SKAction.wait 导致调用错误中的额外参数
SKAction.wait causing Extra Argument in Call Error
我正在尝试对文本标签进行动画处理和编码,但是使用 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))
}
}
}
SKAction.sequence
接受一个数组作为参数。所以你的声明应该是这样的
var animateList = SKAction.sequence([SKAction.fadeIn(withDuration: 1.0), SKAction.wait(forDuration: 2.0), SKAction.fadeOut(withDuration: 1.0)])
更多详情here
我正在尝试对文本标签进行动画处理和编码,但是使用 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))
}
}
}
SKAction.sequence
接受一个数组作为参数。所以你的声明应该是这样的
var animateList = SKAction.sequence([SKAction.fadeIn(withDuration: 1.0), SKAction.wait(forDuration: 2.0), SKAction.fadeOut(withDuration: 1.0)])
更多详情here