8.【cocos2d翻译系列】Actions, Transformations and Effects--Ease actions
来源:互联网 发布:知乎 紫微斗数网站 编辑:程序博客网 时间:2024/05/20 20:47
Ease actions
Actions:Ease(缓和)
Ease 动作是一个特殊的动作,它会修改action的时间。在flash里他经常被叫做Tweening或者Easing action。
这种action修改actions的速度,但是不会修改总的运行时间。如果原来action持续5秒,那么修改后总的时间仍然持续5秒。
Ease action修改线性的时间。
例如它可以加速或减速动作的速度。
这些actions可以分为3类:
- In actions:在动作的开始加速
- Out actions:在动作的末尾加速。
- InOut actions:在动作的开头和末尾都加速。
想要了解更多Easing 或者Tweening 动作,访问下面任何一个页面:
- 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)];
}
变种:
- CCEaseIn:在开始处加速
- CCEaseOut:在结尾处加速
- CCEaseInOut:在开头和结尾处加速
参数rate表明了加速度比例。
例如:
// acceleration at the beginning
id action= [CCMoveTo actionWithDuration:2 position:ccp(100,100)];
id ease= [CCEaseIn actionWithAction:action rate:2];
[sprite runAction:ease];
// acceleration at the end
id action= [CCMoveTo actionWithDuration:2 position:ccp(100,100)];
id ease= [CCEaseOut actionWithAction:action rate:2];
[sprite runAction:ease];
// acceleration at the beginning / end
id action= [CCMoveTo actionWithDuration:2 position:ccp(100,100)];
id ease= [CCEaseInOut actionWithAction:action rate:2];
[sprite runAction:ease];
EaseExponential actions
可用的指数的动作:
- CCEaseExponentialIn
- CCEaseExponentialOut
- CCEaseExponentialInOut
例如:
id scaleAction = [CCScaleTo actionWithDuration:2.5 scale:.8];
id easeAction =[CCEaseExponentialIn actionWithAction:scaleAction];
[label runAction:easeAction];
EaseSine actions
可用的正弦动作:
- CCEaseSineIn
- CCEaseSineOut
- CCEaseSineInOut
例如:
// Sine at the beginning
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseSineIn actionWithAction:move];
[spriterunAction:action];
// Sine at the end
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseSineOut actionWithAction:move];
[sprite runAction:action];
// Sine at the beginning and at theend
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseSineInOut actionWithAction:move];
[sprite runAction:action];
EaseElastic actions
这种动作模拟弹性的变化修改时间,将会使用的大于1和小于0的时间值,所以内部的动作要做好准备处理特殊的值。
一些值将会被触发好几次,所以,内部动作要准备好处理这些值。简单地action像:CCMoveBy,CCScaleBy,CCRotateBy和EaseElastic动作搭配的很好,但是像CCSequence或者CCSpawn动作他们的结果是不可预料的。
可用的动作:
- CCEaseElasticIn
- CCEaseElasticOut
- CCEaseElasticInOut
例子;
// 'period' is how elastic is the action.
// recommended values: between 0.3 and 0.45
// Elastic at the beginning
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseElasticIn actionWithAction:move period:0.3f];
[sprite runAction:action];
// Elastic at the end
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseElasticOut actionWithAction:move period:0.3f];
[sprite runAction:action];
// Elastic at the beginning and atthe end
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseElasticInOut actionWithAction:move period:0.3f];
[sprite runAction:action];
EaseBounce actions
EaseBounce动作模拟弹跳的动作特效。
一些值将会被触发好几次,所以,内部动作要准备好处理这些值。简单地action像:CCMoveBy,CCScaleBy,CCRotateBy和EaseElastic动作搭配的很好,但是像CCSequence或者CCSpawn动作他们的结果是不可预料的。
可用动作:
- CCEaseBounceIn
- CCEaseBounceOut
- CCEaseBounceInOut
例如:
// Bounce at the beginning
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseBounceIn actionWithAction:move];
[spriterunAction:action];
// Bounce at the end
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseBounceOut actionWithAction:move];
[spriterunAction:action];
// Bounce at the beginning and atthe end
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseBounceInOut actionWithAction:move]
; [spriterunAction:action];
EaseBack actions
一些值将会被触发好几次,所以,内部动作要准备好处理这些值。简单地action像:CCMoveBy,CCScaleBy,CCRotateBy和EaseElastic动作搭配的很好,但是像CCSequence或者CCSpawn动作他们的结果是不可预料的。
可用的动作:
- CCEaseBackIn
- CCEaseBackOut
- CCEaseBackInOut
例子:
// Back at the beginning
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseBackIn actionWithAction:move];
[sprite runAction:action];
// Back at the end
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseBackOut actionWithAction:move];
[spriterunAction:action];
// Back at the beginning and at theend
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCEaseBackInOut actionWithAction:move];
[spriterunAction:action];
Actions: Speed
Speed action(速度动作)
The CCSpeedaction modifies the duration of the inner action.
CCSpeed动作修改内部动作的持续时间。
id move= [CCMoveBy actionWithDuration:3 position:ccp(350,0)];
id action= [CCSpeed actionWithAction:move speed:1.0f];// no speed modification
// but you can modify the speedlater [action setSpeed:2.5f];// speed is 2.5 faster
[action setSpeed:0.5f];// speed is 0.5 faster (it means 2times slower)
- 8.【cocos2d翻译系列】Actions, Transformations and Effects--Ease actions
- 7.【cocos2d翻译系列】Actions, Transformations and Effects--Composition actions
- 9.【cocos2d翻译系列】Actions, Transformations and Effects--Effect actions
- 10.【cocos2d翻译系列】Actions, Transformations and Effects--Special actions
- 11.【cocos2d翻译系列】Actions, Transformations and Effects--Animation
- 6.【cocos2d翻译系列】Basic actions
- Spark RDD Actions&Transformations
- Actions, Controllers and Results(翻译)
- actions
- Actions
- Actions
- Actions
- Actions
- Actions
- cocos2d的常用动作及效果总结之三:Ease actions
- cocos2d的常用动作及效果总结之三:Ease actions
- cocos2d-x:动作 Actions
- Spark的transformations和actions操作解释
- 调用其它app中的Service
- 客户端使用自定义代理类访问WCF服务
- Windows Azure Service Bus 推动财务服务门户的高可用性和可伸缩性
- struts与spring的整合
- Element类
- 8.【cocos2d翻译系列】Actions, Transformations and Effects--Ease actions
- @Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction区别
- C语言-Socket地址的转换方式
- Android自定义shape的使用
- MySQL源代码:从SQL语句到MySQL内部对象
- Eclipse中package,source folder,folder区别及相互转换
- IOS 地图相关知识点
- SQL Server: 利用 SET STATISTICS IO 和 SET STATISTICS TIME 对T-SQL语句进行性能分析
- Socket 通信原理(Android客户端和服务器以TCP&&UDP方式互通)