Reputation: 309
whats wrong with this?
self.runAction(
SKAction.sequence([
SKAction.runBlock({
print("Step 1")
}),
SKAction.waitForDuration( 2 ),
SKAction.runBlock({
print("step 2")
}),
SKAction.waitForDuration( 2 ),
SKAction.runBlock({
print("step 3")
}),
])
)
Step 1 prints to console, but step 2 and 3 do not - it seems that the first action gets run but all others do not.
thanks.
Does it have anything to do with my classes?
class Arrow: Entity{}
class Entity: SKSpriteNode
I'm calling the block of code from a function in the Arrow class.
Upvotes: 1
Views: 794
Reputation: 13665
From the docs :
An SKAction object is an action that is executed by a node in the scene
Means if the node is not added to the scene, the actions can't be executed.
So what is currently happening, is that your arrow (obviously) somehow is removed from the scene before your action sequence is completed. Also check if you are accidentally removing all actions (using removeAllActions()
method) from an arrow node at some point. That could stop action execution as well.
Upvotes: 3