3

我以两种不同的形式为 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);
    }
4

0 回答 0