33 lines
745 B
GDScript
33 lines
745 B
GDScript
extends NodeState
|
|
|
|
@export var player: Player
|
|
@export var animatedSprite2D: AnimatedSprite2D
|
|
|
|
@onready var friction = player.friction
|
|
|
|
@warning_ignore("unused_parameter")
|
|
func on_process(delta: float) -> void:
|
|
pass
|
|
|
|
@warning_ignore("unused_parameter")
|
|
func on_phyisics_process(delta: float) -> void:
|
|
|
|
player.velocity.x = move_toward(player.velocity.x, 0, friction * delta)
|
|
|
|
if !animatedSprite2D.is_playing():
|
|
transition.emit("idle")
|
|
|
|
var direction = GameInputEvents.movement_input()
|
|
|
|
if direction != 0 and animatedSprite2D.frame > 4:
|
|
transition.emit("Run")
|
|
|
|
if GameInputEvents.jump_input() and animatedSprite2D.frame > 4:
|
|
transition.emit("Jump")
|
|
|
|
func enter() -> void:
|
|
animatedSprite2D.play("Land")
|
|
|
|
func exit() -> void:
|
|
pass
|