21 lines
450 B
GDScript
Executable File
21 lines
450 B
GDScript
Executable File
extends Node
|
|
|
|
@onready var walk: SpriteFrames
|
|
@onready var idle: SpriteFrames
|
|
|
|
@onready var parent = get_parent()
|
|
@onready var sprite = $"../Sprite"
|
|
|
|
var facing = 1
|
|
|
|
func _process(delta):
|
|
if ! is_zero_approx(parent.velocity.x):
|
|
sprite.scale.x = 1 if parent.velocity.x > 0 else -1
|
|
|
|
if ! parent.is_on_floor():
|
|
sprite.play("Jump")
|
|
elif is_zero_approx(parent.velocity.x):
|
|
sprite.play("Idle")
|
|
else:
|
|
sprite.play("WalkRight", 2.0)
|