37 lines
852 B
GDScript3
37 lines
852 B
GDScript3
extends Node2D
|
|
|
|
|
|
# Declare member variables here. Examples:
|
|
# var a = 2
|
|
# var b = "text"
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
pass # Replace with function body.
|
|
|
|
@export var facing = "S"
|
|
|
|
func play_animation(anim, seek):
|
|
$AnimatedSprite2D.play(anim + "_" + facing)
|
|
$AnimatedSprite2D.frame = seek
|
|
func play_animation_raw(anim):
|
|
$AnimatedSprite2D.play(anim)
|
|
|
|
func play_animation_maintain(anim):
|
|
|
|
var i = $AnimatedSprite2D.frame
|
|
|
|
if anim + "_" + facing != $AnimatedSprite2D.animation:
|
|
#print (anim, i)
|
|
$AnimatedSprite2D.stop()
|
|
$AnimatedSprite2D.play(anim + "_" + facing)
|
|
$AnimatedSprite2D.frame = i
|
|
elif !$AnimatedSprite2D.is_playing():
|
|
$AnimatedSprite2D.play(anim + "_" + facing)
|
|
$AnimatedSprite2D.frame = 0
|
|
|
|
func stop_animation():
|
|
$AnimatedSprite2D.frame = 0
|
|
$AnimatedSprite2D.stop()
|