今天做個貪吃蛇的遊戲,裡面需要用到單選按鈕選擇速度,但從網上找了找,沒有找到cocos2d-x的實現方法,但是有cocos2d-iphone的實現方法,由於本人之前學過ios的基本開發,有oc語言有些了解,而且也學過c++,所以就將cocos2d-iphone的實現方法重寫了一遍,在此分享給大家:
coco2d-iphone實現包
,cocos2d-x實現包
.使用方法:
ccmenuitemimage *bu01 = ccmenuitemimage::create("veryfast.png", "veryfastsel.png", this, menu_selector(gamesetting::button1callback));ccmenuitemimage *bu02 = ccmenuitemimage::create("faster.png", "fastersel.png", this, menu_selector(gamesetting::button2callback));
ccmenuitemimage *bu03 = ccmenuitemimage::create("middle.png", "middlesel.png", this, menu_selector(gamesetting::button3callback));
ccmenuitemimage *bu04 = ccmenuitemimage::create("slow.png", "slowsel.png", this, menu_selector(gamesetting::button4callback));
ccradiomenu *radiomenu = ccradiomenu::create(bu01,bu02,bu03,bu04,null);
radiomenu->setposition(ccp(480.0, 500.5)); 590.0
radiomenu->alignitemshorizontally();
radiomenu->setselecteditem_(bu01);
bu01->selected();
this->addchild(radiomenu, 1);
cocos2dx之建立乙個選單按鈕
cclabelttf label cclabelttf create exit arial 20 create a exit botton ccmenuitemlabel exit game ccmenuitemlabel create label,this,menu selector hellow...
cocos2dx之建立乙個選單按鈕
1,在沒有資源的情況下,如果想要建立乙個只有字型的menu按鈕,看如下 的建立步驟 cclabelttf label cclabelttf create exit arial 20 create a exit botton ccmenuitemlabel exit game ccmenuitemla...
cocos2dx 單點觸控,按鈕事件
1,單點觸控 h include using namespace std 觸控事件開始,手指按下時 void ontouchesbegan const std vector touches,cocos2d event event 觸控移動事件,也就是手指在螢幕滑動的過程 void ontouches...