How to play once the animation of die before function( game_restart(); )

Gorshalox

Member
I'm making 2d platformer in GMS Language. I've a varibale "hpHero" and i did like " if hpHero=0 { game_restart(); } but I need to play the animation of die before game will restart,pls help me
 

chamaeleon

Member
I'm making 2d platformer in GMS Language. I've a varibale "hpHero" and i did like " if hpHero=0 { game_restart(); } but I need to play the animation of die before game will restart,pls help me
Perhaps you can switch to the die sprite animation (and set image_index to zero as well) when hpHero is zero, and in the Animation End event check if the sprite is the die sprite, and if so, game_restart().
 

descrubb

Member
You could set an alarm to restart the game after a certain amount of time, e.g. the duration of the death animation.

When hero dies:
GML:
if hpHero = 0
{
sprite_index = hero_die_sprite // set current sprite to death sprite
image_index = 0 // start at the beginning
image_speed = 1 // play at speed set in sprite editor
alarm_set(0, 180) //Alarm 0, 180 frames at 60fps = 3 seconds before alarm triggers
}
In the Alarm 0 Event:
GML:
game_restart()
 
I made the death animation in my game a separate object- the player instance is changed to it, and obj_death has an Animation End event that restarts the game.
 
Top