新建易碎平台基类,开发中

This commit is contained in:
EsShen7 2026-01-24 21:14:38 +08:00
parent 52fa2c1f0c
commit d83053d2d7
9 changed files with 73 additions and 2 deletions

View File

@ -0,0 +1,49 @@
extends AnimatableBody2D
@export var shaking_target: Node2D
@export var shake_strength: float = 8.0
@export var shake_duration: float = 0.25
@export var shake_hz: float = 12.0 # 每秒抖几次(关键参数)
signal shaking_finished()
var _origin_pos: Vector2
var _shaking := false
var _rng := RandomNumberGenerator.new()
func _ready() -> void:
if not shaking_target:
shaking_target = self
_rng.randomize()
func shaking() -> void:
if _shaking:
return
if not shaking_target:
shaking_target = self
_origin_pos = shaking_target.position
_shaking = true
var end_timer := get_tree().create_timer(shake_duration)
var interval : float = 1.0 / max(shake_hz, 1.0)
var next_update := 0.0
var current_offset := Vector2.ZERO
while end_timer.time_left > 0.0:
next_update -= get_process_delta_time()
if next_update <= 0.0:
current_offset = Vector2(
randf_range(-shake_strength, shake_strength),
randf_range(-shake_strength, shake_strength)
)
next_update = interval
shaking_target.position = _origin_pos + current_offset
await get_tree().process_frame
shaking_target.position = _origin_pos
_shaking = false
shaking_finished.emit()

View File

@ -0,0 +1 @@
uid://dmamoiy8sl0bn

View File

@ -0,0 +1,3 @@
[gd_scene format=3 uid="uid://goua2e1q7qq6"]
[node name="FragileShakingPlatform" type="Node2D"]

View File

@ -0,0 +1,11 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

View File

@ -0,0 +1 @@
uid://bog8pjjhrcd3g

View File

@ -0,0 +1,3 @@
[gd_scene format=3 uid="uid://dfwups0m7a5m4"]
[node name="VinePlatform" type="Node2D"]

View File

@ -111,6 +111,7 @@ _data = {
point_count = 2 point_count = 2
[node name="L1_S10_1" type="Node2D"] [node name="L1_S10_1" type="Node2D"]
editor_description = "藤蔓平台未制作"
script = ExtResource("1_67t0m") script = ExtResource("1_67t0m")
metadata/_custom_type_script = "uid://5e157vdk6175" metadata/_custom_type_script = "uid://5e157vdk6175"

View File

@ -102,6 +102,7 @@ effect_apply_type = SubResource("Resource_hatj6")
metadata/_custom_type_script = "uid://cdvgq0xqdbagk" metadata/_custom_type_script = "uid://cdvgq0xqdbagk"
[node name="L1_S10_3" type="Node2D"] [node name="L1_S10_3" type="Node2D"]
editor_description = "右侧开口可能考虑变成单向入口,目前若作为出口会影响游玩关卡顺序"
script = ExtResource("1_cg8qb") script = ExtResource("1_cg8qb")
metadata/_custom_type_script = "uid://5e157vdk6175" metadata/_custom_type_script = "uid://5e157vdk6175"

View File

@ -75,7 +75,7 @@ prop_state_map = Dictionary[int, ExtResource("8_42yu5")]({
metadata/_custom_type_script = "uid://fxpk2ot6otfh" metadata/_custom_type_script = "uid://fxpk2ot6otfh"
[sub_resource type="RectangleShape2D" id="RectangleShape2D_nvw5u"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_nvw5u"]
size = Vector2(745, 356) size = Vector2(745, 470.73492)
[sub_resource type="Resource" id="Resource_ctwrc"] [sub_resource type="Resource" id="Resource_ctwrc"]
script = ExtResource("21_hsocq") script = ExtResource("21_hsocq")
@ -118,6 +118,7 @@ _data = {
point_count = 2 point_count = 2
[node name="L1_S10_4" type="Node2D"] [node name="L1_S10_4" type="Node2D"]
editor_description = "右侧落石触发后击中龟裂岩层形成两条通路向上前往l1_s10_3向下打通l1_s10_1的路"
script = ExtResource("1_coo21") script = ExtResource("1_coo21")
metadata/_custom_type_script = "uid://5e157vdk6175" metadata/_custom_type_script = "uid://5e157vdk6175"
@ -168,7 +169,7 @@ effects = Array[ExtResource("14_jsj1s")]([ExtResource("16_1fy8b")])
position = Vector2(2173, -1994) position = Vector2(2173, -1994)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Props/PlayerTriggerVolumn"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Props/PlayerTriggerVolumn"]
position = Vector2(-132.5, 87.265015) position = Vector2(-132.5, 144.63257)
shape = SubResource("RectangleShape2D_nvw5u") shape = SubResource("RectangleShape2D_nvw5u")
debug_color = Color(0.56463546, 0.55446386, 0.07705598, 0.41960785) debug_color = Color(0.56463546, 0.55446386, 0.07705598, 0.41960785)