扫雷08 选关界面
选关界面使用cocos studio来制作
新建一个文件
SelectGame.h头文件
1: #ifndef __SELECT_GAME_H__
2: #define __SELECT_GAME_H__
3: #include "customer_define.h"
4:
5:
6: class SelectGame :public Layercolor
7: {
8: public:
9: CREATE_FUNC(SelectGame);
10: SCENE_FUNC(SelectGame);
11: bool init();
12: //回调函数
13: protected:
14: voID MenuEasyCallBack(Ref*);
15: voID MenuMIDCallBack(Ref*);
16: voID MenuHardCallBack(Ref*);
17: voID MenuExitCallBack(Ref*);
18: };
19:
20: #endif // !__SELECT_GAME_H__SelectGame.Cpp文件 1: #include "SelectGame.h"
2: #include "GameScene.h"
3: #include "cocostudio/CocoStudio.h"
4: #include "ui/CocosGUI.h"
6: using namespace cocostudio::timeline;
7:
8: bool SelectGame::init()
9: {
10: if (!Layercolor::initWithcolor(color4B(64,76,128,255))) {
11: return false;
12: }
13:
14: //从csb文件中获取图层
15: auto rootNode = csloader::createNode("select.csb");
16: addChild(rootNode);
17: //获取按钮,关联回调函数
18: auto easyItem = static_cast<ui::button*>(rootNode->getChildByname("Beasy"));
19: easyItem->addtouchEventListener(CC_CALLBACK_1(SelectGame::MenuEasyCallBack,this));
20:
21: auto mIDItem = static_cast<ui::button*>(rootNode->getChildByname("BmID"));
22: mIDItem->addtouchEventListener(CC_CALLBACK_1(SelectGame::MenuMIDCallBack,monospace; wIDth: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 16pt; padding-right: 0px; background-color: white"> 23:
24: auto hardItem = static_cast<ui::button*>(rootNode->getChildByname("Bhard"));
25: hardItem->addtouchEventListener(CC_CALLBACK_1(SelectGame::MenuHardCallBack,monospace; wIDth: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 16pt; padding-right: 0px; background-color: #f4f4f4"> 26:
27: auto exitItem = static_cast<ui::button*>(rootNode->getChildByname("Bexit"));
28: exitItem->addtouchEventListener(CC_CALLBACK_1(SelectGame::MenuExitCallBack,monospace; wIDth: 100%; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; border-left-style: none; line-height: 16pt; padding-right: 0px; background-color: white"> 29: return true;
30: }
31:
32: voID SelectGame::MenuEasyCallBack(Ref *)
33: {
34: Scene * scene = GameScene::scene(1);
35: Director::getInstance()->replaceScene(scene);
36:
37: }
38:
39: voID SelectGame::MenuMIDCallBack(Ref *)
40: {
41: Scene * scene = GameScene::scene(2);
42: Director::getInstance()->replaceScene(scene);
43: }
44:
45: voID SelectGame::MenuHardCallBack(Ref *)
46: {
47: Scene * scene = GameScene::scene(3);
48: Director::getInstance()->replaceScene(scene);
@H_38_502@ 49: }
50:
51: voID SelectGame::MenuExitCallBack(Ref *)
52: {
53: Director::getInstance()->end();
54: }
55:
效果如图 本次效果不是很好,按钮点击切换的图片看不出来。背景由于透明的的影响,也是不怎么好看的。
总结以上是内存溢出为你收集整理的cocos3.x 扫雷08 选关界面全部内容,希望文章能够帮你解决cocos3.x 扫雷08 选关界面所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)