现在的位置: 首页 > 综合 > 正文

NSTimer的暂停和继续

2018年07月15日 ⁄ 综合 ⁄ 共 416字 ⁄ 字号 评论关闭

可以用NSTimer设置访问函数的时间周期:

复制代码

countTime = [NSTimerscheduledTimerWithTimeInterval :( 1.0/60.0

                                     target:self 

                                   selector:@selector(updateBoard) 

                                   userInfo:nil 

                                    repeats:YES];

 

 

复制代码

即每1/60秒调用一次updateBoard函数

但是有时候游戏里要暂停,可以这样:

[countTime setFireDate:[NSDate distantFuture]]; 

需要继续的时候

[countTime setFireDate:[NSDate date]]; 

转自:http://www.cnblogs.com/crazyac/articles/2497477.html

抱歉!评论已关闭.