【问题标题】:Creating a menu in Cocos2d-Android在 Cocos2d-Android 中创建菜单
【发布时间】:2012-06-15 22:49:43
【问题描述】:

我是Android开发的初学者,一直在用cocos2d-android开发一个游戏,需要实现一个菜单屏幕。我在谷歌上看过,只能找到关于 cocos2d for iPhone 的信息。有人对我如何添加菜单有任何建议/想法,或者更好地了解任何可以帮助我的教程或书籍吗?

提前致谢!

【问题讨论】:

    标签: cocos2d-android ccmenuitem


    【解决方案1】:

    您好,您可以使用 CCMenu 和 CCMenuItemLabel 在 cocos2d 中创建菜单,我在这里与您分享一个示例,我从中制作了菜单屏幕作为选项,因此在这里向您展示如何使用 CCMenu 和 CCMenuItemLabel 的方法将对您有所帮助尽力而为。

         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;
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-24
      • 1970-01-01
      • 2018-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多