Cocos2d iphone 更改CCNodeColor的颜色
我将CCNode设置为:Cocos2d iphone 更改CCNodeColor的颜色,cocos2d-iphone,Cocos2d Iphone,我将CCNode设置为: CCNodeColor *node = [CCNodeColor nodeWithColor:[CCColor colorWithRed:0.1f green:0.1f blue:0.1f alpha:0.0f]]; node.position=ccp(0,0); node.name=@"zoomAlpha"; [self addChild:node]; 这很有效。 而不是更改其颜色/alpha: CCNodeColo
CCNodeColor *node = [CCNodeColor nodeWithColor:[CCColor colorWithRed:0.1f green:0.1f blue:0.1f alpha:0.0f]];
node.position=ccp(0,0);
node.name=@"zoomAlpha";
[self addChild:node];
这很有效。
而不是更改其颜色/alpha:
CCNodeColor *nood=(CCNodeColor*)[self getChildByName:@"zoomAlpha" recursively:NO];
if(nood)
{
//i got here with a nood , but color is not changed
[nood setColor: [CCColor colorWithRed:0.6f green:0.3f blue:0.4f alpha:1.0f ]];
return;
}
为什么会这样?试试这个:
[nood setColor: [CCColor3B colorWithRed:0.6f green:0.3f blue:0.4f alpha:1.0f ]];
或
[nood setColor: [CCColor4B colorWithRed:0.6f green:0.3f blue:0.4f alpha:1.0f ]];