开发者

iPhone:Timer pause and resume?

开发者 https://www.devze.com 2022-12-11 17:52 出处:网络
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;

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消