您好,登錄后才能下訂單哦!
一般游戲都包括幾個流程,加載界面,開始界面,選關界面,主界面,暫停界面等等;這節我將這些流程都串聯起來;
代碼下載: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 () {
}
繼續請點擊:http://makeapp.blog.51cto.com/8596155/1361300
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。