Page 1 of 1

Pausing Timers?

PostPosted: Sat Jul 14, 2012 9:14 pm
by happyjustbecause
Hello everybody =D!

I was simply wondering if there's a simple way to pause a timer. I can't really pause the view actor, which hosts the timer event. What I'm trying to do is prevent the player from respawning while the game is paused. Other timers should also be paused in the view actor's control when the game is paused, but I can't pause the view actor because the view actor turns the pause on/off.

Re: Pausing Timers?

PostPosted: Sat Jul 14, 2012 9:31 pm
by lcl
Just add this to your timer events:
Code: Select all
if (paused == 0)
{
    //here your code
}

and they won't do anything even if the timer was running :D

Re: Pausing Timers?

PostPosted: Sat Jul 14, 2012 10:13 pm
by happyjustbecause
But I don't want the timer event to just not happen, I want it to pause and then continue once the game is unpaused. If I have that then the timer event will be cancelled completely, and if the player hasn't respawned and the game is paused, then the player won't ever spawn. And I don't want to create the timer when unpausing. Maybe I have to use a different actor for the respawn timer event, that way I can pause that actor, and not have to pause the view?

Re: Pausing Timers?

PostPosted: Sun Jul 15, 2012 12:06 am
by Fojam
I would make a universal timer that runs ever 100 milliseconds. Then make an integer called worldTime. Each time the timer goes off, have worldTime increment up by 1. For your player, make an integer called myTime. In your drawActor event for the player, say
Code: Select all
if((myTime<=worldTime)&&(paused!=1))
{
    myTime=worldTime+1; //or however many times you want the timer to go off for it
    //do what you would do in the timer
}