-1

When the player dies, I want the sprite to stop animating on the last frame.

I tried this on Animation End event

if  (sprite_index == spr_ninja_dead) {
    image_speed = 0;
    image_index = image_number - 1;
}

I also tried this

if  (sprite_index == spr_ninja_dead) {
    image_speed = 0;
    image_index = 9;
}

This is the recommended way that GM suggests, yet the sprite freezes on the first sub image. What am I doing wrong?

TIES
  • 1
  • 1
  • 1
  • I added some text for debugging. It says that image_index is 9, yet it is showing the sprite sub image 0. Why is this happening? – TIES Jul 14 '16 at 15:09

2 Answers2

0

When the player gets hit, the sprite would change to a flashing sprite image. Then an alarm would change it back to normal. I added an if statement to fix this:

if (sprite_index = spr_ninja_flash){
    sprite_index = spr_ninja_idle;
}
TIES
  • 1
  • 1
  • 1
0

What you want to do is run the animation first. So try this:

if( sprite_index == spr_ninja_dead ){
  if( image_index == image_number ){ // This will check if the image is the last image of the sprite
     image_speed = 0;
  }
}

First you check if the sprite is the dead one, then you check if it's the last image of the sprite and if that is the case you can pause the animation using the image speed.

StefanJanssen
  • 446
  • 1
  • 7
  • 18