一般游戏都包括几个流程,加载界面,开始界面,选关界面,主界面,暂停界面等等;这节我将这些流程都串联起来;
代码下载: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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。