Pausing Timers?

Non-platform specific questions.

Pausing Timers?

Postby happyjustbecause » Sat Jul 14, 2012 9:14 pm

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.
For small creatures such as we the vastness is bearable only through love.
-Carl Sagan

Night Knight Development Thread
User avatar
happyjustbecause
 
Posts: 267
Joined: Tue Jul 26, 2011 3:10 pm
Location: Frazier Park, Ca
Score: 15 Give a positive score

Re: Pausing Timers?

Postby lcl » Sat Jul 14, 2012 9:31 pm

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
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Pausing Timers?

Postby happyjustbecause » Sat Jul 14, 2012 10:13 pm

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?
For small creatures such as we the vastness is bearable only through love.
-Carl Sagan

Night Knight Development Thread
User avatar
happyjustbecause
 
Posts: 267
Joined: Tue Jul 26, 2011 3:10 pm
Location: Frazier Park, Ca
Score: 15 Give a positive score

Re: Pausing Timers?

Postby Fojam » Sun Jul 15, 2012 12:06 am

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
}
CLICK TO GIVE ME POINTS

My Latest Projects:
Super Smash Bros: viewtopic.php?f=6&t=12307 PLEASE help by making sprites!
User avatar
Fojam
 
Posts: 513
Joined: Thu Mar 19, 2009 10:02 pm
Location: under your bed!!!
Score: 69 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest