Reputation: 23
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
Reputation: 9125
First of all, update your AndEngine version. There are no ShapeModifier
s anymore, they are called EntityModifier
s, 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