热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

cocos2d-基本概念(3)-Actions:Ease缓冲动作

Actions:Easeease不知道怎么翻译,暂时翻译成缓冲操作吧。这个chapter大概的意思就是对移动等动作进行封装路线的变化,或者是从原来的在总的持续时间不变的前提下,变成了非匀速的运动。
Actions: Ease

 ease不知道怎么翻译,暂时翻译成缓冲操作吧。这个chapter大概的意思就是对移动等动作进行封装路线的变化,或者是从原来的在总的持续时间不变的前提下,变成了非匀速的运动。需要说名的一点就是,这个wiki里面提到的部分内容,现在最新版本的cocos2d里面已经找不到了,函数的说明变了。。。对于找不到的,暂时不翻译,反正也比较简单,照猫画虎把。哈哈。

 

缓冲操作是一个特殊的复杂操作,可以改变inner 动作的时间。在Flash里面,它们经常被称作Tweening 或者Easing 动作。

它们虽然改变了运动的速度,但是并没有改变总体时间,如果整个的action持续5秒钟,那么整个的时间仍然会持续5秒钟。 

E

The Ease actions alter the linearity of the time.

 

例如它们可以对inner的action进行加速或者是减速。 

这些action可以被分成3类: 

  • In actions: action开始的时候加速
  • Out actions: action结束的时候加速
  • InOut actions: action开始,结束的时候加速

For more information about easing or tweening actions, visit any of these pages:

  • http://hosted.zeh.com.br/tweener/docs/en-us/misc/transitions.html
  • http://www.robertpenner.com/easing/easing_demo.html

Ease actions

这些内部的action是按着如下进行加速的:

-(void) update:(ccTime) t{   [inner update: powf(t,rate)];}

rate 这个参数就是增加的速率

 

以下举了几个例子说明的分别的动作的开始,结束,和开始或者结束的时候加速。 

Example:

// acceleration at the beginning

        id action = [MoveTo actionWithDuration:2 position:ccp(100,100)];

id ease = [EaseIn actionWithAction:action rate:2];

[sprite runAction: ease];

// acceleration at the end

id action = [MoveTo actionWithDuration:2 position:ccp(100,100)];

id ease = [EaseIn actionWithAction:action rate:2];

[sprite runAction: ease];

// acceleration at the beginning / end

id action = [MoveTo actionWithDuration:2 position:ccp(100,100)];

id ease = [EaseInOut actionWithAction:action rate:2];

[sprite runAction: ease];

EaseExponential actions 指数缓冲动作

  • EaseExponentialIn
  • EaseExponentialOut
  • EaseExponentialInOut


EaseSine actions 塞因缓冲

  • EaseSineIn
  • EaseSineOut
  • EaseSineInOut


接下来的几个Ease的action,在最新版本的cocos2d里面找不到了,貌似已经干掉了。不理解了。。可以我从xcode拿出来的code,就知道了,以下的这几个关键字已经不变色了。。

就剩下一个rate的了。

[EaseRateAction actionWithAction:<#(IntervalAction *)action#> rate:<#(float)rate#>]; 

EaseElastic actions 弹性缓冲

These actions alters the time simulating an elastic. Elastic actions will use time values greater than 1 and lower than 0, so the inner action should be prepared to handle this special values.

Also some values will be triggered more than once (this function is not bijective), so again, the inner action should be prepared to handle this values. Simple actions like MoveByScaleByRotateBy work OK with EaseElastic actions, but the Sequence or Spawnactions might have unexpected results.

Available since v0.8.2

Available elastic actions:

  • EaseElasticIn
  • EaseElasticOut
  • EaseElasticInOut

Examples:

 

// 'period' is how elastic is the action.

// recommended values: between 0.3 and 0.45

// Elastic at the beginning

id move = [MoveBy actionWithDuration:3 position:ccp(350,0)];

id action = [EaseElasticIn actionWithAction:move period:0.3f];

[sprite runAction: action];

// Elastic at the end

id move = [MoveBy actionWithDuration:3 position:ccp(350,0)];

id action = [EaseElasticOut actionWithAction:move period:0.3f];

[sprite runAction: action];

// Elastic at the beginning and at the end

id move = [MoveBy actionWithDuration:3 position:ccp(350,0)];

id action = [EaseElasticInOut actionWithAction:move period:0.3f];

[sprite runAction: action];

EaseBounce actions 跳跃缓冲

EaseBounce actions simulates a bouncing effect.

Some time values will be triggered more than once (this function is not bijective), so the inner action should be prepared to handle this values. Simple actions like MoveByScaleByRotateBy work OK with EaseBounce actions, but the Sequence or Spawn actions might have unexpected results.

Available since v0.8.2

Available bounce actions:

  • EaseBounceIn
  • EaseBounceOut
  • EaseBounceInOut

Examples:

 

// Bounce at the beginning

id move = [MoveBy actionWithDuration:3 position:ccp(350,0)];

id action = [EaseBounceIn actionWithAction:move];

[sprite runAction: action];

// Bounce at the end

id move = [MoveBy actionWithDuration:3 position:ccp(350,0)];

id action = [EaseBounceOut actionWithAction:move];

[sprite runAction: action];

// Bounce at the beginning and at the end

id move = [MoveBy actionWithDuration:3 position:ccp(350,0)];

id action = [EaseBounceInOut actionWithAction:move];

[sprite runAction: action];

EaseBack actions

Some time values will be triggered more than once (this function is not bijective), so the inner action should be prepared to handle this values. Simple actions like MoveByScaleByRotateBy work OK with EaseBack actions, but the Sequence or Spawn actions might have unexpected results.

Available since v0.8.2

Available bounce actions:

  • EaseBackIn
  • EaseBackOut
  • EaseBackInOut

Examples:

 

// Back at the beginning

id move = [MoveBy actionWithDuration:3 position:ccp(350,0)];

id action = [EaseBackIn actionWithAction:move];

[sprite runAction: action];

// Back at the end

id move = [MoveBy actionWithDuration:3 position:ccp(350,0)];

id action = [EaseBackOut actionWithAction:move];

[sprite runAction: action];

// Back at the beginning and at the end

id move = [MoveBy actionWithDuration:3 position:ccp(350,0)];

id action = [EaseBackInOut actionWithAction:move];

[sprite runAction: action];

Actions: Speed

Speed action

The Speed action modifies the duration of the inner action.

id move = [MoveBy actionWithDuration:3 position:ccp(350,0)];

id action = [Speed actionWithAction: move speed:1.0f];   // no speed modification

// but you can modify the speed later

[action setSpeed: 2.5f]; // speed is 2.5 faster

[action setSpeed: 0.5f]; // speed is 0.5 faster (it means 2 times slower)



推荐阅读
  • 本文详细介绍了MySQL表分区的创建、增加和删除方法,包括查看分区数据量和全库数据量的方法。欢迎大家阅读并给予点评。 ... [详细]
  • Oracle Database 10g许可授予信息及高级功能详解
    本文介绍了Oracle Database 10g许可授予信息及其中的高级功能,包括数据库优化数据包、SQL访问指导、SQL优化指导、SQL优化集和重组对象。同时提供了详细说明,指导用户在Oracle Database 10g中如何使用这些功能。 ... [详细]
  • [大整数乘法] java代码实现
    本文介绍了使用java代码实现大整数乘法的过程,同时也涉及到大整数加法和大整数减法的计算方法。通过分治算法来提高计算效率,并对算法的时间复杂度进行了研究。详细代码实现请参考文章链接。 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • VScode格式化文档换行或不换行的设置方法
    本文介绍了在VScode中设置格式化文档换行或不换行的方法,包括使用插件和修改settings.json文件的内容。详细步骤为:找到settings.json文件,将其中的代码替换为指定的代码。 ... [详细]
  • Nginx使用(server参数配置)
    本文介绍了Nginx的使用,重点讲解了server参数配置,包括端口号、主机名、根目录等内容。同时,还介绍了Nginx的反向代理功能。 ... [详细]
  • 这是原文链接:sendingformdata许多情况下,我们使用表单发送数据到服务器。服务器处理数据并返回响应给用户。这看起来很简单,但是 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • Windows下配置PHP5.6的方法及注意事项
    本文介绍了在Windows系统下配置PHP5.6的步骤及注意事项,包括下载PHP5.6、解压并配置IIS、添加模块映射、测试等。同时提供了一些常见问题的解决方法,如下载缺失的msvcr110.dll文件等。通过本文的指导,读者可以轻松地在Windows系统下配置PHP5.6,并解决一些常见的配置问题。 ... [详细]
  • Metasploit攻击渗透实践
    本文介绍了Metasploit攻击渗透实践的内容和要求,包括主动攻击、针对浏览器和客户端的攻击,以及成功应用辅助模块的实践过程。其中涉及使用Hydra在不知道密码的情况下攻击metsploit2靶机获取密码,以及攻击浏览器中的tomcat服务的具体步骤。同时还讲解了爆破密码的方法和设置攻击目标主机的相关参数。 ... [详细]
  • baresip android编译、运行教程1语音通话
    本文介绍了如何在安卓平台上编译和运行baresip android,包括下载相关的sdk和ndk,修改ndk路径和输出目录,以及创建一个c++的安卓工程并将目录考到cpp下。详细步骤可参考给出的链接和文档。 ... [详细]
  • 解决VS写C#项目导入MySQL数据源报错“You have a usable connection already”问题的正确方法
    本文介绍了在VS写C#项目导入MySQL数据源时出现报错“You have a usable connection already”的问题,并给出了正确的解决方法。详细描述了问题的出现情况和报错信息,并提供了解决该问题的步骤和注意事项。 ... [详细]
  • 【shell】网络处理:判断IP是否在网段、两个ip是否同网段、IP地址范围、网段包含关系
    本文介绍了使用shell脚本判断IP是否在同一网段、判断IP地址是否在某个范围内、计算IP地址范围、判断网段之间的包含关系的方法和原理。通过对IP和掩码进行与计算,可以判断两个IP是否在同一网段。同时,还提供了一段用于验证IP地址的正则表达式和判断特殊IP地址的方法。 ... [详细]
author-avatar
NE丰胸茶urghx
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有