@warrenb said:
$AnimatedSprite.get_sprite_frames().set_animation_speed("start", 10.0)
$AnimatedSprite.play("start")
this was the best i could come up with...but the helicopter just disappears
Do you have an animation in your AnimatedSprite
called start
? The name of the animation has to be exactly the same, including capitalized letters. start
and Start
would count as two different animations.
I have not really used AnimatedSprite nodes, but the sprite disappearing seems like it cannot find the animation.
One way you can test to see if the animation exists within your AnimatedSprite is with the following few lines code:
if $AnimatedSprite.frames.has_animation("start") == true:
print ("animation with name *start* exists!")
else:
print ("animation with name *start* does not exist!")
(Side note: $AnimatedSprite.frames
should work just like $AnimatedSprite.get_sprite_frames()
in Godot 3. If you are using Godot 2, then you'll need to use the get_sprite_frames
function)
My hunch is that the name is different and so the helicopter disappears since there is no animation to change to. I could be wrong though.
Does the debugger showing anything after the helicopter disappears? It may be helpful in figuring out what is going on.
I was thinking of something. You said the name of the animation is playerHeli
, correct? If that is the animation you are wanting to change, then the following code should work:
$AnimatedSprite.frames.set_animation_speed("playerHeli", 10.0)
$AnimatedSprite.animation = "playerHeli"
I think the line above, $AnimatedSprite.animation = "playerHeli"
, will have the same effect as calling the play
function, though if the animation is already playerHeli
, then it shouldn't reset the animation. If it does not work or gives an error, then all you should need to do is replace it with $AnimatedSprite.play("playerHeli")
.
But other than what I wrote above, I'm not really sure. I primarily use the 3D side of Godot and have never really used many of the 2D nodes, including AnimatedSprite
. Hopefully this helps though!