Cocos2d JS 之消滅星星(三) 進入遊戲過渡情境

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   os   ar   sp   div   

 1 /* 2  * 遊戲過渡情境,主要作用是在每次進入遊戲或者進入下一關卡時進行過渡,顯示當前的關卡以及通過該關卡要達到的分數; 3  */ 4 var TransitionScene = ccui.Layout.extend( 5 { 6     size:null, 7     ctor:function() 8     { 9         this._super();10         this.zinit();11         this.setLabel();12         this.gotoGameMainScene();13     },14     //設定顯示文本(當前關卡數,通過關卡分數)15     setLabel:function()16     {17         //當前進入關卡18         var currentLevel = new myText("level 1",white, 20);19         currentLevel.x = this.size.width - currentLevel.width >> 1;//置中20         currentLevel.y = 500;21         this.addChild(currentLevel, 1);22         23         var targetTxt = new myText("target score is", white, 20);24         targetTxt.x = this.size.width - targetTxt.width >> 1;25         targetTxt.y = currentLevel.y - targetTxt.height - 10;26         this.addChild(targetTxt, 1);27         //通關分數28         var targetScore = new myText("1000", white, 20);29         targetScore.x = this.size.width - targetScore.width >> 1;30         targetScore.y = targetTxt.y - targetScore.height - 10;31         this.addChild(targetScore, 1);32     },33     //進入遊戲主情境34     gotoGameMainScene:function()35     {36         //兩秒後進入遊戲主介面37         this.scheduleOnce(function()38         {39             var gMainScene = GameMainScene.createScene();40             cc.director.runScene(cc.TransitionFade.create(1, gMainScene));41         }, 2);42     },43     //初始化44     zinit:function()45     {46         //設定布局大小47         this.size = cc.size(480, 800);48         this.setSize(this.size);49         //執行個體化背景圖片50         var backGround = new myImage(res.mainbacktop);51         backGround.y = this.size.height - backGround.height;52         this.addChild(backGround, 0);53         var backGround1 = new myImage(res.mainbackbottom);54         this.addChild(backGround1, 0);55     }56 });57 //執行個體化情境58 TransitionScene.createScene = function()59 {60     var tScene = cc.Scene.create();61     var tLayout = new TransitionScene();62     tScene.addChild(tLayout);63     return tScene;64 };
/******************************effect image****************************/

 

 

Cocos2d JS 之消滅星星(三) 進入遊戲過渡情境

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.