Search code examples
objective-csprite-kitcolorize

SpriteKit colour changes to nodes


Whilst experimenting with sprite kit I have been wondering if there is a way to change the colour of nodes in a repeated pattern (for instance red, to orange, red, orange, so on).

I have found the colorize feature below:

[node runAction:[SKAction colorizeWithColor:[SKColor redColor] colorBlendFactor:0.8 duration:0.8]];

Is there a way to keep changing a color in a repeated pattern? I just wonder if you could use this basic principle and just use it in a while loop?

Thank you for reading,


Solution

  • You'll can use:

    [SKAction sequence:];
    

    Which will take an array of SKAction objects and combine them into a single SKAction to run in order.

    Then use:

    [SKAction repeatActionForever:yourSequence];
    

    to get them to repeat forever.