从Delphi开始学Cocos2dx-3.0[12]:可变速度
来源:互联网 发布:vantagepoint软件下载 编辑:程序博客网 时间:2024/06/05 03:50
cocos里面的速度 还不是普通的意义上的速度
大概分成3种 ,
1, 先加速再减速 In
2, 先减速再加速 Out
3, 先减速再加速然后还减速 InOut
为了测试三个的速度. 这回必须要弄3张图片上去了.
// 添加一张精灵图片 auto sprite1 = TSprite::create("ball.png"); // 设置位置到正中间 sprite1->setPosition(TPoint(100.0f, 100.0f)); // 添加到Helloworld图层 this->addChild(sprite1, 0, 1000); auto sprite2 = TSprite::create("ball.png"); sprite2->setPosition(TPoint(100.0f, 300.0f)); this->addChild(sprite2, 0, 1001); auto sprite3 = TSprite::create("ball3.png"); sprite3->setPosition(TPoint(100.0f, 500.0f)); this->addChild(sprite3, 0, 1002); return true;
bool THelloWorld::onTouchBegan(TTouch* touch, TEvent* event){auto sprite1 = (TSprite*)(this->getChildByTag(1000)); auto sprite2 = (TSprite*)(this->getChildByTag(1001)); auto sprite3 = (TSprite*)(this->getChildByTag(1002)); static int nTempIdx = 0;switch (nTempIdx++){case 0: // 大家一起往右移动{sprite1->runAction(TEaseIn::create(TMoveBy::create(1, TPoint(600.0f, 0.0f)),2.0f));sprite2->runAction(TEaseOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f)),2.0f));sprite3->runAction(TEaseInOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f)),2.0f));} break;case 1: // 大家一起往左移动{sprite1->runAction(TEaseIn::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f)),0.5f));sprite2->runAction(TEaseOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f)),0.5f));sprite3->runAction(TEaseInOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f)),0.5f));} break;case 2: // 大家一起往右移动{sprite1->runAction(TEaseSineIn::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));sprite2->runAction(TEaseSineOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));sprite3->runAction(TEaseSineInOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));} break;case 3: // 大家一起往左移动{sprite1->runAction(TEaseSineIn::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));sprite2->runAction(TEaseSineOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));sprite3->runAction(TEaseSineInOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));} break;case 4: // 大家一起往右移动{sprite1->runAction(TEaseBackIn::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));sprite2->runAction(TEaseBackOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));sprite3->runAction(TEaseBackInOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));} break;case 5: // 大家一起往左移动{sprite1->runAction(TEaseBackIn::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));sprite2->runAction(TEaseBackOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));sprite3->runAction(TEaseBackInOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));} break;case 6: // 大家一起往右移动{sprite1->runAction(TEaseExponentialIn::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));sprite2->runAction(TEaseExponentialOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));sprite3->runAction(TEaseExponentialInOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));} break;case 7: // 大家一起往左移动{sprite1->runAction(TEaseExponentialIn::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));sprite2->runAction(TEaseExponentialOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));sprite3->runAction(TEaseExponentialInOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));} break;case 8: // 大家一起往右移动{sprite1->runAction(TEaseBounceIn::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));sprite2->runAction(TEaseBounceOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));sprite3->runAction(TEaseBounceInOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));} break;case 9: // 大家一起往左移动{sprite1->runAction(TEaseBounceIn::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));sprite2->runAction(TEaseBounceOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));sprite3->runAction(TEaseBounceInOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));} break;case 10: // 大家一起往右移动{sprite1->runAction(TEaseElasticIn::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));sprite2->runAction(TEaseElasticOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));sprite3->runAction(TEaseElasticInOut::create(TMoveBy::create(1, TPoint(600.0f, 0.0f))));} break;case 11: // 大家一起往左移动{sprite1->runAction(TEaseElasticIn::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));sprite2->runAction(TEaseElasticOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));sprite3->runAction(TEaseElasticInOut::create(TMoveBy::create(1, TPoint(-600.0f, 0.0f))));} break;default: {sprite1->runAction(TPlace::create(TPoint(100.0f, 100.0f)));sprite2->runAction(TPlace::create(TPoint(100.0f, 300.0f)));sprite3->runAction(TPlace::create(TPoint(100.0f, 500.0f)));nTempIdx = 0;}} CCLOG("THelloWorld::onTouchBegan id = %d, x = %f, y = %f", touch->getID(), touch->getLocation().x, touch->getLocation().y); return true;}
0 0
- 从Delphi开始学Cocos2dx-3.0[12]:可变速度
- 从Delphi开始学Cocos2dx-3.0[1]: AppDelegate 与 Application
- 从Delphi开始学Cocos2dx-3.0[7]:瞬发动作
- 从Delphi开始学Cocos2dx-3.0[16]:LUA脚本接入
- 从Delphi开始学Cocos2dx-3.0[4]:定义一个Delphi头,方便今后编程
- 从Delphi开始学Cocos2dx-3.0[13]:动画-直接从图片文件创建动画
- 从Delphi开始学Cocos2dx-3.0[14]:动画-直接从精灵帧缓存中获取纹理
- 从Delphi开始学Cocos2dx-3.3[17]:从3.0 进化到3.3(详细图文)
- 从Delphi开始学Cocos2dx-3.0[0]: VS2012 与 安装 cocos2d-x-3.0alpha0
- 从Delphi开始学Cocos2dx-3.0[2]:TObject 与 CCObject 看继承关系
- 从Delphi开始学Cocos2dx-3.0[3]:CCNode 可视组件的头
- 从Delphi开始学Cocos2dx-3.0[5]:鼠标按下移动弹起与单点触摸
- 从Delphi开始学Cocos2dx-3.0[6]:拖拽一个精灵
- 从Delphi开始学Cocos2dx-3.0[8]:持续动作之位移持续动作
- 从Delphi开始学Cocos2dx-3.0[9]:持续动作之缩放持续动作
- 从Delphi开始学Cocos2dx-3.0[10]:持续动作之旋转持续动作
- 从Delphi开始学Cocos2dx-3.0[11]:持续动作之组合动作
- 从Delphi开始学Cocos2dx-3.0[15]:关于精灵帧和精灵帧缓存
- java运行windows的cmd命令
- Linux操作系统下的多线程编程详细解析----条件变量
- MySQL存储过程编程教程读书笔记-第二章MySQL存储过程编程指南-存储过程部分
- 收藏的博客--界面开发
- geoserver部分元素名称及其作用
- 从Delphi开始学Cocos2dx-3.0[12]:可变速度
- android开发教程(十一)——android应用程序基础
- java通过commons net whoisclient查询whois信息
- 秒杀多线程第一篇 多线程笔试面试题汇总
- 踩着未来的光点,踏出迷茫的现在
- atheros无线驱动之:系统初始化
- perl: warning: Setting locale failed.
- 备份和恢复 20131224
- 排序汇总(Java实现)