Game Development Reference
In-Depth Information
[CCMenuItemFont setFontName:@"Helvetica-BoldOblique"];
[CCMenuItemFont setFontSize:26];
// create a few labels with text and selector
CCMenuItemFont* item1 = [CCMenuItemFont itemWithString:@"Go Back!"
target:self
selector:@selector(menuItem1Touched:)];
// create a menu item using existing sprites
CCSprite* normal = [CCSprite spriteWithFile:@"Icon.png"];
normal.color = ccRED;
CCSprite* selected = [CCSprite spriteWithFile:@"Icon.png"];
selected.color = ccGREEN;
CCMenuItemSprite* item2 = [CCMenuItemSprite
itemWithNormalSprite:normal
selectedSprite:selected
target:self
selector:@selector(menuItem2Touched:)];
// create a toggle item using two other menu items (toggle works with images, too)
[CCMenuItemFont setFontName:@"STHeitiJ-Light"];
[CCMenuItemFont setFontSize:18];
CCMenuItemFont* toggleOn = [CCMenuItemFont itemWithString:@"I'm ON!"];
CCMenuItemFont* toggleOff = [CCMenuItemFont itemWithString:@"I'm OFF!"];
CCMenuItemToggle* item3 = [CCMenuItemToggle itemWithTarget:self
selector:@selector(menuItem3Touched:)
items:toggleOn, toggleOff, nil];
// create the menu using the items
CCMenu* menu = [CCMenu menuWithItems:item1, item2, item3, nil];
menu.position = CGPointMake(size.width/2, size.height/2);
[self addChild:menu];
// aligning is important, so the menu items don't occupy the same location
[menu alignItemsVerticallyWithPadding:40];
Search Nedrilad ::




Custom Search