Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a 2D shooter using AndEngine. At the moment I'm trying to make the camera follow the player. As I've understood the common approach is to use the SmoothCamera zooming it and setting the chased entity. The problem is that the camera follows the player WITH background moving also (RepeatingSpriteBackground), so it looks like the player doesn't move at all though the actual position changes. So I don't really get how to make the camera follow the player and have the background not moving. Thanks in advance.

share|improve this question
up vote 0 down vote accepted

Simplest approach would be to put the player sprite in a container at center of the container (X:0, y:0), and if he gets some speed, move him away from the center on distance equal to his speed. For example if you move right, you would first gain vx = 0.1 and move him to x:0.1 in the container, then vx = 2 and his distance would be 2 pixels on right from center of the container, and in the end when he's running vx = 10, he would be 10 pixels away from center. If the player character changes his speed smoothly, this will grant you a smooth camera follow effect.

You could multiply velocities by a constant value to make the effect stronger.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.