App Development » How to use CCLabelBMFont as a CCMenuItem in a CCMenu

How to use CCLabelBMFont as a CCMenuItem in a CCMenu

I’m finally getting around to setting up some stats/menus/labels in my app and hit a little bit of a hurdle that I wanted to document in case it helps anyone else out. How to use CCLabelBMFont as a CCMenuItem in a CCMenu.

First you’ll need your .fnt added to your Resources (I used hiero – the java based font creator to turn a .ttf into .fnt and .png). Then just use the code below to add your label label and point your menu item’s label to it. Works like a charm!

CCLabelBMFont *menuItemLabel = [CCLabelBMFont labelWithString:@"Play" fntFile:@"font.fnt"];
 CCMenuItemLabel *menuItem = [CCMenuItemLabel itemWithLabel:menuItemLabel target:self selector:@selector(playMethod:)];
CCMenu *menu = [CCMenu menuWithItems:menuItem, nil];
 [self addChild:menu];

Comments