ccbi反编译ccb
❶ cocosbuilder停止维护了吗
话说现在很少用cocosbuilder了,因为虽然布局比较简单,但是在绑定和个性化设置等方面都不方便,所以我现在很少用,但是有时候仍有几个前辈非要用,然后就搞得我在看他们代码的时候就不得不跟着搞
在两个星期的折磨中,遇到了几个常见的问题会导致工程崩溃.所以总结一下
1.资源图片或者字体丢失,因为修改过的ccb资源有时候只是细节上的差别,而如果刚好是那部分的资源丢失,直接会崩溃,最简单实用的办法就是一个一个的看,同时也要看隐藏的,如果有丢失,补上去就可以了
2.ccb资源有其他的ccb文件,而刚好是其他的那个ccb文件错误,这样的话也是和资源丢失那样崩溃,这个也是你一个一个的看了
3.设置的tag值错误,比如说你在ccb里面没有设置20这个tag值,但是后面又直接读取这个tag,这就会错误,当然,如果你设置了tag,那就不需要在代码里面在设置了,虽然不会出错
4.看你的ccb的特效是否正确,有时候因为ccb文件里面的特效文件丢失,就喝第一个一样会出现错误,这个要查找就是自己点击特效运行,看是否正常
注意,在xcode中,就算改了ccb文件,xcode也不会立即生效的,所以最完整的步骤就是
1.修改ccb文件,2.把原来的ccbi文件删除,然后把这个ccb工程clean一下,然后重新publish一下重新生成ccbi文件
3.把xcode重新clean一下,然后在运行就行了.
当然,有次我的电脑特别悲催,这样干了也是没有出效果,最后不得不重启了电脑,又按照上面的三个步骤走了一遍他才生效了,所以最终还是靠的耐心
cocosbuilder作为一个ui设计的推动者,我们会记得,但是估计也会离我们越来越远,所以只需要简单会用就行了,这个软件说实话,真的不好用
❷ 怎么读取嵌套CCB
我遇到同样的问题.正在找办法解决..
我的已经解决:
其实CCBFile *ccbFileNode = (CCBFile*)node; 这一句里的node是空.往上看:
// Read properties
ccNodeLoader->parseProperties(node, pParent, this);
这个里面 parseProperties没有把node弄出来,因此下面是NULL.
为什么parseProperties里面没把node弄出来呢?进parseProperties函数里面看:
应该是在大switch里面的
case CCBReader::PropertyType::CCB_FILE:
这个case里面有
Node * ccbFileNode = this->parsePropTypeCCBFile(pNode, pParent, ccbReader);
进parsePropTypeCCBFile里面一步步断点看:
发现
// Load sub file
std::string path = FileUtils::getInstance()->fullPathForFilename(ccbFileName.c_str());
的path为'',即空字符串.导致接下来的node不生成.那么进fullPathForFilename里面看:
两层循环里面发现
_searchPathArray
这个东西,看看里面的字符串数组.
把这个数组里的每一个字符产拼接上filename(你的子ccbi文件的相对路径),看看是不是都不能得到真实资源的位置呢?是的话..那就是了.
所以要加几个searchPaths使这里的_searchPathArray里面能使其找到资源才行!
我使用的是Cocos2D-JS 3.6.1 对应 Cocos2D-X 3.6.
在JS端使用了
if (screenSize.width > 960 && screenSize.height > 640) {
cc.log('HDR mode');
cc.director.setContentScaleFactor(4.0);
cc.loader.resPath = 'res/HDR';
var designSize = cc.size(480, 320);
} else if (screenSize.width > 480 && screenSize.height > 320) {
cc.log('HD mode');
cc.director.setContentScaleFactor(2.0);
cc.loader.resPath = 'res/HD';
var designSize = cc.size(480, 320);
} else {
cc.log('SD mode');
cc.director.setContentScaleFactor(2.0);
cc.loader.resPath = 'res/SD';
var designSize = cc.size(480, 320);
}
来设置不同分辨率所用的图片资源.而ccbi资源在res里面没有配置..
怎么配置?
上面多写一句cc.loader.resPath = 'res'即可.
它跟其它的cc.loader.resPath = 'res/HD'等不矛盾.
写几遍就相当于在c++层的_searchPathArray里面多加一条路径.
ps:反正我是有巨坑的感觉
-Ethan.来自藌柚软件科技
❸ cocos2dx里面怎么使用cocosbuilder
2012年过年年回来一直没有可以用于写博客的新收获,以致于担心2013年2月份的博客数量能否达到4篇,以保证我博客头像下锃亮的”恒“。新公司可以直接上网是我这三个月来博客数量倍增的主要原因。好了不多说了,回归正题。
这里主要是一些除CocosBuilder本身Document之外的一些使用教程。CocosBuilder的基本使用这里面是不会提及的,因为CocosBuilder本身就带了此时市面上最全的说明文档。不习惯看说明文档的童鞋们请硬着头皮看一下,顺便当做英语六级补习课。本文的使用的CocosBuilder版本是CocosBuilder-2.1,基于的Cocos2d-x版本是Cocos2d-x 2.0.4。
本教程将使用CocosBuilder创建Project时自带的HelloCocosBuilder.ccb作为素材,在Cocos2d-x 2.0.4中加载并呈现出来。
首先创建一个Cocos2dx的一个模版项目(后面称之为A项目)
然后使用CocosBuilder在A项目资源文件夹下面创建一个Project,然后点击【File】-》【Publish】。这样我们就可以在A项目的资源文件夹下找到HelloCocosBuilder.ccbi。
将HelloCocosBuilder.ccbi加入到A项目的xCode项目管理中。将HelloCocosBuilder.ccbi拖入到xCode中,一般放入Resouces文件下面。特别注意,在弹出的提示框中,一定要勾选想要添加到的target(下面附带截图)。
这点很重要,很多windows开发人员(或许就是我)总认为资源不必加入项目文件中(即开发环境中项目文件列表),程序是能够搜索到的,但是xCode开发ios程序时,xCode会把需要的文件拷贝到ios device目录中,如果你不把需要的文件加入项目文件中,那么xCode不会帮你拷贝,到时候生成的app中就没有这个资源。
打开AppDelegate.cpp文件,修改applicationDidFinishLaunching函数。
[cpp] view plain
由于HelloCocosBuilder.ccbi中没有涉及任何外部资源,所以无须添加外部资源到项目文件中。
Cocos2d-x中CocosBuilder文件的加载没有Cocos2d版本的那么好,没有提供一个便利函数,一句话加载,以致于新手需要上网所搜如何加载。上面的加载代码也是我从网上搜到的,然后自己稍微改的精简一些。具体含义我也没有深究,很是好奇的童鞋可以自己探索一下。
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
//read ccbi file
CCBReader* pReader = new CCBReader( CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary() );
pReader->autorelease();
pDirector->runWithScene( pReader->( "HelloCocosBuilder.ccbi" ) );
return true;
}
【Command】+R,运行程序就能看到Hello CocosBuilder在模拟器中央。
虽然这个教程很简单,但是本人断断续续也搞了一天多,主要出错在于上面的第三步,以及自己建立的CocosBuilder Project文件本身有问题。以后我会在项目中不断挖掘CocosBuilder的用处,然后贴出系列教程。
❹ lua 判断一个对象是不是节点
cocosbuilder 中的设置
在cocosbuilder中 找到需要绑定的CCMenuItemImage
把code connections 中 设置 为 owner var 并填写自定义对象名
设置一个 CCMenuItemImage 叫 close
CCLabelTTF
CCScale9Sprite
等其他对象类似 选 owner var 并设置 自定义对象名
也可以通过设置tag 可以在lua中通过tag 读取对象
在lua中加载ccbi 并加载指定ccbi中指定的对象进行操作
lua中的代码
加载ccbi方式:
proxy= LuaProxy:create() --使用luaproxy 库 新建一个proxy对象
local n = proxy:readCCBFromFile("xxx.ccbi") -- 加载你设置的ccbi文件
local l = tolua.cast(n, "CCLayer") -- 把ccbi 转换对cclayer对象
加载此ccbi中各种对象的 方式:
加载各种对象中xxx 指的时 ccbi中其对象的code connections 中 设置 为 owner var 并在后填写的相应对象名称
上图中 CCMenuItemImage 叫 close 则加载代码为
--把ccbi中的菜单项转换成lua中的菜单项对象
local menuItem= proxy:getNode"close","CCMenuItem"
--把转换好的菜单项绑定回调事件
proxy:handleMenuEvent(menuItem,function()
print("点击了关闭菜单")
end)
--其他常用的对象的加载方式 xxx为ccbi中自定义的对象名
--把ccbi中定义的CCLabelTTF转换成 lua中CCLabelTTF 对象
local ttf=tolua.cast(proxy:getNode"xxx","CCLabelTTF")
--把ccbi中的精灵对象转化成lua的精灵对象
local sprite = tolua.cast(proxy:getNode"xxx","CCSprite")
--把ccbi中的菜单对象转换成lua中的菜单对象
local menu= tolua.cast(proxy:getNode"xxx","CCMenu")
--把ccbi中的菜单项转换成lua中的菜单项对象
local menuItem= proxy:getNode"xxx","CCMenuItem"
--把转换好的菜单项绑定回调事件
proxy:handleMenuEvent(menuItem,function()
end)
--把ccbi中的九宫格 转换成 lua中的九宫格对象
local ccsprite9 = proxy:getNode"xxx","CCScale9Sprite"
--把ccbi中的按钮转换成lua中的按钮对象
local ccontrol = tolua.cast(proxy:getNode"xxx","CCControlButton")
--给转换好的按钮绑定事件
proxy:handleButtonEvent(ccontrol, function(ccontrol, event)
-- 按钮的 事件
end, CCControlEventTouchUpInside)
❺ 如何在 CocosBuilder里使用时间轴Callback 功能
You can use CocosBuilder for creating character animations, animating complete scenes or just about any animation you can imagine. The animation editor has full support for multiple resolutions, easing between keyframes, boned animations and multiple timelines to name a few of the features.
你可以使用CocosBuilder创建角色动画,场景动画或者其他一些动画。动画编辑器完全支持多分辨率,动画关键帧,骨骼动画以及多条时间轴等功能。
The Basics
基础
In the bottom of the main window you can find the timeline. You use the timeline to create your animations.
在下图中你可以看到时间轴,你可以使用时间轴来创建你的动画。
By default your ccb-file has a single timeline that is 10 seconds long. CocosBuilder edits animations at a frame rate of 30 frames per second, but when you play back the animation in your app it will use whatever you have set cocos2d to use (the default in cocos2d is 60 fps). The current time is displayed in the top right corner, and has the format minute:second:frame. The blue vertical line also shows the current time. Click the time display to change the ration of the current timeline.
默认情况下你的ccb文件仅有一条长为10秒钟的时间轴。Cocosbuilder以每秒钟30帧的速率编辑动画,但当你的你的应用中播放动画的时候,动画将以你在cocos2d中设置的速率播放(默认是60fps)。当前的时间在右上角显示出来,格式为分钟:秒:帧。蓝色竖线也显示了当前的所在的时间。点击上方的时间显示(水平进度条)来改变当前时间轴单位时间之间的距离。
Adding Keyframes
添加关键帧
Animations in CocosBuilder are keyframe based. You can add keyframes to different properties of a node and CocosBuilder will automatically interpolate between the keyframes, optionally with different types of easing.
CocosBuilder中的动画是以关键帧为基础的。你可以为节点的不同属性添加关键帧,CocosBuilder会自动地在关键帧中插入不同类型的过渡效果。
To add a keyframe, first expand the view of the node by clicking the triangle to the right of the name of the node. This will reveal all the animatable properties of the node. What can be animated varies slightly depending on what type of node you have selected. Once the properties are visible you can click the property in the timeline with the option key held down. This will create a new keyframe at the time of the click. Alternatively, you can create a new keyframe at the time of the time marker by selecting a node then choosing Insert Keyframe in the Animation menu.
首先通过点击节点名称左边的小三角展开节点。这将把节点中所有可制作动画的属性展现出来。根据你所选择节点类型的不同,可以制作成动画的属性会有少许不同。按住键盘上的option键,点击时间轴上的属性,这将在你当前点击的时间点上建立一个关键帧。或者,选中节点后,你可以通过Animation菜单中的Insert Keyframe(插入关键帧)子菜单来创建一个关键帧。
Keyframes are automatically added at the current time if you transform a node in the canvas area, given that the transformed property already has one or more keyframes in the timeline.
如果你在画布区域对节点进行变形的操作,那么在当前时间点会自动创建一个关键帧。
Editing Keyframes
编辑关键帧
You edit a specific keyframe of a node by moving the time marker to the time of the keyframe and selecting the node. You can focus on a keyframe by double clicking it (which will select the node and move the time marker).
如果你要编辑一个关键帧,你要先选中节点,然后把时间标记移动到关键帧的时间点上。你可以通过双击一个关键帧把它设置为焦点(这个操作会选中节点并移动时间轴)。
You can select keyframes and move them together by dragging a selection box around them. You can also and paste keyframes between nodes. Make sure you only have one selected node when pasting the keyframes. The keyframes will be pasted starting at the time of the time marker.
你可以把关键帧进行框选后一起移动。你还可以在节点间拷贝粘贴关键帧。当你粘贴关键帧的时候,确保你只选中了一个节点。
If you have selected a set of keyframes it is possible to reverse the order of them by selecting Reverse Selected Keyframes in the Animation menu. Use the Stretch Selected Keyframes… option to speed up or slow down an animation by a scaling factor.
如果你选中了一组关键帧,那么你可以通过Animation菜单中的Revert Selected Keyframes(反转选定关键帧)子菜单来把它们的顺序反转。通过Stretch Selected Keyframes…(拉伸选定关键帧)子菜单来加速或者减缓你的动画(通过输入缩放系数)。
Importing a Sequence of Images
导入一系列图片
If you have an animation created by sprite frames it can be tedious to move each indivial frame to the timeline. CocosBuilder simplifies this process by automatically importing a sequence of images. Select the frames that you want to import in the left hand project view, then select a CCSprite in the timeline. Now choose Create Frames from Selected Resources in the Animation menu. The frames will automatically be created at the start of the marker. If you need to slow down the animation, select the newly created keyframes and use the Stretch Selected Keyframes… command.
如果你的动画是通过一组精灵帧实现的,你可以把每一个单独的帧拖放到时间轴上去,但是CocosBuilder简化了这个过程,你可以一口气导入一系列图片资源。在左侧的项目视图中,选择你想要导入的一系列动画帧的资源图片,在时间轴上选择CCScprite(精灵),然后在Animation菜单中选择Create Frames from Selected Resources子菜单,这些帧会自动地在时间点的起始位置创建。如果你想放慢动画,选择刚刚创建好的关键帧并使用Stretch Selected Keyframes…子菜单来达到这个效果。
Applying Easing
使用关键帧过渡
CocosBuilder offers a carefully selected subset of the easings provided by cocos2d. To apply an easing right click between two keyframes and select the type of easing that you want to apply.
CocosBuilder提供了精心挑选的一组cocos2d的过渡(Easing)效果。在两个关键帧中点击右键然后选择你想要的过渡效果。
Some of the easings have additional options, after the easing has been applied you can right click again and select Easing Setting… from the popup menu.
有一些过渡效果有一些额外的参数,使用过渡效果后你可以再次右键点击并从弹出菜单中选择Easing… Setting(过渡设置)。
Using Multiple Timelines
使用多条时间轴
A very powerful feature of CocosBuilder's animation editor is the ability to have multiple timelines in a single file. You can name the different sequences and play them back from your code by using their name. It's even possible to smoothly transition between the different timelines.
CocosBuilder动画编辑器一项最为强大的功能是在一个文件中使用多条时间轴。你可以为不同的序列命名并在你的代码中通过这个名字来调用这个动画。更牛X的是你可以在不同的时间轴间实现无缝过渡。
To select, add or edit your timelines use the timeline popup menu:
在时间轴的弹出菜单中选择:添加或者是编辑你的时间轴:
In the edit timelines dialog you can get an overview of your timelines, rename them, add new ones and (optionally) set one of the timelines to automatically start playback directly when the ccbi-file is loaded by your app.
在编辑时间轴的对话框中,你会看到你的时间轴的概要信息,你可以重命名,添加一个新的时间轴或者指定其中一个时间轴作为当ccbi文件加载时自动播放的时间轴。
Properties in timelines that do not have keyframes set share their values across timelines. E.g. if you move one node in one timeline it will be moved in all timelines as long as they do not have a keyframe set for the position property. It can sometimes be useful to add a single keyframe to a property just to override the shared value for a specific timeline.
如果一个时间轴的属性上没有设定关键帧,那么它就会被其他时间轴的关键帧所影响,比如:如果你在一个时间轴里移动了一个节点,它也会在所有没有定义位置关键帧的时间轴里面移动。你可以通过给一个时间轴设定一个单帧来避免被其他时间轴的关键帧所覆盖。
Chaining Timelines
链接时间轴
You can automatically play back a sequence of timelines by chaining them. You can also use this feature for automatically looping a timeline.
你可以把多条时间轴链接起来并播放。你也可以利用这个功能来自动地循环播放一条时间轴。
To have a timeline play in sequence, click the No chained timeline text and select the timeline you want to play right after the current one.
如果要使用链接时间轴的功能,点击No chained timeline(无链接时间轴)文字并选择当前时间轴结束后你想继续播放的时间轴。
Playing Back Animations in Code
在代码中播放动画
To programmatically control the animations you create with CocosBuilder you will need to retrieve the CCBAnimationManager. The animation manager will be assigned to the nodes userObject when the ccbi-file is loaded.
为了让CocosBuilder创建的动画在你的代码中播放,你需要使用CCBAnimationManager。在ccbi文件加载时,动画管理器会被指定给userObject节点。
CCNode* myNodeGraph = [CCBReader nodeGraphFromFile:@"myFile.ccbi"];
CCBAnimationManager* animationManager = myNodeGraph.userObject;
The animation manager will be returned as an autoreleased object. To play back a specific timeline call the runAnimationsForSequenceNamed: method. If a timeline is currently playing it will be immediately stopped when calling this method.
动画管理器会返回一个自释放的对象。调用runAnimationsForSequenceNamed:方法来播放一个指定的时间轴。如果一个时间轴已经在播放了,它会被立即停止。
[animationManager runAnimationsForSequenceNamed:@"My Timeline"];
Optionally, you can use a tween ration to smoothly transition to the new timeline. Where possible linear interpolations will be used for the transition.
或者你也可以使用tweenDuration参数平滑地过渡到一个新的时间轴。
[animationManager runAnimationsForSequenceNamed:@"My Timeline" tweenDuration:0.5f];
It is also possible to receive a callback whenever a timeline has finished playing. You will receive these callbacks even if another timeline is chained in sequence. Use the CCBAnimationManagerDelegate to receive the callbacks.
还可以为时间轴播放完毕时设定一个回调函数。就算有另外一个时间轴被链接起来,你还是可以使用这些回调函数。使用CCBAnimationManagerDelegate来接收回调函数。
❻ cocosbuilder中ccbi文件过时怎么解决
通过升高CocosBuilder的版本来解决的,那么其实找到低一点版本的CCBReader理论上来说也是可以解决的!
❼ ccbi文件可以打开吗
cb文件可以打开,但是ccbi文件打开了意义也不是太大了,都乱了。
如果要看ccbi文件,最好是拿到它对应的ccb文件看,或者有个方法我也没试过,你可以试试看,就是等ccbi文件加载到程序后断点看它的内容,找到动画对应的内容看。