cocos2dx_3.X项目重新写(一)帧动画的改变

来源:互联网 发布:淘宝如何发货 编辑:程序博客网 时间:2024/06/06 08:42

以后用3.X版本。

重写以前的那个项目。首先去CC,然后,先建立Stage,建立精灵出来,给精灵加走动的动画。遇到错误,fatal error C1083: 无法打开包括文件:“extensions/ExtensionMacros.h”: No such file or directory”。

 找到了如下解决方案。

<span style="font-size:12px;">Cocos2d-x 3.0 Alpha 1开始 对目录结构进行了整合。结果有些附加项目也被在项目中被精简出去。比如说如果你需要使用CocoStdio导出的JSON、或使用Extensions扩展库,libCocosStudio、libExtensions、libGUI都需要在你手动添加。如果你碰到类似这样的错误“ fatal error C1083: 无法打开包括文件:“extensions/ExtensionMacros.h”: No such file or directory”。可以采用下列的操作。</span><span style="font-size:14px;"><strong>第一步:在项目中添加附加项目。</strong></span><span style="font-size:12px;">A:在“解决方案资源管理器”中找到整个解决方案,右击,选择“添加”->“现有项目”。在弹出的对话框中找到“项目目录/cocos2d/cocos/editor-support/cocostudio/proj.win32/libCocoStuido”点击确定。B:在“解决方案资源管理器”中找到整个解决方案,右击,选择“添加”->“现有项目”。在弹出的对话框中找到“项目目录/cocos2d/cocos/gui/proj.win32/libGUI”点击确定。C:在“解决方案资源管理器”中找到整个解决方案,右击,选择“添加”->“现有项目”。在弹出的对话框中找到“项目目录/cocos2d/extensions/proj.win32/libExtensions”点击确定。<strong>第二步:你需要在你的项目中引用这些刚导入的项目。</strong>对你的项目右键,选择“引用...”。在弹出的属性页中点选下面的“添加新引用”。在弹出的子级对话框中勾选我们刚才刚加入的三个lib项目(如图),点击确定,这样就完成添加项目对库的引用。<strong>第三步:为你的项目添加包含目录。</strong>$(EngineRoot)$(EngineRoot)cocos$(EngineRoot)cocos\editor-support</span>
 跟2.x的代码区别如下。

在添加动画的时候

sharedSpriteFrameCache()被getInstance()替换;

3.x放弃了arrar使用vector,在我的函数里定义为Vector<SpriteFrame*> v;添加元素为v.pushBack(frame1);

其他的基本一致。

代码如下

Animate* Player::run_action(){//1 添加到帧缓冲池SpriteFrameCache* frameCache1 = SpriteFrameCache::getInstance();frameCache1->addSpriteFramesWithFile("p.plist","p.png");//2 循环参数int imax1 = 19;SpriteFrame* frame1;Vector<SpriteFrame*> v;//3 循环添加帧for (int i=1; i<=imax1;i++){frame1=frameCache1->getSpriteFrameByName(String::createWithFormat("%d.png",i)->getCString());v.pushBack(frame1);}//4 给CCAnimationAnimation* nima1 = Animation::createWithSpriteFrames(v);nima1->setDelayPerUnit(0.05);nima1->setLoops(-1);//5 给CCAnimateAnimate* action1 = Animate::create(nima1);return action1;}




0 1
原创粉丝点击