我正在尝试使QueueBall遵循路径。但是,当它第一次启动时,它会偏离路径并扭曲形状。一旦到达第三点,它便正确地遵循了路径。
有什么建议吗?
这似乎仅在我更改Main.Storyboard中的自动调整大小以适合全长和高度时才会发生。但仅适用于最初的开始。到达第3点后,它可以完美运行。
这是我正在使用的代码:
-(void)startEX1{
viewQueuBall.frame = viewP1.frame;
[UIView animateKeyframesWithDuration:animationSpeed delay:0.0 options:UIViewKeyframeAnimationOptionAllowUserInteraction animations:^{
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.5 animations:^{
viewQueuBall.frame = viewP2.frame;
}];
[UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:1.0 animations:^{
viewQueuBall.frame = viewP3.frame;
}];
}completion:^(BOOL finished) {
[self startEX2];
}];
}
-(void)startEX2{
viewQueuBall.frame = viewP3.frame;
[UIView animateKeyframesWithDuration:animationSpeed delay:0.0 options:UIViewKeyframeAnimationOptionAllowUserInteraction animations:^{
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.5 animations:^{
viewQueuBall.frame = viewP4.frame;
}];
[UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:1.0 animations:^{
viewQueuBall.frame = viewP1.frame;
}];
}completion:^(BOOL finished) {
stepCount++;
NSLog(@"Step Count = %i", stepCount);
NSLog(@"Animation Speed = %f", animationSpeed);
if (stepCount > 5) {
[self performSegueWithIdentifier:kSegueGameCompleted sender:self];
return;
}
if (stepCount == 2) {
animationSpeed = 2.0;
}else if (stepCount == 3){
animationSpeed = 1.5;
}else if (stepCount == 4){
animationSpeed = 1.0;
}
[self startEX1];
}];
}