【发布时间】:2018-04-04 15:50:47
【问题描述】:
所以我是 swift 的新手,我正在尝试制作一个有玩家汽车和对手汽车的汽车游戏。对手的汽车将穿过屏幕并重复,直到游戏结束。我现在正在实施对手汽车,但我遇到了一个问题,对手汽车的动画只穿过屏幕的一半,直到它们消失并再次开始循环。我将如何改变这一点,以便对手的汽车穿过整个屏幕?这是我当前对对手汽车的代码:
//animation of opponent car1
UIView.animate(withDuration: 4, delay: 0.0, options: [UIViewAnimationOptions.repeat], animations:
{
self.car1image.center.y += self.view.bounds.width
}, completion: nil
)
//opponent car2
UIView.animate(withDuration: 4, delay: 1.0, options: [UIViewAnimationOptions.repeat], animations:
{
self.car2image.center.y += self.view.bounds.width
}, completion: nil
)
//opponent car3
UIView.animate(withDuration: 4, delay: 2.0, options: [UIViewAnimationOptions.repeat], animations:
{
self.car3image.center.y += self.view.bounds.width
}, completion: nil
)
【问题讨论】: