我正在制作一个游戏,当用户移动时,源和目标方块会在动画中亮起。动画持续时间为 1 秒。
问题是当用户太快地点击前进按钮时,所有源和目标方块都会亮起,导致许多亮起的方块发生,因为第二个动画在第一个动画结束之前开始。
当动画的持续时间未结束时,我如何突然结束动画。
动画功能代码:-
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:value];
[UIView setAnimationRepeatCount:1];
// [UIView setAnimationRepeatAutoreverses:YES];
[self.view viewWithTag:(src+1)+2000].backgroundColor=[UIColor orangeColor];
[self.view viewWithTag:(src+1)+2000].backgroundColor=[UIColor clearColor];
[self.view viewWithTag:(dest+1)+2000].backgroundColor=[UIColor orangeColor];
[self.view viewWithTag:(dest+1)+2000].backgroundColor=[UIColor clearColor];
[UIView commitAnimations];
注意:- 我接受反对票是一种健康的批评方式,但请写下原因以便我改进