• 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!

Pause Alarms

D

daniel120

Guest
Is there a method to pause all the alarms of an object besides looping through them and going alarm++ every step?
 
You could save all of their positions in an array or ds_list, then reset them when you want to unpause. For example, pause:
Code:
alarm_list = ds_list_create();
for(var i=0;i<10;i+=1){//replace 10 with number of alarms in object
      ds_list_add(alarm[i]);
      alarm[i]=-1;//stop alarm from happening
}
And unpause:
Code:
var len = ds_list_size(alarm_list);
for(var i=0;i<len;i+=1){
       alarm[i]=ds_list_find_value(alarm_list,i);
}
ds_list_destroy(alarm_list);
 

Jakylgamer

Member
you could try doing something like this.
example :
create event:
///change the 10 the number of alarms being used
Code:
for(var i =0; i<10; i++)
{
   c_alarm[i]=-1;//set a default value
}
then when you want to "pause" them just use the created variables to hold the alarm values.
in an event that only gets called once (maybe a button pressed)
Code:
for(var i=0; i<10; i++)
{
    c_alarm = alarm;
}
//step event
Code:
if (paused==true)
{
   for(vari=0; i<10; i++)
   {
      alarm[i] = c_alarm[i];
   }
}
but if thats not what you need or want to do you can always try using timelines to do what you need, they can be paused ,reversed , and started at specific points
 
W

Wraithious

Guest
when i need to I use a variable to pause the game and alarms, and everything that moves or ticks has the check in the step event like:

Code:
if(global.pause=0)
{
if set=0 set=1;
//do stuff, set alarms, etc
}
if(global.pause=1)
{
hold_alarm[0]=alarm[0];
if set=1 alarm[0]=hold_alarm[0];
hold_alarm[1]=alarm[1];
if set=1 alarm[1]=hold_alarm[1];
hold_alarm[2]=alarm[2];
if set=1 alarm[2]=hold_alarm[2];
//.....etc and then:
set=0;
}
This keeps the alarms set at what they were set at, then when global.pause=0 they count down from where they were
 
Top