Hi, all! I was wondering if there was an efficient way to make a one-framed animation play at the beginning, and another after colliding with a kinematic body 2D (The animated sprite is on an Area2D)? I originally had both frames in their own animations, but neither of them worked. I then wondered if I should put them in one animation, and just have the animation run to switch the frame. Another thought was to have two completely different sprites, and destroy the unnecessary one after the collision.
So far, I'm testing working with one animation and two frames. None of the codes I've tried even changes the frame- it's stuck on the first one. Here's the code so far.
extends Area2D
export var connected = false
# Called when the node enters the scene tree for the first time.
func _ready():
$AnimatedSprite.animation = "switch"
$AnimatedSprite.set_frame(0)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#pass
func _on_Area2D_body_entered(body):
$AnimatedSprite.animation = "on"
connected = true
$AnimatedSprite.set_frame(1)