这是一个关于使用cocostudio实现动画自由切换的小demo

auto  sprite =Sprite::create("background.png");
sprite->setAnchorPoint(Point(0,0));
this->addChild(sprite); ArmatureDataManager::getInstance()->addArmatureFileInfo("catArmature/catArmature.ExportJson");
auto _cat =this->insCatAnimation();
this->addChild(_cat, 1, CATTAG); auto label=LabelTTF::create("Let cat move","Arial",26);
auto item = MenuItemLabel::create(label,CC_CALLBACK_0(HelloWorld::catMove, this)); auto label2 = LabelTTF::create("Let cat pase", "Arial", 26);
auto item2 = MenuItemLabel::create(label2, CC_CALLBACK_0(HelloWorld::catPase, this)); auto menu =Menu::create(item,item2,NULL);
menu->alignItemsVertically();
menu->setPosition(Point(400, 400));
this->addChild(menu); return true;
}
cocostudio::Armature* HelloWorld::insCatAnimation()
{
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin();
auto cat = Armature::create("catArmature");
cat->setPosition(Point(visibleSize.width * 0.6 + 250, visibleSize.height * 0.5 + 20));
cat->getAnimation()->playWithIndex(0); return cat;
} void HelloWorld::catMove()
{
auto cat=(Armature*)this->getChildByTag(CATTAG);
cat->getAnimation()->playWithIndex(0);
auto catM =MoveTo::create(24.0f,Point(150,cat->getPosition().y));
cat->runAction(catM);
} void HelloWorld::catPase()
{
auto cat =(Armature*)this->getChildByTag(CATTAG);
cat->stopAllActions();
cat->getAnimation()->playWithIndex(1);//获取你须要的动画
}

这里是源代码和资源地址:

http://download.csdn.net/detail/u010296979/7288227

写个关于使用cocostudio Armature实现动画自由切换的小demo的更多相关文章

  1. Animo.js :一款管理 CSS 动画的强大的小工具

    Animo.js 是一个功能强大的小工具,用于管理 CSS 动画.它的特色功能包括像堆栈动画,创建跨浏览器的模糊,设置动画完成的回调等等.Animo 还包括惊人的 animate.css,为您提供了近 ...

  2. 原生JS写了一个小demo,根据输入的数字生成不同背景颜色的小方块儿~

    昨天练习写了这个小demo,个人觉得通过设置定位元素left和top的值,来实现换行的功能,这种方法很巧妙~ 另外,如下代码中的随机颜色的获取,还请各位前辈多多指教:需要改进的地方:或者有没有更好的方 ...

  3. JS实现动画方向切换效果(包括:撞墙反弹,暂停继续左右运动等)

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  4. 手写jwt验证,实现java和node无缝切换

    前言 前端时间和我朋友写了一个简易用户管理后台,功能其实很简单,涉及到的技术栈有:vue+elementUI,java+spring MVC以及node+egg,数据库用的mysql,简单方便. 一开 ...

  5. 在项目代码中载入cocostudio导出的动画并循环播放

    须要在代码中引入#include "cocostudio/CocoStudio.h" using namespace cocostudio; ArmatureDataManager ...

  6. 用Canvas写一个炫酷的时间更新动画玩玩

    正文必须要写点什么...   // '; var WINDOW_WIDTH = 913; var WINDOW_HEIGHT = 400; var RADIUS = 7; //球半径 var NUMB ...

  7. css+jq写的小小的移动端按钮的动画改变(三个很闲变成一个叉号)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. iOS 视图控制器转场动画/页面切换效果/跳转动画 学习

    一 学习 在 UINavigationController 中 push 和 pop 的转场效果  (基于iOS7 以上的转场方式) 经过学习了解到,重点分三块: (1)pushAnimation:  ...

  9. 使用karma测试平时写的小demo(arguments为例)

    有人说前端自动化测试非常困难,我觉得确实如此.在项目中,我个人也不放心写的测试,还是要手动测试.但是我们平时写demo学习时,完全可以使用自动化测试. 传统demo 1,新建一个html 2,写入js ...

随机推荐

  1. C#中相关结构的用法及用途

    C#中Dictionary的用法及用途 http://www.cnblogs.com/linzheng/archive/2010/12/13/1904709.html C#中的Dictionary字典 ...

  2. Sql_Handle and Plan_Handle Explained

    For batches, the SQL handles are hash values based on the SQL text. For database objects such as sto ...

  3. lnmp环境的使用教程

    lnmp环境的使用 安装的软件都安装到了:/usr/local 管理nginx service nginx start|stop|restart|reload 管理mysql 直接执行mysql即可登 ...

  4. 使用Nginx Upstream 部署 OpenERP

    Openerp 6.1 使用werkzeug 作为web服务的框架,性能比之前的cherrypy 有了很大的改善.但无论是 werkzeug 还是cherrypy ,都不是专门的web服务器.通常的做 ...

  5. DIV+CSS布局重新学习之使用A标签和CSS制作按钮

    这里主要利用A元素的伪类来实现: a:link {color: #FF0000} /* 未访问的链接 */ a:visited {color: #00FF00} /* 已访问的链接 */ a:hove ...

  6. 以__name__进行单元测试

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #以__name__进行单元测试 #何为单元测试? #单元测试(模块测试)是开发者编写的一小段代码,用于检测被 ...

  7. Tomcat之配置HTTPS

    1. 在C:\Windows\System32\drivers\etc\hosts文件中新增一条项目web.demo.com,让Tomcat可以通过域名访问: 127.0.0.1 web.demo.c ...

  8. CreateThread、_beginthreadex和AfxBeginThread .

    创建线程好几个函数可以使用,可是它们有什么区别,适用于什么情况呢?参考了一些资料,写得都挺好的,这里做一些摘抄和整合. [参考1]CreateThread, AfxBeginThread,_begin ...

  9. Oracle实例

    ORA-12505 Listener refused the connection with following error:ORA-12505,TNS:listener 确定这是连接数据库的SID错 ...

  10. Python 的 pandas 实践

    Python 的 pandas 实践: # !/usr/bin/env python # encoding: utf-8 __author__ = 'Administrator' import pan ...