iOS 7 Sprite Kit帧率

时间:2013-10-10 20:56:47

标签: ios7 sprite-kit

我已经以两种不同的形式为SKScene编写了-update方法,其中一种方法的帧速率比另一种方式好得多。

有人可以解释两种实现之间的区别以及为什么它们创建两种不同的帧速率的原因吗?

Method 1 (frame rate drops to about 20-30 fps when moving sprite)

- (void)update:(NSTimeInterval)currentTime

    {
        [self updateBackground];
        player.position = CGPointMake(slider.sliderValue * self.view.frame.size.width/200 + self.view.frame.size.width/2, player.position.y);
    }


Method 2 (frame rate remains constant 60 fps when moving sprite)

- (void)update:(NSTimeInterval)currentTime
    {
        [self updateBackground];
        delta = currentTime - previousTime;
        previousTime = currentTime;
        //NSLog(@"%f",delta);
        player.position = CGPointMake(delta * adjustmentFactor * slider.sliderValue * self.view.frame.size.width/200 + self.view.frame.size.width/2, player.position.y);
    }

0 个答案:

没有答案