SKAction.wait在调用错误中导致额外参数

时间:2017-07-27 06:12:22

标签: ios swift sprite-kit skaction

我正在尝试设置动画和编码文本标签,但是使用SKAction.wait(:)函数会在调用错误中导致额外的参数。这是我的代码。我没有其他错误,我的其他SKAction函数运行正常:

import SpriteKit
import GameplayKit

class GameScene: SKScene {

    private var label : SKLabelNode?


    override func didMove(to view: SKView) {

        // Get label node from scene and store it for use later
        self.label = self.childNode(withName: "//helloLabel") as? SKLabelNode
        if let label = self.label {
            label.alpha = 0.0
            label.run(SKAction.fadeIn(withDuration: 2.0))

            var animateList = SKAction.sequence(SKAction.fadeIn(withDuration: 1.0), SKAction.wait(forDuration: 2.0), SKAction.fadeOut(withDuration: 1.0))

        }
    }
}

1 个答案:

答案 0 :(得分:2)

SKAction.sequence接受一个数组作为参数。所以你的陈述应如下所示

var animateList = SKAction.sequence([SKAction.fadeIn(withDuration: 1.0), SKAction.wait(forDuration: 2.0), SKAction.fadeOut(withDuration: 1.0)])

更多详情here