Cocos study notes-Menu

cocos study notes-Menu

reference: jellythink
In cocos-2d-x, its menu UI system can be divided to three catageries:

  • MenuItemLabel
  • MenuItemSprite
  • MenuItemToggle

Now, let’t talk about them in detail.

1.MenuItemLabel

It is a MenuItem which was defined by typeface, or we can say this is a MenuItem which can be used to write words on it. MenuItemLabel includes MenuItemAtlasFont and MenuItemFont.
MenuItemFont is a class which can set the size and name of typeface. This is its member functions:

static MenuItemFont *create(const std::string& value="start");
static MenuItemFont *create(const std::string& value,const MenuCallback& callback);
//the size of typeface
static void setFontSize(int size);
static int getFontSize();
//the name of typeface
static void setFontName(const std::string& name);
static const std::string& getFontName();

MenuItemAlasFont is created by typeface file,something alike plist file.

2.MenuItemSprite

MenuItemSprite is a class which can load picture.First, let’s see its member functions:

static MenuItemSprite *create(Node* normalSprite,Node* selectedSprite,Node* disabledSprite=nullptr);  
static MenuSprite *create(Node* normalSprite,Node* selectSprite,Node* disabledSprite,const MenuCallback* callback); //sometimes we can omit the disabledSprite
inline Node* getNormalImage()cosnt {return _normalImage;};
void setNormalImage(Node* image);
//the other two can be inferred by the functions above.

3.MenuItemToggle

You can pass any MenuItem to the MenuItemToggle,which can be treated as a button.And its member function:

//create with a vector containing MenuItem
static MenuItemToggle *createWithCallback(const MenuCallback& callback,const Vector<MenuItem*>&menuItem);
//create with plenty of MenuItem
static MenuItemToggle* createWithCallback(const MenuCallback& callback,MenuItem* item,...,NULL);
//create an empty MenuItemToggle
static MenuItemToggle* create();
//add MenuItem to it
void addSubItem(MenuItem *item);
MenuItem* getSelectedItem();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值