View unanswered posts | View active topics

Reply to topic  [ 2 posts ] 
How to stop a Timer without reseting it? 
Author Message

Joined: Sat Jun 27, 2015 9:14 pm
Posts: 3
Reply with quote
I'm making a space shooter game similar to Supernova and have an array of "enemy spots" where a Timer checks each spot every second, if a number is found in a spot, then another timer "enemyClock" is activated calling the "createEnemies" function, so that every 600 ms an enemy is created 5 times creating a row of enemies that behave in a certain way.
Now, like every other game, I also made a condition where if SPACE is pressed, everything pauses. The problem comes when I pause the game in the middle function, the subsecuent enemies will all come at the same time in the top of the others since the "createEnemies" is still running, but if I stop the timer (or the function), no more enemies are created since the Timer is reseted to zero.
Any possible solutions?

Wed Jul 01, 2015 10:18 pm

Joined: Wed Aug 31, 2005 7:27 am
Posts: 12172
Location: London
Reply with quote
Better use an enterframe and check the time.
When pausing you can stop this enterframe, and when resuming you can increase all the times by the duration of the pause.

Sat Jul 04, 2015 8:54 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.