Search code examples
objective-cios5cocos2d-iphone

CCMenuItemFont color change


How can I set the color of a CCMenuItemFont. I've been searching for hours, returning 0 valid results. They're all outdated.

[CCMenuItemFont setFontName:@"Futura"]; 
    [CCMenuItemFont setFontSize:40];
    CCMenuItem *Play = [CCMenuItemFont itemFromString:@"Play" target:self selector:@selector(goToLevelSelect:)]; 

    CCMenu *menuPlay = [CCMenu menuWithItems: Play, nil]; 
    menuPlay.position = ccp(50,100);
    [menuPlay alignItemsVerticallyWithPadding:10];
    [self addChild:menuPlay]; 

Solution

  • CCMenuItemFont is derived from CCMenuItemLabel which has a label property:

    CCMenuItemLabel *play = [CCMenuItemFont itemFromString:@"Play" 
                             target:self selector:@selector(goToLevelSelect:)];
    play.color = ccRED;