减速(Easing)
Easing用一个给定的加速度来使动画更加顺畅。需要记住的是,无论速度快慢,ease动作总是同时开始和结束。在游戏中如果你想模拟一些物理特效,但又不想过度且麻烦地使用多个非常基本的动作,那么此时Ease动作将是模拟物理特效的一个很好的方法。这里有另一个给菜单和按钮添加动画的很好的例子。
下图显示了一些常用的减速功能:

Cocos2d-x支持上图中所显示的大部分减速功能。这些功能也是容易实现的。让我们一起看看一个特殊的用例。屏幕的上方添加一个Sprite对象,并使其上下跳动。
//
create a spriteauto
mySprite = Sprite::create("mysprite.png");//
create a MoveBy Action to where we want the sprite to drop from.auto
move = MoveBy::create(2, Vec2(200, dirs->getVisibleSize().height - newSprite2->getContentSize().height));auto
move_back = move->reverse();//
create a BounceIn Ease Actionauto
move_ease_in = EaseBounceIn::create(move->clone() );//
create a delay that is run in between sequence eventsauto
delay = DelayTime::create(0.25f);//
create the sequence of actions, in the order we want to run themauto
seq1 = Sequence::create(move_ease_in, delay, move_ease_in_back, delay->clone(),
nullptr);//
run the sequence and repeat forever.mySprite->runAction(RepeatForever::create(seq1));
本文介绍如何在Cocos2d-x中使用Ease动画功能,通过实例演示了如何创建上下跳动的精灵对象,并利用EaseBounceIn平滑过渡效果实现自然的物理动画。适用于希望为游戏增加真实感的开发者。
884

被折叠的 条评论
为什么被折叠?



