溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

十四 手游開發(fā)神器 cocos2d-x editor 之串聯(lián)游戲流程

發(fā)布時間:2020-06-23 20:47:57 來源:網(wǎng)絡(luò) 閱讀:6286 作者:makeapp628 欄目:游戲開發(fā)

一般游戲都包括幾個流程,加載界面,開始界面,選關(guān)界面,主界面,暫停界面等等;這節(jié)我將這些流程都串聯(lián)起來;


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


loading界面;

十四 手游開發(fā)神器 cocos2d-x editor 之串聯(lián)游戲流程

LoadingLayer.ccbx


[html]view plaincopy十四 手游開發(fā)神器 cocos2d-x editor 之串聯(lián)游戲流程十四 手游開發(fā)神器 cocos2d-x editor 之串聯(lián)游戲流程
  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>



開始界面;

十四 手游開發(fā)神器 cocos2d-x editor 之串聯(lián)游戲流程

StartLayer.ccbx


[html]view plaincopy十四 手游開發(fā)神器 cocos2d-x editor 之串聯(lián)游戲流程十四 手游開發(fā)神器 cocos2d-x editor 之串聯(lián)游戲流程
  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十四 手游開發(fā)神器 cocos2d-x editor 之串聯(lián)游戲流程十四 手游開發(fā)神器 cocos2d-x editor 之串聯(lián)游戲流程
  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. }  

繼續(xù)請點擊:http://makeapp.blog.51cto.com/8596155/1361300

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI