一、有关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-> 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 );
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);