棺材怪砍下动作优化

This commit is contained in:
cakipaul 2025-09-03 21:13:11 +08:00
parent 5b4d976439
commit a8f75d2c61
3 changed files with 32 additions and 24 deletions

View File

@ -95,38 +95,38 @@ animations = [{
"speed": 5.0
}, {
"frames": [{
"duration": 6.0,
"duration": 1.0,
"texture": ExtResource("1_ddjd1")
}, {
"duration": 6.0,
"duration": 1.0,
"texture": ExtResource("2_1bfo3")
}, {
"duration": 6.0,
"duration": 1.0,
"texture": ExtResource("3_j1ego")
}, {
"duration": 6.0,
"duration": 1.0,
"texture": ExtResource("4_s55rn")
}],
"loop": false,
"name": &"棺材怪右砍",
"speed": 30.0
"speed": 5.0
}, {
"frames": [{
"duration": 6.0,
"duration": 1.0,
"texture": ExtResource("5_2j3c0")
}, {
"duration": 6.0,
"duration": 1.0,
"texture": ExtResource("6_nysf7")
}, {
"duration": 6.0,
"duration": 1.0,
"texture": ExtResource("7_0vrf3")
}, {
"duration": 6.0,
"duration": 1.0,
"texture": ExtResource("8_g0hd4")
}],
"loop": false,
"name": &"棺材怪左砍",
"speed": 30.0
"speed": 5.0
}, {
"frames": [{
"duration": 6.0,
@ -169,7 +169,7 @@ animations = [{
"duration": 6.0,
"texture": ExtResource("2_0dcjf")
}],
"loop": true,
"loop": false,
"name": &"棺材怪移动",
"speed": 30.0
}, {
@ -180,7 +180,7 @@ animations = [{
"duration": 6.0,
"texture": ExtResource("20_pjkh2")
}],
"loop": true,
"loop": false,
"name": &"棺材怪移动右",
"speed": 30.0
}, {

View File

@ -828,7 +828,7 @@ self_modulate = Color(1, 1, 1, 0)
z_index = -1
position = Vector2(3434, -17.5)
sprite_frames = ExtResource("16_f57cq")
animation = &"棺材怪砍"
animation = &"棺材怪砍"
script = ExtResource("9_js8ld")
mute = true
move_target = NodePath("../../DeployLayer/MonsterMoveTarget")

View File

@ -42,6 +42,8 @@ func _ready() -> void:
left_area.body_entered.connect(_on_player_chopped)
right_area.body_entered.connect(_on_player_chopped)
_on_mute_updated()
if GlobalConfig.DEBUG:
animation_changed.connect(func(): print("animation changed:", animation))
func _on_mute_updated() -> void:
@ -76,10 +78,10 @@ func chop_left(aiming_duration := AIMING_DURATION) -> void:
return
hand_mode = 0
aiming += 1
_checkout_hand_animation(false)
var tween = create_tween()
if aiming_duration > 0.0:
tween.tween_property(remote_left_shadow, "scale", Vector2.ONE, aiming_duration)
tween.tween_callback(_checkout_hand_animation.bind(false))
tween.tween_callback(left_side_sprite.play)
tween.tween_property(remote_left_side, "position:y", 0.0, 0.15)
if aiming_duration <= 0.0:
@ -99,10 +101,10 @@ func chop_right(aiming_duration := AIMING_DURATION) -> void:
return
hand_mode = 1
aiming += 1
_checkout_hand_animation(false)
var tween = create_tween()
if aiming_duration > 0.0:
tween.tween_property(remote_right_shadow, "scale", Vector2.ONE, aiming_duration)
tween.tween_callback(_checkout_hand_animation.bind(false))
tween.tween_callback(right_side_sprite.play)
tween.tween_property(remote_right_side, "position:y", 0.0, 0.15)
if aiming_duration <= 0.0:
@ -152,6 +154,7 @@ func _physics_process(delta: float) -> void:
target_x -= right_hand_x_offset
var x = global_position.x
if chopped_safe_period or abs(target_x - x) < 0.1:
if not playing_chopping_animation:
stop()
if footstep_sfx.playing:
footstep_sfx.stop()
@ -165,17 +168,22 @@ func _physics_process(delta: float) -> void:
# prints(x, target_x)
if not footstep_sfx.playing:
footstep_sfx.play()
_checkout_hand_animation()
_checkout_hand_animation(true)
var playing_chopping_animation = false
func _checkout_hand_animation(is_move := true) -> void:
func _checkout_hand_animation(moving: bool) -> void:
if playing_chopping_animation:
return
var target_animation = ""
if is_move:
if moving:
target_animation = "棺材怪移动" if hand_mode == 0 else "棺材怪移动右"
if not is_playing():
play(target_animation)
else:
playing_chopping_animation = true
target_animation = "棺材怪左砍" if hand_mode == 0 else "棺材怪右砍"
if not is_playing() or animation != target_animation:
if hand_mode == 0:
play(target_animation)
else:
if GlobalConfig.DEBUG:
prints("play chopping animation:", target_animation)
play(target_animation)
Util.timer(1.0, func(): playing_chopping_animation = false)