Even more changes.
This commit is contained in:
Executable → Regular
+27
-10
@@ -7,10 +7,12 @@ extends AnimatedSprite2D
|
||||
func _ready():
|
||||
play("default")
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(_delta):
|
||||
match player.state:
|
||||
if player.direction and player.state not in Player.STATES_IMMOBILE:
|
||||
flip_h = player.direction < 0
|
||||
|
||||
func _on_player_state_change(old: Player.States, new: Player.States) -> void:
|
||||
match new:
|
||||
Player.States.IDLE:
|
||||
play("default")
|
||||
Player.States.RUN_START:
|
||||
@@ -37,18 +39,33 @@ func _process(_delta):
|
||||
frame = 4
|
||||
Player.States.LAY:
|
||||
play("lay")
|
||||
if player.direction:
|
||||
flip_h = player.direction < 0
|
||||
Player.States.POUND:
|
||||
play("pound")
|
||||
if old == Player.States.POUND_FALL:
|
||||
frame = 4
|
||||
Player.States.POUND_FALL:
|
||||
play("pound_fall")
|
||||
Player.States.KICK:
|
||||
play("kick")
|
||||
|
||||
func _on_animation_finished():
|
||||
match animation:
|
||||
"run_start":
|
||||
player.state = Player.States.RUN
|
||||
"land":
|
||||
player.state = Player.States.IDLE
|
||||
"jump_start":
|
||||
player.state = Player.States.JUMP
|
||||
"roll":
|
||||
player.state = Player.States.IDLE
|
||||
"damage":
|
||||
"land", "roll", "damage", "pound", "kick":
|
||||
player.state = Player.States.IDLE
|
||||
|
||||
func _on_frame_changed() -> void:
|
||||
match animation:
|
||||
"pound" when frame == 3 and !player.is_on_floor():
|
||||
player.state = Player.States.POUND_FALL
|
||||
"pound" when frame == 5:
|
||||
player.audio_player.stream = player.POUND_SOUND
|
||||
player.audio_player.play()
|
||||
|
||||
var pound_bullet = player.POUND_BULLET.instantiate()
|
||||
pound_bullet.position = player.position
|
||||
pound_bullet.flip_h = !flip_h
|
||||
player.add_sibling(pound_bullet)
|
||||
|
||||
Reference in New Issue
Block a user