2015-05-11 49 views
-2
override func update(currentTime: CFTimeInterval) { 
    if currentTime - self.lastEnemyAdded > 1 { //my lastEnemyAdded is "var lastEnemyAdded : NSTimeInterval = 0.0" 
     self.lastEnemyAdded = currentTime + 0.5 //how can i make this -0.1 as the game go longer or if the player reach a certain score 
     self.addEnemy() //can someone help me please 
    } 
} 

回答

1

您可以通過添加到這個烏爾didMoveToView方法做到這一點:

runAction(SKAction.repeatActionForever(SKAction.sequence([SKAction.runBlock(addEnemy), SKAction.waitForDuration(1.0)]))) 

你可以每1秒addEnemy()功能後更改waitForDuration根據自己的需要,併爲這段代碼呼叫。

希望這會有所幫助。

+0

非常感謝你 –

+1

高興地幫助你.. :) –