我试图让一个人向左移动,转身,然后向右移动。我知道如何在 Spritekit 中执行此操作,它使用 SKAction 序列。然而,我真的很难在应用程序而不是游戏中做到这一点。我现在所拥有的将导致那家伙同时移动和转身:
UIView.animateWithDuration(5.0, delay: 0.0, options: [ .Repeat, .Autoreverse, .CurveEaseInOut], animations: {
self.guy.center.x -= 130
}, completion: nil)
//
UIView.animateWithDuration(5.0, delay: 5.0, options: [ .CurveEaseInOut, .Repeat, .Autoreverse ], animations: {
self.guy.transform = CGAffineTransformMakeScale(-1, 1)
}, completion:nil )
谢谢!
最佳答案
如果第一个动画触发第二个动画,您可以使用完成处理程序。
将其放入一个函数中,并使用计时器触发该函数以创建循环
UIView.animateWithDuration(5.0, delay: 0.0, options: [ .Repeat, .Autoreverse, .CurveEaseInOut], animations: {
self.guy.center.x -= 130
}, completion: {
UIView.animateWithDuration(5.0, delay: 0.0, options: [ .CurveEaseInOut, .Repeat, .Autoreverse ], animations: {
self.guy.transform = CGAffineTransformMakeScale(-1, 1)
}, completion:nil )
})
关于ios - 如何在应用程序中创建 Action 序列(例如 spritekit 游戏)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36669373/