我是游戏开发的新手,目前正在使用AndEngine进行安卓游戏。这是一个右滚动游戏,玩家可以像马里奥一样连续移动到屏幕右侧。
我们怎样才能有无限的右滚动?
目前,我正在设置我的boundCamera限制:
camera.setBounds(0, 0, CAMERA_WIDTH*100, CAMERA_HEIGHT);
我创建了一个这样的框架:
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);
}
但它最终只是固定宽度(相机宽度的100倍)。我怎么能有无限宽度?如果我给予非常大的价值,应用程序崩溃。
感谢您的帮助..
答案 0 :(得分:3)
你不希望宽度是无限的,因为游戏永远不会完成加载。而不是固定背景操纵它看起来好像背景正在移动。