Reputation: 1239
I have a scene with lots of squares (SKSpriteNode
) in it.
I can detect which node has tapped but I want to add an animation (like a change color or fade color or glow) to it, after the node was touched.
What can i do?
Thanks
Upvotes: 0
Views: 305
Reputation: 22343
You have to use the touchesBegan
and touchesEnded
method.
You can use an SKAction
on it. For example to change the color, you can do it like that:
//in your touchesBegan-method
yourNode.runAction(SKAction.colorizeWithColor(UIColor.blueColor(), colorBlendFactor: 1.0, duration: duration)
//in your touchesEnded-method
yourNode.runAction(SKAction.colorizeWithColor(UIColor.greenColor(), colorBlendFactor: 1.0, duration: duration)
This will change the color of the node to blue during the touch and change it to green, when the node isn't being touched anymore.
Upvotes: 2