我试图将我的背景图像向下移动,然后在3秒延迟后,将其移回屏幕。我希望这种情况永远发生。
它在屏幕上完全滑下来,但是没有其他事情发生。谁能看到我在这里做错了什么?
override func didMoveToView(view: SKView) {
background.anchorPoint = CGPoint(x: 0, y: 0)
background.size = CGSize(width: frame.size.width, height: frame.size.height)
background.name = "bg"
addChild(background)
let moveBG1 = SKAction.moveToY(-(size.height), duration: 3.0)
let moveBGback = SKAction.moveToY(size.height, duration: 3.0)
runAction(SKAction.repeatActionForever(
SKAction.sequence([
SKAction.runAction(moveBG1, onChildWithName: "bg"),
SKAction.waitForDuration(3.0),
SKAction.runAction(moveBGback, onChildWithName: "bg")
])
))
答案 0 :(得分:0)
根据你的anchorPoint,第一个动作是正确的。正如nickfalk写信给你,第二个动作必须是:
let moveBGback = SKAction.moveToY(0, duration: 3.0)
如果你想看到你的BG回来,那么Y位置就错了,否则你的BG被放在屏幕的顶部(所以不可见)