创建帧动画

SpriteFrameCache 精灵缓冲池
第一种是读取plist文件到精灵缓冲池,获得每一帧的精灵帧,添加到Animation动画中,设置setDelayPerUnit 每一帧的时间,然后获得Animate 动作,最后播放动作
备注:怎么样才能获取plist文件里面的数量?通过判断获取到的是NULL对象来判断吗?
第二种是通过AnimationCache 管理动画的单例; 它用于缓存的动画,读取到的plist文件必须是带有animation这个key的;通过getAnimation获得指定的动画

读取骨骼动画

通过ArmatureDataManager,同步或者异步加载骨骼动画到ArmatureData里面,然后通过Armature进行创建动画,播放

cocostudio::ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("DemoPlayer0.png","DemoPlayer0.plist","DemoPlayer.ExportJson");
auto spritecache = SpriteFrameCache::getInstance();spritecache->addSpriteFramesWithFile("grossini.plist");auto animation3 = Animation::create();Vector<SpriteFrame* >vectorSprite;for (int i = 1; i <= 14; i++) {SpriteFrame *temp = spritecache->spriteFrameByName(StringUtils::format("grossini_dance_%02d.png",i));animation3->addSpriteFrame(temp);}animation3->setDelayPerUnit(1);Animate *animatetest = Animate::create(animation3);CCLOG("%d",spritecache->getReferenceCount());auto cache = AnimationCache::getInstance();cache->addAnimationsWithFile("animations-2.plist");auto lunzi = Sprite::createWithSpriteFrameName("grossini_dance_01.png");lunzi->setPosition(Point(300, 300));auto animation2 = cache->getAnimation("dance_1");auto animate2 = Animate::create(animation2);lunzi->runAction(RepeatForever::create(animatetest));cocostudio::ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("DemoPlayer0.png","DemoPlayer0.plist","DemoPlayer.ExportJson");cocostudio::Armature* armature = cocostudio::Armature::create("DemoPlayer");armature->getAnimation()->playByIndex(0);armature->setPosition(Point(400, 400));this->addChild(lunzi);this->addChild(armature);

骨骼动画的帧事件,通过动画制作的时候绑定到骨骼动画帧中,currentFrameIndex为第几帧触发,evt输出的是骨骼动画事件的名字

    cocostudio::ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("chongwu.png", "chongwu.plist", "miaomiao.xml");cocostudio::Armature* armature2 = cocostudio::Armature::create("miaomiao");armature2->getAnimation()->playByIndex(1);armature2->setPosition(Point(500, 500));(armature2->getAnimation())->setFrameEventCallFunc(this,cocostudio::SEL_FrameEventCallFunc(&HelloWorld::onFrameEvent));
void HelloWorld::onFrameEvent(cocostudio::Bone * bone, const std::string & evt, int originFrameIndex, int currentFrameIndex)
{auto bonedata =bone->getBoneData();CCLOG("bone x=%f,y=%f", bonedata->x, bonedata->y);CCLOG("evt =%s", evt.c_str());CCLOG("originFrameIndex=%d", originFrameIndex);CCLOG("currentFrameIndex=%d", currentFrameIndex);
}

Animation Animate Armture三个动画的使用相关推荐

  1. Android Animation学习(三) ApiDemos解析:XML动画文件的使用

    Android Animation学习(三) ApiDemos解析:XML动画文件的使用 可以用XML文件来定义Animation. 文件必须有一个唯一的根节点: <set>, <o ...

  2. SRPG游戏开发(四十一)第九章 战斗系统 - 三 战斗动画(Combat Animation)

    返回总目录 第九章 战斗系统(Combat System) 在SRPG中,大多数情况是指角色与角色之间的战斗.而这种战斗一般有两种模式: 地图中直接战斗: 有专门的战斗场景. 这两种模式的战斗在数据上 ...

  3. Android 三种动画的总结

    在看动画相关的代码的时候看到过 anim,animator 目录,资源文件中的有 <set> 作为根节点的,也有 <animate-list> 作为根节点的.虽然知道它们这是跟 ...

  4. python matplotlib animation制作世界人口变动动画

    python matplotlib animation制作世界人口变动动画 主要利用animation 做了个世界人口动画,数据从网上下载的.做成json格式的.读入pandas.没有放数据, 只是弄 ...

  5. Android开发—三种动画实现原理及使用

    Android动画目前分为三种: Frame Animation 帧动画,通过顺序播放一系列图像从而产生动画效果,.图片过多时容易造成OOM(Out Of Memory内存用完)异常. Tween A ...

  6. 利用CSS3的animation step属性实现wifi动画(结尾有彩蛋)

    之前攒的满满的SVG+CSS3做动画的技能一直未能放个大招,理由很简单,因为本身从事行业的性质,软件里不能出现劳什子动画这等花里胡哨的东西,哦,不不,叫隐喻行为引导的趣味化.用canvas实现了一个科 ...

  7. iOS核心动画--浅析三个动画的实现

    点击打开链接 http://www.jianshu.com/p/272aa1f26c62 动画和绘图是iOS开发中非常重要的部分.我们要实现一个动效,首先就是动画解析,分析动画的路径,然后再考虑具体的 ...

  8. CSS3 animation实现点点点loading动画

    一.再续前缘 去年夏天,写了篇名为"CSS3 animation渐进实现点点点等待提示效果"的文章,主要内容是实现类似下面打点等待提示效果,比干巴巴的字符...要更人性化: 之前实 ...

  9. 利用Animation控件制作帧动画过程详解

    利用Animation控件制作帧动画过程详解 前言 通过Animation控件来达到序列图的播放(素材和示例视频在文章末尾) 一.序列图 (此素材为已经分割好的序列图) 如若序列图在一张图片上,请参考 ...

最新文章

  1. linux脚本命令顺序执行命令,linux – nohup多个顺序命令
  2. 1.3 计划需求控制
  3. 高中计算机试题一,職业高中高考计算机专业试卷1.doc
  4. 基础强化:深入理解JVM中的方法调用
  5. 【自然语言处理】--视觉问答(Visual Question Answering,VQA)从初始到应用
  6. linux下安装redis-cli
  7. WPF笔记(1.8 资源与映射)——Hello,WPF!
  8. GPS精密星历文件下载地址
  9. 高速公路综合信息管理系统
  10. 牛逼!分享一款基于 SpringBoot 的微信点餐系统(附源码)
  11. ubuntu 16.04 更换阿里源
  12. 在线html排版网页排版,40张网页排版设计案例,总有一款你会用得上
  13. 前后端分离框架Vue+Element UI(上集)
  14. 增加收入的 6 种方式
  15. 如何快速实现微信账号的注销,福利在这里,怎样快速注销微信账号
  16. 1011:2.4将磅转换为千克
  17. css清除浮动float
  18. 2018.4.3 美图笔试题
  19. 基于NI myRIO的小车红外循迹避障
  20. android应用图标_管理您的android应用图标

热门文章

  1. 清华、北大、中科大、UMA、MSU五位博士生畅聊深度学习理论
  2. voltdb mysql_VoltDB安装
  3. 无法连接到 。 其他信息: 用户 ‘‘ 登录失败。 (Microsoft SQL Server,错误: 18456
  4. K-Means(K均值)聚类算法
  5. 51单片机读写WTV语音芯片
  6. 深入理解BootStrap -- 面板(panel)17
  7. displaytag的Excel导出实践
  8. 移动端fastClick使用
  9. js实现滚动条自动滚动(scrollTop)
  10. batch 13.0 批处理 attrib