所以我有这段代码。如果计数器是5,我想增加气泡的生成时间。我已经完成了部分代码,但它没有工作。
//This spawn bubbles every "delayBubbleSpawn"
var delayBubbleSpawn = SKAction.waitForDuration(3.0)
//Running the bubble and cone action
runAction(SKAction.sequence([SKAction.runBlock(addCones),
SKAction.repeatActionForever(SKAction.sequence([SKAction.runBlock(addBubbles),
delayBubbleSpawn]))]))
override func update(currentTime: CFTimeInterval) {
scoreLabel?.text = "Score : \(score)"
if counter_speed == 5 { //if score is 5, increase spawning time
actionForKey("delayBubbleSpawn")!.speed += 20.0
}
}
答案 0 :(得分:1)
这应该有效,而且不那么复杂。 运行此功能,然后你就开始产生你的气泡和锥体
func spawnBubbles() {
let bubbleDelayTime: NSTimeInterval = 3.0
if counter_speed == 5 {
bubbleDelayTime = 25.0
}
addCones()
addBubbles()
runAction(SKAction.sequence([
SKAction.waitForDuration(bubbleDelayTime),
SKAction.performSelector(spawnBubbles(), onTarget: self)
]))
}