[MenuItemFont setFontSize:20];
[MenuItemFont setFontName:@"Helvetica"];
//I'm trying to change the color of start (below item)
MenuItem *start = [MenuItemFont itemFromString:@"Start Game"
target:self
selector:@selector(startGame:)];
MenuItem *help = [MenuItemFont itemFromString:@"Help"
target:self
selector:@selector(help:)];
Menu *startMenu = [Menu menuWithItems:start, help, nil];
[startMenu alignItemsVertically];
[self add:startMenu];
MenuItemFont *start = [MenuItemFont itemFromString:@"Start Game"
target:self
selector:@selector(startGame:)];
[start.label setRGB:0 :0 :0]; // Black menu item
Label is a property of MenuItemFont, a subclass of MenuItem, so you lose it during the implicit cast to MenuItem.
Alternatively, you could do:
[((MenuItemFont *)start).label setRGB:0 :0 :0]
(but that's ugly, and startMenu will take a MenuItemFont with no complaints).
Keep in mind that the colors are for the most part hardcoded in MenuItemFont, so calling 'setIsEnabled' will set the colors back to grey or white. This happens around line 239 of MenuItem.m if you need to tweak it. If I get around to making a patch to expose this functionality on MenuItemFont (assuming it's not already in the pre-.7.1 sources) I'll update my post.
setRGB has been set to setColor in newer versions. For example:
[start.label setColor: ccc3(200,0,200)];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With