• 15
• 15
• 11
• 9
• 10

# Stop Clock (Pause)

This topic is 3699 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I was playing around with this tutorial (http://www.gamedev.net/community/forums/topic.asp?topic_id=192483&PageSize=25), and I was trying to figure out a pause function, but I was having trouble, any of you have ideas how to pause it? Would I stop the game loop? If so, how? Thanks.

##### Share on other sites
Could you describe the problem in more detail? It looks like your link goes to a page which discusses a page that you are talking about...

In any case, what's preventing you from just doing something like:
if (paused == false)  GameLogic();

##### Share on other sites
Without reading the link, there are a few ways to implement a basic pause function.

1) stop calling Update() on objects you want paused (everything in the game world, probably, but NOT the GUI or input or you won't be able to unpause)

2) pass a zero time delta to the update objects to make them think no time has elapsed - not as good as option #1.

3) don't update the time at all

##### Share on other sites
Sorry, I linked to the last page, but I fixed it, if you could look, that would be great. :D

##### Share on other sites
Well, I tried

if(!paused)
{
do stuff
}

but it didn't work, it compiled, but nothing happened.

##### Share on other sites
Quote:
 Original post by TheUnbelieverOr, indeed....
Heh... I sometimes explicitly put the equality test for readability, but in this case "!paused" is certainly more readable.

##### Share on other sites
Quote:
Original post by smitty1276
Quote:
 Original post by TheUnbelieverOr, indeed....
Heh... I sometimes explicitly put the equality test for readability, but in this case "!paused" is certainly more readable.

Oops, I accidentally deleted the post when editing.

Quote:
Original post by TheUnbeliever
Quote:
 Original post by smitty1276In any case, what's preventing you from just doing something like:if (paused == false) GameLogic();

Or, indeed,

if (!paused)  GameLogic();