Ios 如何在应用程序中创建动作序列,如在spritekit游戏中?
我试着让一个人向左移动,转过身,然后向右移动。我知道如何在Spritekit中实现这一点,它使用SKAction序列。然而,我真的很难在应用程序而不是游戏中做到这一点。我现在所做的将导致家伙同时移动和转向:Ios 如何在应用程序中创建动作序列,如在spritekit游戏中?,ios,swift,animation,Ios,Swift,Animation,我试着让一个人向左移动,转过身,然后向右移动。我知道如何在Spritekit中实现这一点,它使用SKAction序列。然而,我真的很难在应用程序而不是游戏中做到这一点。我现在所做的将导致家伙同时移动和转向: UIView.animateWithDuration(5.0, delay: 0.0, options: [ .Repeat, .Autoreverse, .CurveEaseInOut], animations: { self.guy.center.x -= 130
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 )
})