나는 탭 사이의 리듬을 유지하려고합니다. 그러나, 나는 무작위로 거대한 가치를 얻고 나는 왜 확실하지 않다.iOS 사이의 타이밍
@implementation GameScene
{
CFTimeInterval previousFrameTime;
SKLabelNode* myLabel;
}
-(void)didMoveToView:(SKView *)view {
previousTimeFrame = 0.0f;
myLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"];
myLabel.text = @" ";
myLabel.fontSize = 12;
myLabel.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
[self addChild:myLabel];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
myLabel.text = [NSSTring stringWithFormat: @"%f", previousFrameTime];
}
//Called every frame
-(void)update:(CFTimeInterval)currentTime {
//get the time between frames
previousFrameTime = CACurrentMediaTime() - previousFrameTime;
}
출력 : 0.65323 0.93527 1.65326 5866.42930 < - ???? 2.52442 5.23156 5888.21345 < - ?????
이러한 임의 점프의 원인은 무엇입니까?
다음은 평균 탭 속도를 계산하는 방법을 보여주는 답변입니다 - 도움이 될 수 있습니다 http://stackoverflow.com/questions/26666972/how-can-i-calculate-the-instantaneous- or-close-to-taps- 초당 쿠키 - 26667164 # 26667164 – Paulw11