private void addRectangleWithTension(final Scene pScene, final float pTension, float pDelay) { final Rectangle rectangle = new Rectangle(-SIZE, -SIZE, SIZE, SIZE, this.getVertexBufferObjectManager()); rectangle.setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE); if (pTension < 0) { rectangle.setColor(1 - pTension, 0, 0, 0.5f); } else { rectangle.setColor(pTension, 0, 0, 0.5f); } final CardinalSplineMoveModifierConfig catmullRomMoveModifierConfig1 = new CardinalSplineMoveModifierConfig( CardinalSplineMoveModifierExample.CONTROLPOINT_1_XS.length, pTension); final CardinalSplineMoveModifierConfig catmullRomMoveModifierConfig2 = new CardinalSplineMoveModifierConfig( CardinalSplineMoveModifierExample.CONTROLPOINT_1_XS.length, pTension); for (int i = 0; i < CardinalSplineMoveModifierExample.CONTROLPOINT_1_XS.length; i++) { catmullRomMoveModifierConfig1.setControlPoint( i, CardinalSplineMoveModifierExample.CONTROLPOINT_1_XS[i] - SIZE / 2, CardinalSplineMoveModifierExample.CONTROLPOINT_YS[i] - SIZE / 2); catmullRomMoveModifierConfig2.setControlPoint( i, CardinalSplineMoveModifierExample.CONTROLPOINT_2_XS[i] - SIZE / 2, CardinalSplineMoveModifierExample.CONTROLPOINT_YS[i] - SIZE / 2); } rectangle.registerEntityModifier( new SequenceEntityModifier( new DelayModifier(pDelay), new LoopEntityModifier( new SequenceEntityModifier( new ParallelEntityModifier( new CardinalSplineMoveModifier( CardinalSplineMoveModifierExample.DURATION, catmullRomMoveModifierConfig1, EaseLinear.getInstance()), new RotationModifier( CardinalSplineMoveModifierExample.DURATION, -45, -315)), new ParallelEntityModifier( new CardinalSplineMoveModifier( CardinalSplineMoveModifierExample.DURATION, catmullRomMoveModifierConfig2, EaseLinear.getInstance()), new RotationModifier( CardinalSplineMoveModifierExample.DURATION, 45, 315)))))); pScene.attachChild(rectangle); }
public MoveXModifier( final float pDuration, final float pFromX, final float pToX, final IEntityModifierListener pEntityModifierListener) { super(pDuration, pFromX, pToX, pEntityModifierListener, EaseLinear.getInstance()); }
public static IEntityModifier LevelOnePath() { final Path path = new Path(5) .to(10, 10) .to(10, CAMERA_HEIGHT - 74) .to(CAMERA_WIDTH - 58, CAMERA_HEIGHT - 74) .to(CAMERA_WIDTH - 58, 10) .to(10, 10); return ((new PathModifier(30, path, EaseLinear.getInstance()))); }
public MoveXModifier(final float pDuration, final float pFromX, final float pToX) { this(pDuration, pFromX, pToX, null, EaseLinear.getInstance()); }
/** * (c) 2010 Nicolas Gramlich (c) 2011 Zynga Inc. * * @author Nicolas Gramlich * @since 11:04:35 - 02.04.2010 */ public class SlideMenuSceneAnimator extends MenuSceneAnimator { // =========================================================== // Constants // =========================================================== private static final float DURATION = 1.0f; private static final IEaseFunction EASEFUNCTION_DEFAULT = EaseLinear.getInstance(); private static final Direction DIRECTION_DEFAULT = Direction.RIGHT; // =========================================================== // Fields // =========================================================== private IEaseFunction mEaseFunction; private Direction mDirection; // =========================================================== // Constructors // =========================================================== public SlideMenuSceneAnimator() { this(SlideMenuSceneAnimator.DIRECTION_DEFAULT, SlideMenuSceneAnimator.EASEFUNCTION_DEFAULT); } public SlideMenuSceneAnimator(final IEaseFunction pEaseFunction) { this(SlideMenuSceneAnimator.DIRECTION_DEFAULT, pEaseFunction); } public SlideMenuSceneAnimator(final Direction pDirection) { this(pDirection, SlideMenuSceneAnimator.EASEFUNCTION_DEFAULT); } public SlideMenuSceneAnimator(final Direction pDirection, final IEaseFunction pEaseFunction) { super(); this.mDirection = pDirection; this.mEaseFunction = pEaseFunction; } public SlideMenuSceneAnimator( final HorizontalAlign pHorizontalAlign, final VerticalAlign pVerticalAlign) { this( pHorizontalAlign, pVerticalAlign, SlideMenuSceneAnimator.DIRECTION_DEFAULT, SlideMenuSceneAnimator.EASEFUNCTION_DEFAULT); } public SlideMenuSceneAnimator( final HorizontalAlign pHorizontalAlign, final VerticalAlign pVerticalAlign, final IEaseFunction pEaseFunction) { this(pHorizontalAlign, pVerticalAlign, SlideMenuSceneAnimator.DIRECTION_DEFAULT, pEaseFunction); } public SlideMenuSceneAnimator( final HorizontalAlign pHorizontalAlign, final VerticalAlign pVerticalAlign, final Direction pDirection) { this(pHorizontalAlign, pVerticalAlign, pDirection, SlideMenuSceneAnimator.EASEFUNCTION_DEFAULT); } public SlideMenuSceneAnimator( final HorizontalAlign pHorizontalAlign, final VerticalAlign pVerticalAlign, final Direction pDirection, final IEaseFunction pEaseFunction) { super(pHorizontalAlign, pVerticalAlign); this.mDirection = pDirection; this.mEaseFunction = pEaseFunction; } // =========================================================== // Getter & Setter // =========================================================== public IEaseFunction getEaseFunction() { return this.mEaseFunction; } public void setEaseFunction(final IEaseFunction pEaseFunction) { this.mEaseFunction = pEaseFunction; } public Direction getDirection() { return this.mDirection; } public void setDirection(final Direction pDirection) { this.mDirection = pDirection; } // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected void onMenuItemPositionBuilt( final MenuScene pMenuScene, final int pIndex, final IMenuItem pMenuItem, final float pX, final float pY) { final float fromX = getFromX(pMenuScene, pMenuItem, pX); final float fromY = getFromY(pMenuScene, pMenuItem, pY); pMenuItem.setPosition(fromX, fromY); final MoveModifier moveModifier = new MoveModifier(SlideMenuSceneAnimator.DURATION, fromX, fromY, pX, pY, this.mEaseFunction); moveModifier.setAutoUnregisterWhenFinished(false); pMenuItem.registerEntityModifier(moveModifier); } @Override protected void onMenuItemPositionReset( final MenuScene pMenuScene, final int pIndex, final IMenuItem pMenuItem, final float pX, final float pY) { final float fromX = getFromX(pMenuScene, pMenuItem, pX); final float fromY = getFromY(pMenuScene, pMenuItem, pY); pMenuItem.setPosition(fromX, fromY); pMenuItem.resetEntityModifiers(); } // =========================================================== // Methods // =========================================================== protected float getFromX(final MenuScene pMenuScene, final IMenuItem pMenuItem, final float pX) { switch (this.mDirection) { case UP: case DOWN: return pX; case DOWN_LEFT: case UP_LEFT: case LEFT: return pMenuScene.getWidth() + (pMenuItem.getWidth() * 0.5f); case DOWN_RIGHT: case UP_RIGHT: case RIGHT: return -(pMenuItem.getWidth() * 0.5f); default: throw new IllegalArgumentException(); } } protected float getFromY(final MenuScene pMenuScene, final IMenuItem pMenuItem, final float pY) { switch (this.mDirection) { case DOWN_LEFT: case DOWN: case DOWN_RIGHT: return pMenuScene.getHeight() + (pMenuItem.getHeight() * 0.5f); case LEFT: case RIGHT: return pY; case UP_LEFT: case UP: case UP_RIGHT: return -(pMenuItem.getHeight() * 0.5f); default: throw new IllegalArgumentException(); } } // =========================================================== // Inner and Anonymous Classes // =========================================================== }