Sprite Animation just 1 time and not a loop

C

Coleft

Guest
How can I do that coz if I add the Sprite to an object, it will start again and again
 

Yal

šŸ§ *penguin noises*
GMC Elder
Add Event--->Other (the icon is a small green rhombus)--->Animation End

Tip: this event is great for explosions and other effects (make them destroy themselves in the animation end event).
 
What you want to do after the animation ends?

If you want to destroy the object-

Under Animation End-
Execute a piece of code-
Then write-
instance_destroy()

if you want to stop the animation at a particular frame-

Under Animation End-
Execute a piece of code-
Then write-
image_speed=0
image_index= "Any number of frame from the animation like 0,1,2,3 etc."
 
B

Bryan Green

Guest
But how do you target WHICH animation has ended? if you have an idle animation that gets switched to another animation you want to run once-- if you used 'animation end' it'll fire on every cycle of the idle animation, not just the other animation....
 

jo-thijs

Member
But how do you target WHICH animation has ended? if you have an idle animation that gets switched to another animation you want to run once-- if you used 'animation end' it'll fire on every cycle of the idle animation, not just the other animation....
You can check the value of the variable sprite_index in the animation end event.
 

Yal

šŸ§ *penguin noises*
GMC Elder
You can check the value of the variable sprite_index in the animation end event.
Or in more practical terms, something like this:
Code:
///Animation end event
switch(sprite_index){
  case spr_attackanimation1:
  case spr_attackanimation2:
  case spr_someotheranimationthatonlyrunsonce:
    sprite_index = spr_idle
  break

  default: // do nothing
}
 
Top