I am probably staring the answer in the face, however.
I want to assign a random colour to a CCLabelTTF
string. When I try to set the return type of (CCColor3B *)
and assign it CCLabelTTF.color = [self randomColor]
I get incompatible assignment errors, both in the method, and at the above assignment. Method code:
-(ccColor3B *)randomColor
{
float r = arc4random() % 255;
float g = arc4random() % 255;
float b = arc4random() % 255;
ccColor3B *color = {r,g,b,1};
return color;
}
I think I am trying to obtain a return value which is the wrong type, or assign a read-only value, but information on CCColor3B
is scarce. Thanks in advance.
From Cocos2d class documentation, the property
color
of CCSprite is not a pointer (it is a struct)You need to change your method as follows
You can find the definition of ccColor3B in the docs for CCTypes.h (line 43)