cocos2d-x 详谈 Label 与 MenuItem

一、有关MenuItem的所有实现方式(cocos2d-x 3.3)
// menuitem 所有  
    auto item = MenuItemFont :: create ( "Click" , CC_CALLBACK_1 ( HelloWorld :: item_call , this ));
    item->
setPosition (visibleSize. width / 2 - 400 ,visibleSize. height / 2 );
    item->setTag(1);
   
   
auto item2 = MenuItemImage :: create ( "CloseNormal.png" , "CloseSelected.png" );
    item2->
setCallback ( CC_CALLBACK_1 ( HelloWorld :: item_call , this ));
    item2->
setPosition (visibleSize. width / 2 - 250 ,visibleSize. height / 2 );
    item2->
setTag ( 2 );
   
   
auto itemlabel = Label :: createWithTTF ( "ItemLabel" , "fonts/Marker Felt.ttf" , 30 );
   
auto item3 = MenuItemLabel :: create (itemlabel, CC_CALLBACK_1 ( HelloWorld :: item_call , this ));
    item3->
setPosition (visibleSize. width / 2 - 50 ,visibleSize. height / 2 );
    item3->
setTag ( 3 );
   
   
auto item_a = MenuItemImage :: create ( "sound_on.png" , "sound_on.png" );
   
auto item_b = MenuItemImage :: create ( "sound_off.png" , "sound_off.png" );
    
auto item4 = MenuItemToggle :: create ();
    item4->
addSubItem (item_a);
    item4->
addSubItem (item_b);
    item4->
setSelectedIndex ( 0 );
    item4->
setCallback ( CC_CALLBACK_1 ( HelloWorld :: item_call , this ));
    item4->
setPosition (visibleSize. width / 2 + 100 ,visibleSize. height / 2 );
    item4->
setTag ( 4 );
   
   
   
auto item5 = MenuItemAtlasFont :: create ( "Cl" , "tuffy_bold_italic-charmap.png" , 48 , 64 , ' ' );
    item5->
setPosition (visibleSize. width / 2 + 250 ,visibleSize. height / 2 );
    item5->
setCallback ( CC_CALLBACK_1 ( HelloWorld :: item_call , this ));
    item5->
setTag ( 5 );
   
   
   
auto item_spr = Sprite :: create ( "CloseNormal.png" );
   
auto item_spr2 = Sprite :: create ( "CloseSelected.png" );
   
auto item6 = MenuItemSprite :: create (item_spr, item_spr2);
    item6->
setPosition (visibleSize. width / 2 + 350 ,visibleSize. height / 2 );
    item6->
setCallback ( CC_CALLBACK_1 ( HelloWorld :: item_call , this ));
    item6->
setTag ( 6 );
   
   
    menu->
addChild (item);
    menu->
addChild (item2);
    menu->
addChild (item3);
    menu->
addChild (item4);
    menu->
addChild (item5);
    menu->addChild(item6);

二、有关Label的所有实现方式(cocos2d-x 3.3)

    auto label1 = Label :: createWithSystemFont ( "System" , "fonts/Marker Felt.ttf" , 40 );
     label1->
setPosition (visibleSize/ 2 );
    
addChild (label1);
    
    
auto label2 = Label :: createWithBMFont ( "sign.fnt" , "123" );
     label2->
setPosition (visibleSize/ 3 );
    
addChild (label2);
    
    
    
auto label3 = Label :: createWithCharMap ( "tuffy_bold_italic-charmap.png" , 48 , 64 , ' ' );
     label3->
setString ( "156" );
     label3->
setPosition (visibleSize/ 4 );
     addChild (label3);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值