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