【问题标题】:Swift - Trouble with SKAction sequenceSwift - SKAction 序列的问题
【发布时间】:2014-12-10 03:04:42
【问题描述】:

我正在尝试将背景图像向下移动,然后在 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")
            ])
        ))

【问题讨论】:

  • let moveBGback = SKAction.moveToY(0, duration: 3.0)

标签: ios xcode swift sprite-kit skaction


【解决方案1】:

根据你的anchorPoint,第一个动作是正确的。正如 nickfalk 写信给您的那样,第二个动作必须是:

let moveBGback = SKAction.moveToY(0, duration: 3.0) 

如果你想看到你的BG回来,那么你的Y位置错了,否则你的BG被放在屏幕的顶部(所以不可见)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-05
    • 1970-01-01
    • 2016-06-14
    • 1970-01-01
    • 2014-08-21
    • 1970-01-01
    • 2015-06-20
    相关资源
    最近更新 更多