GML Need help with animations[SOLVED]

G

GalGames

Guest
I have a sprite when obj_enemy dies but I don't know how to put the sprite spr_explosion on the obj_enemy.

I tried putting that if enemy_life = 0 {sprite_index = spr_explosion} and it doesn't work. Need help! Thanks!
 

Slyddar

Member
I like to create a new object and assign the explosion sprite to that. Add an Other -> Animation End event, and destroy the instance with this code, which will happen after the explosion animation plays.
Code:
instance_destroy();
Then when the obj_enemy dies, you need to create an instance of the explosion. Depending if you are running GMS 1.x or 2 you would do something like this
Code:
if enemy_life <= 0 {
  //gms2
  instance_create_depth(x, y, depth, obj_explosion);
  //gms1.x
  create_instance(x, y, obj_explosion);
  //destroy the enemy object
  instance_destroy();
}
 
Last edited:
G

GalGames

Guest
I like to create a new object and assign the explosion sprite to that. Add an Other -> Animation End event, and destroy the instance with this code, which will happen after the explosion animation plays.
Code:
instance_destroy();
Then when the obj_enemy dies, you need to create an instance of the explosion. Depending if you are running GMS 1.x or 2 you would do something like this
Code:
if enemy_life == 0 {
  //gms2
  instance_create_depth(x, y, depth, obj_explosion);
  //gms1.x
  create_instance(x, y, obj_explosion);
  //destroy the enemy object
  instance_destroy();
}
Thanks, you helped me:)
 
Top