十四 手游开发神器 cocos2d-x editor 之串联游戏流程 推荐 原创 makeapp628 2014-02-20 16:34:36 ©著作权 文章标签 editor cocos2d-x 串联游戏 文章分类 游戏开发 ©著作权归作者所有:来自51CTO博客作者makeapp628的原创作品,请联系作者获取转载授权,否则将追究法律责任 一般游戏都包括几个流程,加载界面,开始界面,选关界面,主界面,暂停界面等等;这节我将这些流程都串联起来;代码下载:http://www.kuaipan.cn/file/id_25348935635745200.htm?source=1loading界面;LoadingLayer.ccbx[html]view plaincopy<?xmlversion="1.0"encoding="UTF-8"?><DocumentjsControlled="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><LayerpositionX="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[html]view plaincopy<?xmlversion="1.0"encoding="UTF-8"?><DocumentjsControlled="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><LayerpositionX="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[Javascript]view plaincopy//// 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 赞 收藏 评论 分享 举报 上一篇:android fragment切换无法保存状态的一种解决方法 下一篇:十四-2 手游开发神器 cocos2d-x editor 之串联游戏流程 提问和评论都可以,用心的回复会被更多人看到 评论 发布评论 全部评论 () 最热 最新 相关文章 cocos2d-x 中CCSpriteFrameCache用法与Cocos Creator中有关方案 本文给出cocos2d-x中CCSpriteFrameCache类的使用思路,并对比了Cocos Creator 3.8环境下的实现方案,但有关更高级的缓存方案并没有讨论,请注意。 缓存 cocos creator cocos2d-x CCSpriteFrameCache SpriteFrame cocos2d-x中的动作替换成Cocos creator 3.8中的Tween动画 文章简单介绍从Cocos2d-x向Cocos Creator转移过程中,原先的Action动作在Creator中如何实现。 Cocos Creator Cocos2d-x 动作 Tween Cocos2d-x 中精灵间的zIndex索引在cocos Creator 3.8中是如何实现的? 本文旨在探讨cocos creator 3.8环境中实现类似于cocos2d-x中节点zIndex值大小的控制方案,以便实现在各类扑克游戏中上下叠压的效果。 遮罩层 cocos creator cocos2d-x zIndex siblingIndex 十四-2 手游开发神器 cocos2d-x editor 之串联游戏流程 选关界面GameSelectLayer.ccbx[html]view plaincopy<?xmlversion="1.0"encoding="UTF-8"?><DocumentjsCOntrolled="true"jsCOntroller="GameSelectLayer"resolution="default"><Resolutions><Resolu editor cocos2d-x 游戏流程 一 手游开发神器 cocos2d-x editor初识 背景: 笔者学java ,android,Javascript出身,近期开始学习手机游戏开发,由于手游开发是多平台,所以深思熟虑选择cocos2d-x作为开发游戏引擎。 但遇到如下一些问题, 其一,cocos2d-x开发平台很多是 Javascript window平台 cocos2d-x游戏引擎 手机游戏开发工具 cocos2d-x editor 四 手游开发神器 cocos2d-x editor 游戏框架介绍 cocos2d-x editor 新建工程时会自动生成游戏框架,如下图 红色边框共有五个区域 idea 是自动生成的目录,读者不需要操作 Source是主工程目录,所有的设计和编码都在该目录下完成; Resource是项目的资源存放处,包括贴图,字体,粒子,声音等等main.js,是程序的主函数入口,里面代码主要用来根据游戏平台处理不同的事件;也控制游戏场景 Javascript intellij idea cocos2d-x游戏引擎 window平台 cocos2d-x editor 五 手游开发神器 cocos2d-x editor 之贴图(TexturePacker) 游戏图片资源需要打包,本章我将介绍cocos2d-x editor贴图(TexturePacker); 贴图的原则是把小图片集合到一块,如果图片很大(比如背景资源),需要单独放置。 这一节起,我通过一个叫snow的项目来把主要的知识点汇总。 首先,File-New project新建一个项目,设置编程提示;   Javascript 游戏源码 cocos2d-x游戏引擎 cocosd-x游戏源码 cocosd-x editor 十二 手游开发神器 cocos2d-x editor 之游戏暂停悬浮层 进入游戏主场景,游戏需要临时暂停、重新选关、重新玩等等,所以玩家点击暂停按钮,弹出一个选择悬浮层,这一节我们来实现; 效果如下: 点击右上角游戏暂停; 返回回到开始界面; 代码下载:http://www.kuaipan.cn/file/id_25348935635744972.htm?source=1 首先创建一 Javascript intellij idea cocosd-x editor cocos2d-x游戏源码 游戏暂停界面 十 手游开发神器 cocos2d-x editor 之触摸事件 这一节 我将实现让小怪物跟随我的触摸方向移动,同时触摸的地方产生一个四周发散的效果 效果如下: 代码下载:http://www.kuaipan.cn/file/id_25348935635744782.htm?source=1 打开MainLayer.js,把onDidLoadFromCCB函数修改如下,让触摸可用; MainLaye Javascript cocos2d-x游戏引擎 cocos2d-x游戏源码 cocos2d-x editor cocos2d-x触摸事件 六 手游开发神器 cocos2d-x editor 之场景切换 接着上一节,我们已经创建了一个主游戏场景MainLayer,现在我们需要创建一个开始场景StartLayer,包括StartLayer.ccbx和StartLayer.js两个文件,点击StartLayer上的开始按钮,游戏切换到主游戏场景。 先看运行效果; 代码下载地址:http://www.kuaipan.cn/file/id_2534893 Javascript intellij idea cocos2d-x游戏引擎 cocos2d-x游戏源码 cocos2d场景切换 七 手游开发神器 cocos2d-x editor 之图片字体(LabelBMFont) 我们平时玩游戏时候看到很多超炫的字体效果,大部分都是用了自定义图片, cocos2dx里面叫做LabelBMFont; 运行效果如下; 代码下载地址:http://www.kuaipan.cn/file/id_25348935635744540.htm?source=1 首先在Resources目录下新建一个fonts Javascript cocos2d-x游戏引擎 cocosd-x游戏源码 LabelBMFont cocos2dx字体 九 手游开发神器 cocos2d-x editor 之粒子效果(ParticleEditor) 下雪,烟花,火焰用图片绘制不是很容易,而使用粒子效果则会事半功倍;这一节我要实现小怪物头顶有光环粒子,背景有瀑布粒子 先展示效果: 代码下载地址:http://www.kuaipan.cn/file/id_25348935635744695.htm?source=1 在Resources新建一个package目录particles, cocos2d-x游戏引擎 cocos2d-x游戏源码 cocos2d-x editor cocos2dx粒子 ParticleEditor 十三 手游开发神器 cocos2d-x editor 之选关滑动界面(ScrollView) 这一节,我将实现游戏的选关界面,游戏50关,每一屏15关,总共4屏,左滑动可切换到上一屏,右滑动可切换到下一屏; 效果如下; 开始进入选关界面; 滑动到最后一屏; 点击关卡,进入主界面; 代码下载:http://www.kuaipan.cn/file/id_25348935635745079.htm?source=1 Javascript cocosd-x editor cocos2d-x游戏引擎 cocos2d-x游戏源码 选关界面 八 手游开发神器 cocos2d-x editor 之动画和帧动画 一个游戏的成功很大程度上取决于动画的成功,熟悉cocos2dx的读者都知道它具备了很多现成的动画。这一节我将实现小怪物慢慢的摇摇晃晃的向前走;运行效果如下代码下载地址:http://www.kuaipan.cn/file/id_25348935635744616.htm?source=1首先新建一个帧动画文件,Resorces-----New----FramesAnimation,命名确定,创建s Javascript 游戏源码 cocos2d-x游戏源码 cocos2d-x游戏引擎 cocos2d-x动画 三 手游开发神器 cocos2d-x editor 之基础工具 intellij idea intellij idea 13 注册序列号:亲测有效 csdn 00548-51HIX-2TUE7-IGUTN-8B5R2-XI1X5makeapp 00820-K2S8N-OSMAW-WI632-LZ9SU-L4VC4 makeapp1 00222-NCU0B-NSV6Q-EVW4I-BT0LB- eclipse intellij idea intellij idea 13 注册序 intellij idea使用技巧 十一 手游开发神器 cocos2d-x editor 之音乐和音效 这一节,我将给游戏添加背景音乐和音效; 代码下载:http://www.kuaipan.cn/file/id_25348935635744873.htm?source=1 先在Resources目录下新建一个sounds目录,把准备好的音效复制到该目录下; 打开MainLayer.js,修改代码如下: // // Cleane Javascript intellij idea cocosd-x游戏源码 cocos2d-x editor 游戏音效 手游开发神器cocos2d-x editor for lua 之配置lua环境和运行hellolua 手游开发神器cocos2d-x editor for lua 之配置lua环境和运行hellolua 公告:最新的idea13.1竟然无法在插件市场找到lua,可能是lua的作者没有及时更新上,我们只能通过网页下载lua插件了 http://plugins.jetbrains.com/plugin/5055?pr=idea&offset=15&max=15#comments_pan lua cocosd-x editor cocos2d-x教程 cocos2d-x游戏引擎 手游开发神器 cocos2d-x editor 教程聚合和代码下载(持续更新中) 一 cocos2d-x editor工具下载和基础教程: 一 手游开发神器 cocos2d-x editor初识 二 手游开发神器 cocos2d-x editor工具下载和安装配置 三 手游开发神器 cocos2d-x editor 之基础工具 intellij idea 四 手游开发神器 cocos2d-x editor 游戏框架介绍 五 手游开发神器 cocos2d Javascript cocosd-x editor cocos2d-x教程 cocos2d-x游戏引擎 Cocos2d-x 3.X手游开发实例详解 《Cocos2d-x 3.X手游开发实例详解》以Cocos2d-x V3.0 系列版本为框架,通过实例讲解手机游戏的开发知识和方法,着重通过实例提高读者的开发动手能力。涉及的内容包括:环境搭建、交叉编译以及打包部署;Cocos2d-x数据类型和基本概念的使用,如场景、导演、精灵等;使用Cocos2d-x 创建用户界面,如文本、菜单、滚动框等基本控件,以及一些扩展控件的使用;使用Cocos2d-x 创建动作,比如让精灵移动、跳跃、旋转,以及如何创建按顺序或同时进行的动作;使用Cocos2d-x 播放、停止、暂停、继续播放背景音乐和音效;Cocos2d-x 使用的触摸事件机制;在游戏中存储数据的几种方式;使用HTTP、Sockets、WebSockets 进行网络编程;在游戏中使用物理引擎Box2D、使用瓷砖地图、使用CocosBuilder 制作游戏界面等;Cocos2d-x 中的纹理和动画。最后通过两个完整的游戏开发实例讲解使用Cocos2d-x 开发游戏的全过程。《Cocos2d-x 3.X手游开发实例详解》实例丰富,代码完备,知识点清晰简洁。《Cocos2d-x 3.X手游开发实 学习方法 创始人 知识点 热门游戏 手机游戏 一 手游开发工具cocos2d-x editor初识 可学习的demo:7个实战项目flappybird(飞扬小鸟)、popstar(消灭星星)、fruitninja(水果忍者)、2048(数度消除)。moonwarriors(月亮战神)、fruitattack(水果粉碎传奇)、testsJavascript(样例手冊),代码所有开源,可在本博客里面寻... 2d Javascript 开发工具 手游开发 android