Beginer Developer
Beginer Developer

Reputation: 23

AndEngine Ease Founction

Can someone tell me how to implement ease function in this example: I want to move mySprite to left/right with ease effect.

    public void offsetsChanged(float xOffset, float yOffset, float xOffsetStep,
        float yOffsetStep, int xPixelOffset, int yPixelOffset) {
    if(mCamera != null){
        mCamera.setCenter( (480 * xOffset )+300, mCamera.getCenterY() );

    }

    mySprite.addShapeModifier(new MoveModifier(3,mySprite.getX(),?????????,mySprite.getY(),mySprite.getY(),EaseBackOut.getInstance()));

}

Upvotes: 0

Views: 1506

Answers (1)

Jong
Jong

Reputation: 9125

First of all, update your AndEngine version. There are no ShapeModifiers anymore, they are called EntityModifiers, and the method addShapeModifier doesn't exist. There is a method Camera.offsetCenter(..) so you don't need to do it on your own.

Anyways, when kind of EaseFunction do you want? There are many, and you use it this way (With the most updated MoveModifier class):

mySprite.registerEntityModifier(new MoveModifier(duration, fromX, toX, fromY, toY, easeFunction);

You should run the EaseFunctionExample on your device/emulator, and decide which one you want.

If you want to move mySprite on the X axis, you could do:

mySprite.registerEntityModifier(new MoveXModifier(duration, mySprite.getX(), toX, easeFunction);

Upvotes: 1

Related Questions