温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

十四 手游开发神器 cocos2d-x editor 之串联游戏流程

发布时间:2020-06-23 20:47:57 来源:网络 阅读:6290 作者:makeapp628 栏目:游戏开发

一般游戏都包括几个流程,加载界面,开始界面,选关界面,主界面,暂停界面等等;这节我将这些流程都串联起来;


代码下载:http://www.kuaipan.cn/file/id_25348935635745200.htm?source=1


loading界面;

十四 手游开发神器 cocos2d-x editor 之串联游戏流程

LoadingLayer.ccbx


[html]view plaincopy十四 手游开发神器 cocos2d-x editor 之串联游戏流程十四 手游开发神器 cocos2d-x editor 之串联游戏流程
  1. <?xmlversion="1.0"encoding="UTF-8"?>

  2. <Document

  3. jsControlled="true"

  4. jsController=""

  5. resolution="default"

  6. >

  7. <Resolutions>

  8. <ResolutioncenteredOrigin="false"ext="iphone"height="1280"width="720"name="default"scale="1"/>

  9. <ResolutioncenteredOrigin="false"ext="iphone"height="720"width="1280"name="default1"scale="1"/>

  10. </Resolutions>

  11. <Animations>

  12. <AnimationautoPlay="true"

  13. id="0"

  14. name="Default Timeline"

  15. length="10"

  16. chainedId="0"

  17. offset="0.0"

  18. position="0.0"

  19. resolution="30"

  20. scale="128">

  21. <CallbackChannel>

  22. </CallbackChannel>

  23. <SoundChannel>

  24. </SoundChannel>

  25. </Animation>

  26. </Animations>

  27. <Layer

  28. positionX="0"positionY="0"

  29. width="100"height="100"sizeType="Percent"

  30. anchorPointX="0.5"anchorPointY="0.5"ignoreAnchorPoint="true"

  31. scaleX="1"scaleY="1"

  32. touchEnabled="true"positionType="LeftBottom"target="Owner">

  33. <LayerColorpositionType="LeftBottom"width="720"height="1280"positionX="0"positionY="0"anchorPointX="0"

  34. anchorPointY="0"color="#ffff40b8"target="Doc"/>

  35. <SpritepositionType="LeftBottom"width="245.0"height="72.0"positionX="381.0"positionY="661.0"anchorPointX="0.5"

  36. anchorPointY="0.5"src="Resources/snow_packer.plist/sa_loading_0001.png"

  37. target="Owner"/>

  38. </Layer>

  39. </Document>



开始界面;

十四 手游开发神器 cocos2d-x editor 之串联游戏流程

StartLayer.ccbx


[html]view plaincopy十四 手游开发神器 cocos2d-x editor 之串联游戏流程十四 手游开发神器 cocos2d-x editor 之串联游戏流程
  1. <?xmlversion="1.0"encoding="UTF-8"?>

  2. <Document

  3. jsControlled="true"

  4. jsController="StartLayer"

  5. resolution="default"

  6. >

  7. <Resolutions>

  8. <ResolutioncenteredOrigin="false"ext="iphone"height="1280"width="720"name="default"scale="1"/>

  9. <ResolutioncenteredOrigin="false"ext="iphone"height="720"width="1280"name="default1"scale="1"/>

  10. </Resolutions>

  11. <Animations>

  12. <AnimationautoPlay="true"

  13. id="0"

  14. name="Default Timeline"

  15. length="10"

  16. chainedId="0"

  17. offset="0.0"

  18. position="0.0"

  19. resolution="30"

  20. scale="128">

  21. <CallbackChannel>

  22. </CallbackChannel>

  23. <SoundChannel>

  24. </SoundChannel>

  25. </Animation>

  26. </Animations>

  27. <Layer

  28. positionX="0"positionY="0"

  29. width="100"height="100"sizeType="Percent"

  30. anchorPointX="0.5"anchorPointY="0.5"ignoreAnchorPoint="true"

  31. scaleX="1"scaleY="1"

  32. touchEnabled="true"positionType="LeftBottom"visible="true">

  33. <LayerColorpositionType="LeftBottom"width="720"height="1280"positionX="0"positionY="0"anchorPointX="0"

  34. anchorPointY="0"color="#ff10ff9e"/>

  35. <MenupositionType="LeftBottom"width="40"height="40"positionX="354.0"positionY="712.0"anchorPointX="0.5"

  36. anchorPointY="0.5">

  37. <MenuItempositionType="LeftBottom"width="203"height="129"positionX="0"positionY="0"anchorPointX="0.5"

  38. anchorPointY="0.5"onClick="onPlayClicked"normalImage="Resources/snow_packer.plist/m_play.png"

  39. target="Doc"selectedImage="Resources/snow_packer.plist/m_play.png"/>

  40. </Menu>

  41. </Layer>

  42. </Document>


StartLayer.js



[javascript]view plaincopy十四 手游开发神器 cocos2d-x editor 之串联游戏流程十四 手游开发神器 cocos2d-x editor 之串联游戏流程
  1. //

  2. // CleanerScoreScene class

  3. //

  4. var StartLayer = function () {  

  5.    cc.log("StartLayer")  

  6. this.LoadingLayer = this.LoadingLayer || {};  

  7. this.passTime = 0;  

  8. this.goStart = false;  

  9. };  

  10. StartLayer.prototype.onDidLoadFromCCB = function () {  

  11. //    this.rootNode.onUpdate = function (dt)

  12. //    {

  13. //        this.controller.onUpdate();

  14. //    };

  15. //    this.rootNode.schedule(this.rootNode.onUpdate);

  16. if (sys.platform == 'browser') {  

  17. this.onEnter();  

  18.    }  

  19. else {  

  20. this.rootNode.onEnter = function () {  

  21. this.controller.onEnter();  

  22.        };  

  23.    }  

  24. this.rootNode.onExit = function () {  

  25. this.controller.onExit();  

  26.    };  

  27. this.rootNode.schedule(function (dt) {  

  28. this.controller.onUpdate(dt);  

  29.    });  

  30. };  

  31. StartLayer.prototype.onEnter = function () {  

  32. this.LoadingLayer = cc.BuilderReader.loadAsNodeFrom("", "LoadingLayer", this);  

  33. this.LoadingLayer.setPosition(cc.p(0, 0));  

  34. this.LoadingLayer.setZOrder(200);  

  35. this.rootNode.addChild(this.LoadingLayer);  

  36. //  cc.Director.getInstance().pause();

  37. /*this.LoadingLayer.scheduleOnce(this.removeLoading, 1);*/

  38. this.goStart = true;  

  39. this.startTime = this.passTime;  

  40. }  

  41. StartLayer.prototype.removeLoading = function () {  

  42. // if (this.LoadingLayer) {

  43.    cc.log("removeLoading");  

  44. // cc.Director.getInstance().resume();

  45. this.LoadingLayer.removeFromParent();  

  46. }  

  47. StartLayer.prototype.onUpdate = function (dt) {  

  48. this.passTime += dt;  

  49. if (this.passTime - this.startTime > 3 && this.goStart) {  

  50. this.removeLoading();  

  51. this.goStart = false;  

  52.    }  

  53. }  

  54. StartLayer.prototype.onPlayClicked = function () {  

  55.    cc.BuilderReader.runScene("", "GameSelectLayer");  

  56. }  

  57. StartLayer.prototype.onExit = function () {  

  58. }  

继续请点击:http://makeapp.blog.51cto.com/8596155/1361300

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI