I have a run action loop that spawns an enemy then waits and spawns another. The intention is that the higher the score the quicker the enemies spawn.
But the current code has the enemies spawn at the same rate no matter what. I update the rate in the override func update(currentTime: NSTimeInterval) method all the time, so I don't know what's wrong.
override func update(currentTime: NSTimeInterval){
spawnRate = 2.0-(0.1*(Double)(((Double)(Score))/(10.0)))
if(spawnRate < 0.5){
spawnRate = 0.5
}
}
override func didMoveToView(view: SKView) {
runAction(SKAction.repeatActionForever(
SKAction.sequence([
SKAction.runBlock(addEnemy),
SKAction.waitForDuration(spawnRate)
])
))
}