clock system getting paused

C

Chtichoko

Guest
Hey there,

I created a basic clock who is persistent from my 1st level to my last one.
I have a menu transition leading to next level from one to two then from 2 to 3...

I want that my clock is getting paused while i m in transition screen cause for now, the clock still continuing...
I can t find anything about this feature and i m pretty new on GM2.

To understand, Here s what i made with an object named clock and where s i m lost...
I want that my clock getting PAUSED when my player leave level 1 to transition menu then UNPAUSED when starting level 2.

create event :

image_speed = 0;
alarm[0] = 60;
clockactived = 1;
seconds= 00;
minutes =00;


STEP :

if clockactived = 1{
secondes +=1/60
minutes =0

if(seconds >= 60)
{
seconds = 0
minutes++
}
}
else if
clockactived =0
{ frame -= vitTemps }

Alarm :
alarm[0] = 60;

Draw GUI :

case rm_level1:
draw_text(110, 450,string (minuts)+"min. "+string(secondes)+"sec.")
case rm_level2:
draw_text(110, 450,string (minuts)+"min. "+string(secondes)+"sec.")

i think that STEP event doesnt have all needed to get the pause system.
i already tried something about putting "clockactived =0" when i player finished level 1 then putting back clockactived to 1 when starting level 2 but not working.

If you can help, you re welcome :D

Thank you,
 

flyinian

Member
GML:
create event :

image_speed = 0;
alarm[0] = 60;
clockactived = false;    // A variable that tracks if the clock is active or not. This can be made into a global variable.
seconds = 00;
minutes = 00;


STEP :
if(clockactived)// This means when "clockactived" == true then do the following code. "if(clockactived)" means if its true & "if(!clockactived)" means if its false. The "!" turns it into a false.
{
// Your code that makes your clock tick
}
So, when your game enters a scene that you don't want your clock to continue counting, just set "clockactived" to false somewhere in your game like in a controller object.

GML:
// Controller Object

// Create event

_InTransition = false; // So, when ever you enter a transition you set this to "true".


// Step event

if(_InTransition)
{
    clockactived = false;
}
else
{
    clockactived = true;
};
I hope this helps.
 
Last edited:
Top