• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

{Solved} 2 second delay problem

S

Specter

Guest
I want to get my game to restart after the player is destroyed with an explosion, but I'm having trouble making it work. Here is what I did. I'm using a Controller object to test if the player exists, I've used in the step event- if instance_number(obj_Player)=0 {alarm[1]=60}. In the alarm[1] game_restart, but the game just keeps running after the player is destroyed. If I put the game_restart in the player object in the collision event after it is destroyed then it restarts but you don't see the explosion. I need the delay to see the explosion, but not sure how to do it since the sleep command is no longer valid. I see from another post that it is probably because I set the alarm in the step event so it always stays at 60 but if not in the step then what?
 
Last edited by a moderator:

Jakylgamer

Member
do this instead
Code:
if !instance_exists(obj_player) {
   if alarm[0]=-1 { //check to make sure alarm isnt running
      alarm[0]=60; //then set alarm to 60 steps
   }
}
you first need to check and see if the alarm is running or not else it will continuously loop
 

Perseus

Not Medusa
Forum Staff
Moderator
The alarm keeps being reset to 60 every step as long as that condition is true, so the alarm event never gets to trigger. You should make sure that it hasn't already been activated by checking if alarm[1] equals -1 prior to setting it to 60 steps.
Code:
if (alarm[1] == -1) {
    alarm[1] = 60;
}
 
S

Specter

Guest
do this instead
Code:
if !instance_exists(obj_player) {
   if alarm[0]=-1 { //check to make sure alarm isnt running
      alarm[0]=60; //then set alarm to 60 steps
   }
}
you first need to check and see if the alarm is running or not else it will continuously loop
Nope that doesn't work either.
 
Top