tags:

views:

272

answers:

2

Hi,

My game application is having a timer(starting from 0:00 then increases) when it is is running. For that i use, NSTimer and then int hrVal = (timeCount/60)60; int minVal = ((timeCount/60)60)+9; etc code.

At some point of time, lets say user wins one level, i am showing a winning alert, at this point of time, i need to Pause the timer and resume again once user clicked OK button from this alert. Is it possible to do that and How?

I would appreciate if some one help me on this !

Thanks.

+1  A: 

Instead of starting and stopping the timer you could set a BOOL pause = YES and then do nothing in the method that the timer fires while it is YES. When the pause ends set it back to NO.

Felix
Thank you. Could you please clarify more on this as i am not able to get it exactly?
I did it. Great help! Thank you very much.
A: 

You could invalidate the timer when a level is completed and create a new one for the next level.

gerry3
I can't do invalidate as i must have to resume and continue the timer. I meant 'level is not the game level, it just one finish, still user need to finish 10 levels(finishes) to complete the entire First level.
It seems like ignoring the timer (the other solution) for an unknown amount of time while the user dismisses the alert would affect the gameplay more than controlling exactly when the timers exist, but you have way more details about this and it sounds like you found your solution.
gerry3
Thank you so much.