[cocos2dx笔记011]使用Cocostudio UI编辑器

19 篇文章 0 订阅
13 篇文章 1 订阅
笔记汇总: http://www.cppblog.com/zdhsoft/archive/2014/07/15/207659.html
cocos2dx不仅是有框架,还提供了一个编辑器,可以对动画、UI、骨骼动画和场景编辑的功能。
使用这些工具,大大缩短了用cocos2dx开发周期。但总的来说,操作并不是很方便,但是有总比没有强!
下载地址:http://cn.cocos2d-x.org/download/ 现在MAC的版本也出来了。
下图是界面


然后启动,新建一个项目


这样就完成项目的创建。
在编辑之前,需要先给项目提供资源,一种是把资源拖到右边的资源列表或都在资源列表打开选择资源对话框。


插入结果
其它资源依此类推。
项目创建会默认创建一个画布和一个容器panel

在正式编辑UI之前,需要先设置画面大小,这个跟据你项目的要求设置。

下面在画面中,填加一个图片。很不幸,你不能从资源列表直接拖到中间的画布上只,只能在画布或对象列表使用右键,弹出右键菜单,添加图片对象。


然后,用鼠标选这个对象。在画面的右边,会有一个对象的属性面板。

属性面版有尺寸和模式、常规、控件布局、特性。大家可以尝试设置,就知道他的作用了。添加完成后,把具体的图片资源拖到属性面版->特性->文件框内,就可以了。

结果

这样就OK了
在属性面板有一个Tag属性和名子属性要注意一下,我面在加载UI后,可以通过这两个属性取得UI中的这个对象。
可能调整渲染层级达到调整显示次序的效果。
按照上面的步骤,就可以很快的做出UI了。
做完后,就需要导出UI了,cocos2dx是不能直接使用UI工程的,需要使用导出的。


在导出资源这块,要注意一下,使用大图,会把用到的资源拼成一个大图,可以提高效率。使用小图,则把资源的图原样复制过去。这个看你的取舍了。
导出完成后,把导出的目录复制到cocos2dx工程的Resource这个目录下面,就可以在项目中使用了。

最后在需要使用这个UI的场景,增加下面代码

        gui::TouchGroup* ul = gui::TouchGroup::create();
        ul->addWidget(GUIReader::shareReader()->widgetFromJsonFile("NewUi_1/NewUi_1.ExportJson"));
         this->addChild(ul, 2);
如果要访问这个资源,就可以通过tag来操作。 ul->getWidgetByTag(42)。注意不是ui->getChildByTag(42),这个不会遍历所有的子节点。 !这样就完成一个完全的UI操作!
About CocoStudio is a game development tool kit based on Cocos2d-x. It breaks down tasks in game development into different roles, it includes: UI editor for UI graphic artists, Animation editor for graphic artists, Number cruncher for game data designers, Scene editor for game designers CocoStudio forms a complete game development solution. The UI editor The UI was designed to serve its only purpose: create UI for games. Its simple and intuitive interface allows graphic artists to focus on their expertise, without worrying about other aspects such as programming. Currently the UI editor has 12 different UI elements ready to be used in games, new UI elements will be added with each and every release of CocoStudio, Other key features that the UI editor supports are: Texture packaging - Automatically packs individual texture files into a single large sprite, which further saves memory and improves game performance. Multi-resolution adaption - Automatically adapts to multiple resolution sizes with relative UI positioning. Templating - Reuse the same UI layout across different games, swap out texture resources to give it a new look. The Animation editor The Animation editor was designed to feel like Adobe Flash, which makes graphic artists feel right at home. The Animation editor brings skeletal animation to Cocos2d-x. What advantage does skeletal animation holds against the traditional frame animation? Lower memory consumption - An animation with the traditional frame based solution could use dozens of individual textures, but with skeletal animation, only 1 set of body parts is required to make infinite number of different animations. Smaller file size - due to less number of assets. Animation blending - you can combine animations together to easily make new animation, for example, you could blend attacking animation with walk animation to create "attacking while walking animation". Animation reuse - you can share skeletal animations with another character with the same skeleton setup. Smooth interpolation - traditional frame based animation is very choppy especially in slow motion. Skeletal animation interpolates between 2 sets of key frames, so animation is always played at the same frame rate as the game. However Skeletal animation cannot replace the traditional frame based animation, for example, it cannot make isometric character, it cannot make explosion, that is why we did not forget frame based animation, we even made it better and simpler. You only have to drag and drop frame sequences to the work space, and the animation editor will automatically creates the frame animation for you. Other highlight of Animation editor includes: WYSIWYG collision box editing - editing collision box in wysiwyg way has never being easier and accurate. Reference point - enables characters to wield swords, mount horses, and attaching other objects easily. Texture packing - Automatically packs individual texture files into a single large sprite, which further saves memory and improves game performance. The Data Cruncher The data Cruncher imports excel tables and converts the data into a format readable by cocos2d-x, which can also be used as a component for the Scene editor. The Scene editor The scene editor pieces all the assets made by the UI editor, Animation editor, and the Data Cruncher into a game scene, it can then simulate the game inside the editor. The scene editor also supports many assets made from third party editors such as particle designer, tiled etc. The scene editor relies on the CocosStudio Framework. CocoStudio Framework CocoStudio Framework is an open source higher level framework on top of Cocos2d-x, it employes entity and component system, it is used to read the data saved from the scene editor. The Scene editor saves data in a MVC like fashion, it includes all entities and events used in the current scene, and exports to corresponding code template for the programmers. A programmer can then write the code in Javascript to bring the game alive. CocoStudio的安装 1.CocoStudio的运行平台是Windows操作系统,推荐使用Windows7操作系统。 2.安装CocoStudio之前,确保电脑中安装了.Net 4.0 Framework 3.安装目录尽量不要在C盘的Program Files文件夹下,可能会导致启动器无法启动编辑器。当然,通过“以管理员身份运行”的方式也可以打开软件 4.在Xp和Windows8的操作系统下,可能会出现的闪屏或无法运行的问题。这个问题会尽快修复
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值