Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocos2d How to use CCC4?

Any one have any ideas on how to convert ccc3 to ccc4 or even just a macro! I am currently using CCMotion streak and it requires me to use ccc4 but i dont know what combination makes what color! Please any help would be appreciated! Thanks

like image 641
iDeveloper Avatar asked Jan 17 '11 20:01

iDeveloper


1 Answers

from ccTypes.h

typedef struct _ccColor4B
{
 GLubyte r;
 GLubyte g;
 GLubyte b;
 GLubyte a;
} ccColor4B;
//! helper macro that creates an ccColor4B type
static inline ccColor4B
ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o)
{
 ccColor4B c = {r, g, b, o};
 return c;
}

For exampe:

ccColor4b myColor = ccc4(255, 0, 0, 255); creates a solid red color

Again from ccTypes.h

/** Returns a ccColor4F from a ccColor3B. Alpha will be 1.
 @since v0.99.1
 */
static inline ccColor4F ccc4FFromccc3B(ccColor3B c)
{ 
 return (ccColor4F){c.r/255.f, c.g/255.f, c.b/255.f, 1.f};
}

If it's not enough for your write your own converter like the last one

EDIT:

If you have ccColor3B myColor3B and you want to have ccColor4F myColor4F simply use the converter:

myColor4F c = ccc4FFromccc3B(myColor3B);

If you want to have ccColor4B write your own converter:

static inline ccColor4B ccc4BFromccc3B(ccColor3B c)
{ 
 return (ccColor4F){c.r, c.g, c.b, 255};
}

and use it like this:

ccColor4B c = ccc4BFromccc3B(myColor);
like image 159
Andrew Avatar answered Oct 10 '22 12:10

Andrew