iPhone:Timer pause and resume?
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 p开发者_JAVA百科oint 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.
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.
You could invalidate
the timer when a level is completed and create a new one for the next level.
精彩评论