Reputation: 1377
I want to move sprite on yaxis with some a consistent speed current I am doing just decrement from height of screen to 0 with a constant value. here is the code
this.engine.registerDrawHandler(new IDrawHandler() {
@Override
public void onDraw(GLState pGLState, Camera pCamera) {
ballon.setpostiton(ballon.getX(), ballon.getY() - 1);
}
});
But I am not getting consistent when I move my code to different sprite. On small device its ends earlier as compared to large resolution devices and on this more I have passed FillResolutionPolicy in my andengine option.
Please tell me a consistent way to move sprite in Andengine.
Upvotes: 4
Views: 5492
Reputation: 192
MoveXModifier mod1=new MoveXModifier(constanttime,fromX,toX);
sprite.registerEntityModifier(mod1);
Use this modifier for x movement.
MoveYModifier mod1=new MoveYModifier(constanttime,fromY,toY);
sprite.registerEntityModifier(mod1);
Use this modifier for Y movement.
MoveModifier mod1=new MoveModifier(constanttime,fromX,toX,fromY,toY);
sprite.registerEntityModifier(mod1);
Use this modifier for X and Y movement.
Upvotes: 9
Reputation: 153
You might have a look onto AndEngine Examples - especially the Moving Ball Example should be interesting for you. You can also download the AndEngineExamples from the Play Store to see what they do.
Upvotes: 5