0

i just started a side-scrolling game with andengine using xml-levels and box2d.

does anyone know how get the level scrolling when i move the player, so that the player stays in the center of the screen?

thx

blub
  • 21
  • 2

1 Answers1

1

Use the method Camera.setChaseEntity (With your player object).

Jong
  • 9,045
  • 3
  • 34
  • 66
  • i tried this already. does not seem to work. first problem is, that i have a black gap on the left side and second the camera does not move. – blub Nov 21 '12 at 12:04
  • `setChaseEntity` is the way to do it. If it doesn't work, it has to be a problem in your code. Please post it – Jong Nov 21 '12 at 12:48
  • ist okay. thx. I got it working with myCamera.setCenter(mySprite.getX(),mySprite.getY()); – blub Nov 21 '12 at 15:03
  • That's exactly what `setChaseEntity` does. Every loop of the update thread it repositions the camera center to be the entity's coordinates. – Jong Nov 21 '12 at 16:47