AcrobatEpee
Member
I have an animation I want to play once and then stop at the current position and change sprite, how may I proceed ? Thanks !
switch(sprite_index) {
case spr_jump_from_ground:
sprite_index = spr_jump_going_up;
break;
case spr_jump_landing:
sprite_index = spr_idle;
break;
}
If you read the post I provided, I gave you a screenshot of how the Animation End event should look like.I tried this and this and it gives me this :/
I guess it is because when the animation ends it is not on the last but on the first image sprite, how may I do then because checking for animation end will just make me enter a loop (My animation sprite will end and my idle sprite will replace it but then my idle sprite will keep being over because there is only one image in it)
Thanks all for helping
Hello, I am new here and I saw this thread.There is an event called Animation End which is called when the sprite is done animating all sub-images.
Inside that event, you can simply test for what sprite you currently have, and if it's the sprite which animation you wanted to play once, then change the sprite.
Using code, you would do something like this:
The above code will change the sprite when the animation ends (if you put it in the 'Other > Animation End' event)Code:switch(sprite_index) { case spr_jump_from_ground: sprite_index = spr_jump_going_up; break; case spr_jump_landing: sprite_index = spr_idle; break; }
only if the sprite was "spr_jump_from_ground" or if it was "spr_jump_landing".
You can do the equivalent with drag n drop, I'm sure you can figure out how to use the "test for sprite" and the "else" control statements
Hope this was usefull
A simple solution to this is:Hello, I am new here and I saw this thread.
I am having similar problem. My ship I want to play the destroyed animation once hit and play it once, but I do not want to switch it to anything else. I want this to happen everytime your ship spawns and gets hit.. I am doing the asteroids game if that helps.
instance_create_layer(obj_Player_Ship.x,obj_Player_Ship.y,"Player_Layer",obj_Ship_Destroy);
instance_destroy();
Thanks for getting back to me so quick. I appreciate your time and effort in helping. I had all of it done as I am doing the tutorial on Youtube. I exchanged the first half of your code with the one in the tutorial and did everything right. When I went to run it and crashed my ship into the asteroid it gave me an error. I changed the first part of the code back to the following:A simple solution to this is:
1. Create two sprites - One of your ship, and the other of the ship's destroy animation.
2. Create two objects - One using the sprite of your ship, and the other using the sprite of your ship's destroy animation.
3. When your ship is hit, in it's destroy event, create a instance of the ships destroy animation in its place.
Example
4. In your ship destroy animation object, destroy the object after it's animation has played.GML:instance_create_layer(obj_Player_Ship.x,obj_Player_Ship.y,"Player_Layer",obj_Ship_Destroy);
(Event>Other>Animation End)
And you're done.GML:instance_destroy();