How do I scroll in the physical world?

Posted by Esteban Quintero on Game Development See other posts from Game Development or by Esteban Quintero
Published on 2012-04-08T14:56:24Z Indexed on 2012/04/13 17:43 UTC
Read the original article Hit count: 273

Filed under:

I am using andengine to make a game where a sprite (player) is going up across the stage, this is my world.

final Rectangle ground = new Rectangle(0, CAMERA_HEIGHT - 2, CAMERA_WIDTH, 2, vertexBufferObjectManager);
final Rectangle roof = new Rectangle(0, 0, CAMERA_WIDTH, 2, vertexBufferObjectManager);
final Rectangle left = new Rectangle(0, 0, 2, CAMERA_HEIGHT, vertexBufferObjectManager);
final Rectangle right = new Rectangle(CAMERA_WIDTH - 2, 0, 2, CAMERA_HEIGHT, vertexBufferObjectManager);

final FixtureDef wallFixtureDef = PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, ground, BodyType.StaticBody, wallFixtureDef);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, roof, BodyType.StaticBody, wallFixtureDef);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, left, BodyType.StaticBody, wallFixtureDef);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, right, BodyType.StaticBody, wallFixtureDef);

/* Create two sprits and add it to the scene. */

this.mScene.setBackground(autoParallaxBackground);

this.mScene.attachChild(ground);
this.mScene.attachChild(roof);
this.mScene.attachChild(left);
this.mScene.attachChild(right);

this.mScene.registerUpdateHandler(this.mPhysicsWorld);

The problem is that if the sprite reaches up and hits the wall, as I scroll here?

© Game Development or respective owner

Related posts about andengine