开发者

Is there an Objective-C equivalent to XNA's update function?

What function can be used in Objective-C, for iPhone, that wo开发者_Python百科rks like the update function in the XNA framework?

Like this:

Is there an Objective-C equivalent to XNA's update function?

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".

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜