Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why physics body automatically moves upwards in andengine gles2 anchor center live wallpaper

I am trying to develop a live wallpaper using andengine gles2 anchor center , with some physics.But when i add a physics object it was moving upwards.instead of moving downward due to gravity
what are the mistakes i am making please help me to sort out the issue

Here is my code

FixtureDef FIXTURE_DEF = PhysicsFactory.createFixtureDef(1, 0.5f,
                0.5f);
mPhysicsWorld = new PhysicsWorld(new Vector2(0,
                        SensorManager.GRAVITY_EARTH), false);
final AnimatedSprite animatedSprite;
animatedSprite = new AnimatedSprite(500, 250,
                        this.mBoxFaceTextureRegion, this.getVertexBufferObjectManager());

body = PhysicsFactory.createBoxBody(this.mPhysicsWorld, animatedSprite,
                        BodyType.DynamicBody, FIXTURE_DEF);

scene.attachChild(animatedSprite);
animatedSprite.animate(200);
mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(
                        animatedSprite, body, true, true));
like image 671
Renjith K N Avatar asked Jan 23 '26 15:01

Renjith K N


1 Answers

Just multiply SensorManager.GRAVITY_EARTH by -1.

like image 171
David Avatar answered Jan 26 '26 08:01

David



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!