標籤: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 之消滅星星(三) 進入遊戲過渡情境