我有几个runBlocks需要按顺序运行,但即使使用SKAction.sequence([action1,action2,action3])它们仍然可以同时运行。任何帮助将不胜感激。
以下是我的代码示例:
func SetupText() {
let wait = SKAction.waitForDuration(2.0)
var Label1 = SKLabelNode()
Label1.fontColor = UIColor.whiteColor()
Label1.position = CGPointMake(self.size.width / 2.3, self.size.height / 1.4)
Label1.text = "blah1"
self.addChild(Label1)
scrollLabel1 = SKAction.runBlock({
self.runSomeCode(Label1)
})
var Label2 = SKLabelNode()
Label2.fontColor = UIColor.whiteColor()
Label2.position = CGPointMake(self.size.width / 2.5, self.size.height * 0.6)
Label2.text = "blah2"
self.addChild(Label2)
scrollLabel2 = SKAction.runBlock({
self.runSomeCode(Label2)
})
var Label3 = SKLabelNode()
Label3.fontColor = UIColor.whiteColor()
Label3.position = CGPointMake(self.size.width / 2.5, self.size.height * 0.5)
Label3.text = "blah3"
self.addChild(Label3)
scrollLabel3 = SKAction.runBlock({
self.runSomeCode(Label3)
})
var Label4 = SKLabelNode()
Label4.fontColor = UIColor.whiteColor()
Label4.position = CGPointMake(self.size.width / 2.5, self.size.height * 0.4)
Label4.text = "blah4"
self.addChild(Label4)
scrollLabel4 = SKAction.runBlock({
self.runSomeCode(Label4)
})
var Label5 = SKLabelNode()
Label5.fontSize = 20
Label5.fontName = "LiquidCrystal-Regular"
Label5.fontColor = UIColor.whiteColor()
Label5.position = CGPointMake(self.size.width / 2.5, self.size.height * 0.3)
Label5.text = "blah5"
self.addChild(Label5)
scrollLabel5 = SKAction.runBlock({
self.runSomeCode(Label5)
})
var actions = Array<SKAction>()
actions.append(wait)
actions.append(scrollLabel1)
actions.append(scrollLabel2)
actions.append(scrollLabel3)
actions.append(scrollLabel4)
actions.append(scrollLabel5)
let sequence = SKAction.sequence(actions)
self.runAction(sequence)
}
答案 0 :(得分:0)
实际上它似乎与动作无关,但它与运行块有关。运行块的操作时间可能比序列长,这意味着您的序列似乎是并发的。使用常规操作而不是操作块需要解决您的问题。