Reputation: 366
I have been trying to implement the following functionality in my game. I run an action on the sprite node (sprite node parent is nil) and the action should wait for my specified time and then add the node to self. I could not find any action which adds the node to parent. I thought doing something like that:
node.runAction(SKAction.sequence([SKAction.waitForDuration(timetowait), SKAction.runBlock(addToSelf(node))]))
and just having a method as this:
func addToSelf(node: SKSpriteNode){
self.addChild(node)
}
If I succeed doing this, my game performance would improve a lot. Anyone knows is there a work around?
Upvotes: 4
Views: 572
Reputation: 652
You are on the right track. You should be able to use
SKAction.runBlock({ self.someFunction(param) })
See the documentation for more details.
Upvotes: 4