1
在Objective-C中,iPhone可以使用哪种功能,就像XNA框架中的update
函数一样?是否有与XNA的更新功能相当的Objective-C?
像这样: for automantic update。
在Objective-C中,iPhone可以使用哪种功能,就像XNA框架中的update
函数一样?是否有与XNA的更新功能相当的Objective-C?
像这样: for automantic update。
您必须自己完成繁重的工作,通常是使用线程或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”。
实现UIView的' - (void)layoutSubviews'方法... – Jhaliya