views:

54

answers:

1

I must be missing something!

I want to create a solid rectangular CCSprite with a background color initialized to a particular RGB value. I have looked all over the docs and can't find anything.

Is there a way to initialize the background of CCSprite to a specific color? I don't want to have to include a solid color PNG for each colors that I will need.

Help!

A: 

CCSprite has a color property of type ccColor3B:

- (ccColor3B) color [read, assign]
RGB colors: conforms to CCRGBAProtocol protocol    

Definition at line 145 of file CCSprite.h.

Source: CCSprite reference.

You can easily construct a ccColor3B struct using ccc3():

ccc3(const GLubyte r, const GLubyte g, const GLubyte b)

Reference: ccColor3B reference.

Justin
Justin, thanks that was what I was doing ... the additional trick of course is setting the textureRect properly!!!
poundev23