2012-06-15 36 views
2

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

在此先感谢!

回答

3

嗨,你可以使用CCMenu和CCMenuItemLabel在这里使用CCMenu和CCMenuItemLabel创建菜单,我在这里分享你一个例子,我从中选择了菜单屏幕,所以它会对你有帮助,这里给你展示使用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; 
     }