What function can be used in Objective-C, for iPhone, that wo开发者_Python百科rks like the update
function in the XNA framework?
Like this:
for automantic update.You'll have to do the heavy lifting yourself, typically by using threading or an NSTimer object.
For example:
[NSTimer scheduledTimerWithTimeInterval:0.033f target:self
selector:@selector(mainLoop:) userInfo:nil repeats:NO];
where the "selector" points to your game loop function. Make sure the game loop creates another NSTimer after calling Update and Render:
- (void) mainLoop: (id) sender
{
[Update];
[Render];
[NSTimer scheduledTimerWithTimeInterval:sleepPeriod target:self
selector:@selector(mainLoop:) userInfo:nil repeats:NO];
}
Also check out this thread for threading discussion: What is a better way to create a game loop on the iPhone other than using NSTimer?
Or Google "iOS gameloop NSTimer".
精彩评论