Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move sprite in Andengine

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.

like image 758
mfq Avatar asked Dec 08 '22 13:12

mfq


2 Answers

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.

like image 86
Kiran ZabuzaLabs Avatar answered Dec 27 '22 02:12

Kiran ZabuzaLabs


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.

like image 20
nidhoeggr09 Avatar answered Dec 27 '22 03:12

nidhoeggr09