Reputation: 89
I created a CCDrawNode object component and want to change the color, y created the object initially with a gray color, but if i want to changue it the color remains the same.
I tried:
CCDrawNode * node;
[node setColor:colorORG]
[node setColorRGBA:ColorORG]
This code causes no effect on the component's color Any advice on this? Thanks in Advance!
Upvotes: 0
Views: 283
Reputation: 9079
Under 3.2.1, CCDrawNode derives from CCNode , thus the .color and .colorRGBA properties are visible (from CCNode). However, the node itself is a container for some draw primitives, and it is to the primitives that you must specify the color.
for example, i just added this to one of my MapLayout classes :
static CCDrawNode *dg;
if (!dg) {
dg = [CCDrawNode node];
[dg setColorRGBA:[CCColor cyanColor]]; // < does nothing !!!
[self addChild:dg];
// the following 2 lines add primitives, the color must be specified on each
[dg drawDot:ccp(0,0) radius:50 color:[CCColor blackColor]]; // color the dot
[dg drawSegmentFrom:ccp(0,0) to:ccp(80,80) radius:10 color:[CCColor blueColor]]; // color the line segment
dg.visible=YES;
dg.opacity=1.f;
}
shown here :
Upvotes: 1