All examples · Sprites and 2D

Camera follow

What this example shows

useCamera2d() gives the scene a camera, and from then on every position is a place in a world that can be bigger than the screen. The camera's x and y are the world point at the screen's top-left corner.

So following the player means subtracting half the screen: the player stays in the middle while the marker grid scrolls underneath.

Starting