• Cocos2d-x之CCMenu


    from://http://blog.linguofeng.com/archive/2012/11/14/cocos2d-x-CCMenu.html

     

    Cocos2d-x之CCMenu

    Cocos2dx的菜单


    CCSprite* normal =CCSprite::spriteWithFile("默认状态的图片");CCSprite* selected =CCSprite::spriteWithFile("选中状态的图片");CCSprite* disabled =CCSprite::spriteWithFile("禁用状态的图片");CCMenuItemSprite* item =CCMenuItemSprite::itemFromNormalSprite(normal, selected, disabled,this, menu_selector(Test::callback));// itemFromNormalSprite(normal, selected, disabled);// itemFromNormalSprite(normal, selected, this, menu_selector(Test::callback));// itemFromNormalSprite(normal, selected);
    item->setIsEnabled(false);// 是否可用,默认true
    CCMenuItemImage* item =CCMenuItemImage::itemFromNormalImage("默认状态","选中状态",this, menu_selector(Test::callback));// itemFromNormalImage("默认状态", "选中状态");// itemFromNormalImage("默认", "选中", "禁用", this, menu_selector(Test::callback));// itemFromNormalImage("默认", "选中", "禁用");
    // 支持CCLabelAtlas、CCLabelBMFontCCLabelAtlas* label =CCLabelAtlas::labelWithString("123","nums.png",24,30,'');CCMenuItemLabel* item =CCMenuItemLabel::itemWithLabel(label,this, menu_selector(Test::callback));// itemWithLabel(label);
    item->setDisabledColor(ccc3(255,255,255));
    item->setColor(ccc3(0,0,0));
    CCMenuItemFont* item =CCMenuItemFont::itemFromString("文本",this, menu_selector(Test::callback));// itemFromString("文本");
    item->setFontSizeObj(24);
    item->setFontName("Monaco");// 全局字体与大小CCMenuItemFont::setFontSize("全局字体大小");CCMenuItemFont::setFontName("全局字体名称");
    CCMenuItemToggle* item =CCMenuItemToggle::itemWithTarget(this,
            menu_selector(Test::callback),CCMenuItemFont::itemFromString("On"),CCMenuItemFont::itemFromString("Off"),
            NULL);
    item->getSubItems()->addObject(CCMenuItemFont::itemFromString("Other"));
    item->setSelectedIndex(2);
    CCMenu* menu =CCMenu::menuWithItems(item1, item2, NULL);
    menu->alignItemsHorizontally();// 垂直对齐
    menu->alignItemsVertically();// 水平对象
    menu->alignItemsInColumns(2,1, NULL);// 两行,两列,一列
    Test::callback(CCObject* sender){}
  • 相关阅读:
    jQuery.qrcode二维码插件生成网页二维码
    JavaScript 常用方法
    jQuery——样式与动画
    jQuery——事件
    js基础(使用Canvas画图)
    ES6
    正则表达式总结及常规的正则表达式校验
    jQuery基础介绍
    weblogic 数据源高可用配置
    win10 查看端口是否被占用以及杀进程
  • 原文地址:https://www.cnblogs.com/wanqieddy/p/3318581.html
Copyright © 2020-2023  润新知