user1251388
user1251388

Reputation: 11

Creating a menu in Cocos2d-Android

I am a beginner in Android Development and have been working on a game in cocos2d-android and need to implement a menu screen. I have looked on google and can only find information in regard to cocos2d for iPhone. Would anyone have any advice/ideas as to how I could add a menu, or even better know of any tutorials or books that could help me with this?

Thanks in advance!

Upvotes: 1

Views: 1064

Answers (1)

user1414160
user1414160

Reputation:

Hi you can create menu in cocos2d with use of CCMenu and CCMenuItemLabel here i am sharing you an example from which i made menu screen for option so it will helpful to you here the method which shows you to use of CCMenu and CCMenuItemLabel so try it all the best.

     private CCNode addOtherOptions(String strName, int xpos, int ypos, String action) {
            CCNode ccStartNode = CCNode.node();
            ccStartNode.setPosition(CGPoint.ccp(xpos, ypos));
            ccStartNode.setAnchorPoint(CGPoint.ccp(0, 0));

            CCMenuItemLabel startGame = CCMenuItemLabel.item(strName, this, action);
            startGame.setPosition(CGPoint.ccp(0, 0));
            startGame.setAnchorPoint(CGPoint.ccp(0, 0));
            startGame.setColor(ccColor3B.ccc3(139, 69, 19));
            startGame.setScale(0.5f);

            CCMenu menu2 = CCMenu.menu(startGame);
            menu2.alignItemsVertically(-10f);
            menu2.setPosition(CGPoint.ccp(-20, 0));
            menu2.setAnchorPoint(CGPoint.ccp(0, 0));
            // addChild(menu2);

            ccStartNode.addChild(menu2);

            return ccStartNode;
        }

Upvotes: 3

Related Questions