0

I am a newbie to game development and currently using AndEngine for an android game. It is a right scrolling game where the player can continuously move to right of the screen like mario.

How can we have infinite right scrolling?

Currently, I am setting my boundCamera Limits like this:

 camera.setBounds(0, 0, CAMERA_WIDTH*100,  CAMERA_HEIGHT);

and I create a frame like this:

public void createFrame(){

//  205-175-149     cdaf95
final IAreaShape/*Shape*/ ground = new Rectangle(0, mCameraHeight - 2, mCameraWidth*100, 2, gameLogicController.getVertexBufferObjectManager());
ground.setColor(0.7f, 0.5f, 0.3f);
final IAreaShape/*Shape*/ roof = new Rectangle(0, 0, mCameraWidth*100, 2, gameLogicController.getVertexBufferObjectManager());
roof.setColor(0.7f, 0.5f, 0.3f);
final IAreaShape/*Shape*/ left = new Rectangle(0, 0, 2, mCameraHeight, gameLogicController.getVertexBufferObjectManager());
left.setColor(0.7f, 0.5f, 0.3f);
final IAreaShape/*Shape*/ right = new Rectangle(mCameraWidth*100 - 2, 0, 2, mCameraHeight, gameLogicController.getVertexBufferObjectManager());
right.setColor(0.7f, 0.5f, 0.3f);

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);


scene.attachChild(ground);
scene.attachChild(roof); 
scene.attachChild(left); 
scene.attachChild(right); 

}

But it ends up being fixed width only (100 times camera width). How can I have infinite width? If I give very large value, app crashes.

Thank you for any help..

4

1 回答 1

3

您不希望宽度是无限的,因为那样游戏将永远无法完成加载。与其使用固定的背景,不如让它看起来好像背景在移动。

于 2013-08-23T00:04:52.817 回答