All examples · Sprites and 2D · As Markdown, for AIs

Platformer camera and parallax

What this example shows

useCameraFollow keeps the hero in view: a dead zone in the middle (the white frame) that the hero walks inside without the camera moving, never past the edges of the map (bounds: map), on whole pixels. shake makes it tremble, and dies away on its own.

Behind the level, createBackdrop lays clouds and hills endlessly across the world, each moving with the camera only so much (parallax): a tenth for the clouds, four tenths for the hills. The brick wall is a single frame of the tile sheet repeated across one sprite (tile: true).

← → walk, Z jump, X shake.

Starting
Starting
—