Reputation: 778
I need to know how to make a simple menu with 5 buttons and have them be on the right side of the screen in cocos2d. Do I create the menu in the -(id)init ? Any help is appreciated. Thanks!
Upvotes: 3
Views: 3749
Reputation: 2917
You can use the following code to create Menu
CCMenuItemImage *menuItem1 = [CCMenuItemImage itemFromNormalImage:@"menu.png" selectedImage:@"menu1.png"
target:self selector:@selector(onClick:)];
CCMenu *menu = [CCMenu menuWithItems:menuItem1,nil];
menu.position = ccp(320,480);
[self addChild:menu z:100];
Hope this helps.....
Upvotes: 5
Reputation: 13999
Do I create the menu in the -(id)init ?
Yes, create the menu in the -(id)init of CCScene subclass or CCLayer subclass as the following tutorials. It is prefer to attach the menu into CCLayer because you can adjust the position of the menu at once by setting the position of the layer.
Upvotes: 2