您好,登錄后才能下訂單哦!
一般游戲都包括幾個流程,加載界面,開始界面,選關(guān)界面,主界面,暫停界面等等;這節(jié)我將這些流程都串聯(lián)起來;
代碼下載:http://www.kuaipan.cn/file/id_25348935635745200.htm?source=1
loading界面;
LoadingLayer.ccbx
<?xmlversion="1.0"encoding="UTF-8"?>
<Document
jsControlled="true"
jsController=""
resolution="default"
>
<Resolutions>
<ResolutioncenteredOrigin="false"ext="iphone"height="1280"width="720"name="default"scale="1"/>
<ResolutioncenteredOrigin="false"ext="iphone"height="720"width="1280"name="default1"scale="1"/>
</Resolutions>
<Animations>
<AnimationautoPlay="true"
id="0"
name="Default Timeline"
length="10"
chainedId="0"
offset="0.0"
position="0.0"
resolution="30"
scale="128">
<CallbackChannel>
</CallbackChannel>
<SoundChannel>
</SoundChannel>
</Animation>
</Animations>
<Layer
positionX="0"positionY="0"
width="100"height="100"sizeType="Percent"
anchorPointX="0.5"anchorPointY="0.5"ignoreAnchorPoint="true"
scaleX="1"scaleY="1"
touchEnabled="true"positionType="LeftBottom"target="Owner">
<LayerColorpositionType="LeftBottom"width="720"height="1280"positionX="0"positionY="0"anchorPointX="0"
anchorPointY="0"color="#ffff40b8"target="Doc"/>
<SpritepositionType="LeftBottom"width="245.0"height="72.0"positionX="381.0"positionY="661.0"anchorPointX="0.5"
anchorPointY="0.5"src="Resources/snow_packer.plist/sa_loading_0001.png"
target="Owner"/>
</Layer>
</Document>
開始界面;
StartLayer.ccbx
<?xmlversion="1.0"encoding="UTF-8"?>
<Document
jsControlled="true"
jsController="StartLayer"
resolution="default"
>
<Resolutions>
<ResolutioncenteredOrigin="false"ext="iphone"height="1280"width="720"name="default"scale="1"/>
<ResolutioncenteredOrigin="false"ext="iphone"height="720"width="1280"name="default1"scale="1"/>
</Resolutions>
<Animations>
<AnimationautoPlay="true"
id="0"
name="Default Timeline"
length="10"
chainedId="0"
offset="0.0"
position="0.0"
resolution="30"
scale="128">
<CallbackChannel>
</CallbackChannel>
<SoundChannel>
</SoundChannel>
</Animation>
</Animations>
<Layer
positionX="0"positionY="0"
width="100"height="100"sizeType="Percent"
anchorPointX="0.5"anchorPointY="0.5"ignoreAnchorPoint="true"
scaleX="1"scaleY="1"
touchEnabled="true"positionType="LeftBottom"visible="true">
<LayerColorpositionType="LeftBottom"width="720"height="1280"positionX="0"positionY="0"anchorPointX="0"
anchorPointY="0"color="#ff10ff9e"/>
<MenupositionType="LeftBottom"width="40"height="40"positionX="354.0"positionY="712.0"anchorPointX="0.5"
anchorPointY="0.5">
<MenuItempositionType="LeftBottom"width="203"height="129"positionX="0"positionY="0"anchorPointX="0.5"
anchorPointY="0.5"onClick="onPlayClicked"normalImage="Resources/snow_packer.plist/m_play.png"
target="Doc"selectedImage="Resources/snow_packer.plist/m_play.png"/>
</Menu>
</Layer>
</Document>
StartLayer.js
//
// CleanerScoreScene class
//
var StartLayer = function () {
cc.log("StartLayer")
this.LoadingLayer = this.LoadingLayer || {};
this.passTime = 0;
this.goStart = false;
};
StartLayer.prototype.onDidLoadFromCCB = function () {
// this.rootNode.onUpdate = function (dt)
// {
// this.controller.onUpdate();
// };
// this.rootNode.schedule(this.rootNode.onUpdate);
if (sys.platform == 'browser') {
this.onEnter();
}
else {
this.rootNode.onEnter = function () {
this.controller.onEnter();
};
}
this.rootNode.onExit = function () {
this.controller.onExit();
};
this.rootNode.schedule(function (dt) {
this.controller.onUpdate(dt);
});
};
StartLayer.prototype.onEnter = function () {
this.LoadingLayer = cc.BuilderReader.loadAsNodeFrom("", "LoadingLayer", this);
this.LoadingLayer.setPosition(cc.p(0, 0));
this.LoadingLayer.setZOrder(200);
this.rootNode.addChild(this.LoadingLayer);
// cc.Director.getInstance().pause();
/*this.LoadingLayer.scheduleOnce(this.removeLoading, 1);*/
this.goStart = true;
this.startTime = this.passTime;
}
StartLayer.prototype.removeLoading = function () {
// if (this.LoadingLayer) {
cc.log("removeLoading");
// cc.Director.getInstance().resume();
this.LoadingLayer.removeFromParent();
}
StartLayer.prototype.onUpdate = function (dt) {
this.passTime += dt;
if (this.passTime - this.startTime > 3 && this.goStart) {
this.removeLoading();
this.goStart = false;
}
}
StartLayer.prototype.onPlayClicked = function () {
cc.BuilderReader.runScene("", "GameSelectLayer");
}
StartLayer.prototype.onExit = function () {
}
繼續(xù)請點擊:http://makeapp.blog.51cto.com/8596155/1361300
免責(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)容。