Can you tell me why this code doesn't work? Isn't it possible to run an Action in a SKAction.runBlock()-function?
let testaction = SKAction.repeatActionForever(SKAction.runBlock({self.myFunction()}))
runAction(testaction)
Here is my testaction:
func myFunction() {
runAction(SKAction.runBlock({
let i = 0
print(i)
}))
}
I need this for a game. I want to distinguish some cases in myFunction to run different Actions in different cases. What have i done wrong?
Edit: When i change myFunction() to this, i get printed the 1 forever, but not the 0 from the inside runBlock.
func myFunction() {
let j = 1
print(j)
runAction(SKAction.runBlock({
let i = 0
print(i)
}))
}