cocos2d-基本概念(3)-Actions: Ease 缓冲动作
2010-01-24 19:03
549 查看
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 MoveBy, ScaleBy, RotateBy work OK with
EaseElasticactions, 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 MoveBy, ScaleBy, RotateBy work OK with
EaseBounceactions, 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 MoveBy, ScaleBy, RotateBy work OK with
EaseBackactions, 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
TheSpeedaction 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)
相关文章推荐
- cocos2d-基本概念(1)-Basic actions基本动作
- cocos2d-基本概念(2)-Composition Actions 复杂动作
- cocos2d-x 基本概念 动作 Action
- cocos2d的常用动作及效果总结之三:Ease actions
- cocos2d入门教程2:基本概念Actions
- [Cocos2d-x For WP8]EaseActions缓动动作
- cocos2d-x开发记录:二,基本概念(动作,动画,坐标系统)
- Cocos2d-x学习笔记(十九)之 缓冲动作
- cocos2d-x基本知识点(6)---动作系列(end)
- cocos2d-x for wp之EaseActions——运动加速效果
- iPhone开发之游戏篇(1) --- cocos2d的基本概念
- 【cocos2d-x】动作类之缓冲动作和组合动作的使用(变速动作)
- Cocos2d-x基本动作
- cocos2d-x基本概念
- cocos2d-x基本知识点(6)---动作系列(上)
- cocos2d-x基本知识点(6)---动作系列(下)
- cocos2d学习教程1:cocos2d基本概念
- Cocos2d-X学习笔记《04》—— 基本概念
- Cocos2D的4个基本概念
- 撸到猴年马月之保卫萝卜(一)cocos2d-x 基本概念