首页 > 代码库 > OGEngine使用Modifier修改动画

OGEngine使用Modifier修改动画

动画修改器(modifier)有很多种,常用的有一下几种:
1.AlphaModifier:透明度修改器,有以下几种构造:

  1. <font color="#000"><font face="Arial">public AlphaModifier(final float pDuration, final float pFromAlpha, final float pToAlpha) {

  2.                 this(pDuration, pFromAlpha, pToAlpha, null, EaseLinear.getInstance());

  3.         }


  4.         public AlphaModifier(final float pDuration, final float pFromAlpha, final float pToAlpha, final IEaseFunction pEaseFunction) {

  5.                 this(pDuration, pFromAlpha, pToAlpha, null, pEaseFunction);

  6.         }


  7.         public AlphaMod</font></font>ifier(final float pDu<font color="#000"><font face="Arial">ration, final float pFromAlpha, final float pToAlpha, final IEntityModifierListener pEntityModifierListener) {

  8.                 super(pDuration, pFromAlpha, pToAlpha, pEntityModifierListener, EaseLinear.getInstance());

  9.         }


  10.         public AlphaModifier(final float pDuration, final float pFromAlpha, final float pToAlpha, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) {

  11.                 super(pDuration, pFromAlpha, pToAlpha, pEntityModifierListener, pEaseFunction);

  12.         }


  13.         protected AlphaModifier(final AlphaModifier pAlphaModifier) {

  14.                 super(pAlphaModifier);

  15.         }</font></font>

复制代码

pDuration代表动画修改周期,就是就是完成整个透明度变化所要的时间,单位为秒.
pFromAlpha代表起始透明度
pToAlpha代表目标透明度


2.ScaleModifier,比例修改器.主要是对动画的大小比例进行修改:

  1. public ScaleModifier(final float pDuration, final float pFromScale, final float pToScale) {

  2.                 this(pDuration, pFromScale, pToScale, null, EaseLinear.getInstance());

  3.         }


  4.         public ScaleModifier(final float pDuration, final float pFromScale, final float pToScale, final IEaseFunction pEaseFunction) {

  5.                 this(pDuration, pFromScale, pToScale, null, pEaseFunction);

  6.         }


  7.         public ScaleModifier(final float pDuration, final float pFromScale, final float pToScale, final IEntityModifierListener pEntityModifierListener) {

  8.                 this(pDuration, pFromScale, pToScale, pFromScale, pToScale, pEntityModifierListener, EaseLinear.getInstance());

  9.         }


  10.         public ScaleModifier(final float pDuration, final float pFromScale, final float pToScale, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) {

  11.                 this(pDuration, pFromScale, pToScale, pFromScale, pToScale, pEntityModifierListener, pEaseFunction);

  12.         }


  13.         public ScaleModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY) {

  14.                 this(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, null, EaseLinear.getInstance());

  15.         }


  16.         public ScaleModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final IEaseFunction pEaseFunction) {

  17.                 this(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, null, pEaseFunction);

  18.         }


  19.         public ScaleModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final IEntityModifierListener pEntityModifierListener) {

  20.                 super(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, pEntityModifierListener, EaseLinear.getInstance());

  21.         }


  22.         public ScaleModifier(final float pDuration, final float pFromScaleX, final float pToScaleX, final float pFromScaleY, final float pToScaleY, final IEntityModifierListener pEntityModifierListener, final IEaseFunction pEaseFunction) {

  23.                 super(pDuration, pFromScaleX, pToScaleX, pFromScaleY, pToScaleY, pEntityModifierListener, pEaseFunction);

  24.         }


  25.         protected ScaleModifier(final ScaleModifier pScaleModifier) {

  26.                 super(pScaleModifier);

  27.         }

复制代码

pDuration代表动画修改周期,就是就是完成整个变化所要的时间,单位为秒.
pFromScale代表起始透大小比例
pToScale代表目标大小比例

3.位置相关的Modifier:
    MoveModifier(final float pDuration ,final float pFromX,final float pToX,final float pFromY,final float pToY,final IEntityModifierListener pEntityModifierListener,final IEaseFunction pEaseFunction
红色为可选参数,表示修改器的完成时的监听回调和缓动函数

    pDuration为移动所持续的秒数。

    除此之外,还有MoveXModifier(...),及MoveYModifier(...),顾名思义,当实体只要在一个正交方向上移动时可以使用。


4.延迟相关的Modifier:
    DelayModifier(final float pDurationfinal IEntityModifierListener pEntityModifierListener
    pDuration为延迟的时间, pEntityModifierListener会在延迟动作完成时回调。


5.旋转相关的Modifier:
    RotationModifier(float pDuration, float pFromRotation, float pToRotation)
    R otationAtModifie(...)

6.透明度相关的Modifier:
    AlphaModifier(float pDuration, float pFromAlpha, float pToAlpha)

7.颜色相关的Modifier:
    ColorModofier(....)

8.Modifier的组合
    有时候,仅仅一种效果是不够用的。此时,就需要构建一系列的Modifier组合来改变。

    ParallelEntityModifier:当需要对某个Entity同时应用两个以上Modifier时使用
    ParallelEntityModifier(IEntityModifier... pEntityModifiers) 

    SequenceEntityModifier:当需要对某个Entity顺序地应用两个以上Modfier时使用
    SequenceEntityModifier(IEntityModifier... pEntityModifiers)

http://www.eoeandroid.com/forum-863-1.html

www.ogengine.com