31
Graphics / Getting the camera to follow a sprite.
« on: September 06, 2009, 04:06:02 pm »
i am not sure if i understood your problem.
imagine the view as a camera and the sprites as what the camera is pointed at - the world.
so if you move your view (your camera) but not the sprites (your objects in the world), like the background, the background image will move out of your view, as it is not moved.
if you want you background be drawn as some kind of screen background, you'll have to reposition it also on every frame, following the player or the camera.
if you want the background to stay in place (as in falling out of the view), you should call Window.Clear(); before the drawing commands, as the screen is not cleared automatically on redraw.
imagine the view as a camera and the sprites as what the camera is pointed at - the world.
so if you move your view (your camera) but not the sprites (your objects in the world), like the background, the background image will move out of your view, as it is not moved.
if you want you background be drawn as some kind of screen background, you'll have to reposition it also on every frame, following the player or the camera.
if you want the background to stay in place (as in falling out of the view), you should call Window.Clear(); before the drawing commands, as the screen is not cleared automatically on redraw.