Search code examples
ioscocos2d-iphonespritebuilder

Set color overlay on CCSprite - Spritebuilder/Cocos2d


I am trying to set a colour overlay on a few CCSprites by code as is done using Spritebuilder - It puts a colour overlay over the image. However all I can find to do so is

sprite.color = CCRed;

When I do so I get the following error:

Assigning to 'CCColor' *from incompatible type 'const ccColor3B' aka ('const struct _ccColor3b')

How can I set the color overlay on the CCSprite?


Solution

  • you are trying to assign a constant struct to an object. Instead try :

        sprite.color = [CCColor colorWithCcColor3b:ccRED];
    

    or

        sprite.color = [CCColor redColor];
    

    that will get rid of the specific error. However, i'm not certain it will 'duplicate' the rendering achieved in SpriteBuillder. There are many way to tint a node.