Animated sprite fix for animation sequence. This whole thing needs some work.

This commit is contained in:
Dustin 2025-06-19 08:43:08 -07:00
parent c5fa3e8edb
commit 94274cd447
2 changed files with 7 additions and 0 deletions

View File

@ -1,6 +1,8 @@
class_name AnimatedSprite_StateReceiver class_name AnimatedSprite_StateReceiver
extends AnimatedSprite extends AnimatedSprite
export var debug_component: bool = false
export var callable_state_machine :NodePath export var callable_state_machine :NodePath
onready var current_state = StateAnimatedActor.new() onready var current_state = StateAnimatedActor.new()
@ -55,6 +57,8 @@ func _process(delta):
call('_state_process_' + current_state.name) call('_state_process_' + current_state.name)
func _on_animation_finished(): func _on_animation_finished():
if debug_component:
var foo = 2+2
if frames.get_animation_loop(animation) == false: if frames.get_animation_loop(animation) == false:
#print("Stop!!!!!", current_state.animation_sequence.size(), " - ", current_state.animation_index) #print("Stop!!!!!", current_state.animation_sequence.size(), " - ", current_state.animation_index)
if current_state.animation_sequence.size() > 0: if current_state.animation_sequence.size() > 0:
@ -63,6 +67,8 @@ func _on_animation_finished():
if animation_index >= current_state.animation_sequence.size(): if animation_index >= current_state.animation_sequence.size():
#print("Stop!!!!!") #print("Stop!!!!!")
current_state.animation_finished = true current_state.animation_finished = true
else:
change_animation(0,animation_index)
##TODO: Allow a way to stop animation even if in a looped sequence ##TODO: Allow a way to stop animation even if in a looped sequence
# If called, this will attempt to make the most appropriate animation change # If called, this will attempt to make the most appropriate animation change

View File

@ -27,6 +27,7 @@ states = [ ExtResource( 3 ), ExtResource( 6 ) ]
[node name="AnimatedSprite_StateReceiver" parent="." index="1"] [node name="AnimatedSprite_StateReceiver" parent="." index="1"]
frames = ExtResource( 2 ) frames = ExtResource( 2 )
playing = true playing = true
debug_component = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="4"] [node name="CollisionShape2D" type="CollisionShape2D" parent="." index="4"]
position = Vector2( -5, 6 ) position = Vector2( -5, 6 )