Menus
Menus provide one way for users to interact with your game using a familiar GUI concept, “buttons.Menu Item to choose from:
- CCMenuItemAtlasFont
- CCMenuItemFont
- CCMenuItemImage
- CCMenuItemLabel
- CCMenuItemSprite
- CCMenuItemToggle
Create Menu Item
CCMenuItemImage *menuItemNormal =
[CCMenuItemImage
itemWithNormalImage:@"normal.png"
[CCMenuItemImage
itemWithNormalImage:@"normal.png"
selectedImage:@"normal_selected.png"
block:^(id sender) {
[[CCDirector sharedDirector] replaceScene:[NormalScene scene]];
}];
CCMenuItemImage *menuItemSlim =
[CCMenuItemImage
itemWithNormalImage:@"slim.png"
selectedImage:@"slim_selected.png"
block:^(id sender) {
[[CCDirector sharedDirector] replaceScene:[SlimScene scene]];
}];
CCMenuItemImage *menuItemSlim =
[CCMenuItemImage
itemWithNormalImage:@"slim.png"
[CCMenuItemImage
itemWithNormalImage:@"slim.png"
selectedImage:@"slim_selected.png"
block:^(id sender) {
[[CCDirector sharedDirector] replaceScene:[SlimScene scene]];
}];
CCMenuItemImage *menuItemFat =
[CCMenuItemImage
itemWithNormalImage:@"fat.png"
selectedImage:@"fat_selected.png"
block:^(id sender) {
[[CCDirector sharedDirector] replaceScene:[FatScene scene]];
}];
Create Menu and add Menu Items
CCMenu *myMenu = [CCMenu menuWithItems:menuItemNormal,
menuItemSlim,
menuItemFat,
nil];
Add Menu to Scene
[self addChild:myMenu];
CCMenuItemImage *menuItemFat =
[CCMenuItemImage
itemWithNormalImage:@"fat.png"
[CCMenuItemImage
itemWithNormalImage:@"fat.png"
selectedImage:@"fat_selected.png"
block:^(id sender) {
[[CCDirector sharedDirector] replaceScene:[FatScene scene]];
}];
Create Menu and add Menu Items
CCMenu *myMenu = [CCMenu menuWithItems:menuItemNormal,
menuItemSlim,
menuItemFat,
nil];
menuItemSlim,
menuItemFat,
nil];
Add Menu to Scene
[self addChild:myMenu];
沒有留言:
張貼留言