2011-09-07 64 views

回答

0

您必须自己完成繁重的工作,通常是使用线程或NSTimer对象。

例如:

[NSTimer scheduledTimerWithTimeInterval:0.033f target:self 
      selector:@selector(mainLoop:) userInfo:nil repeats:NO]; 

其中 “选择” 点到你的游戏循环功能。确保游戏循环中调用更新和渲染之后创建另一个的NSTimer:

- (void) mainLoop: (id) sender 
    { 
     [Update]; 
     [Render]; 

     [NSTimer scheduledTimerWithTimeInterval:sleepPeriod target:self 
       selector:@selector(mainLoop:) userInfo:nil repeats:NO]; 
    } 

还检查了这个线程的线程讨论:What is a better way to create a game loop on the iPhone other than using NSTimer?

或谷歌“的iOS gameloop的NSTimer”。

相关问题