What it does
Each layer is a grid of cells, and a cell may hold one star. A hash of the cell decides whether it does, where the star sits, how bright it is and when it twinkles, so nothing is stored and the field goes on for ever. The layers move at 0.15, 0.40 and 0.65 of the camera's movement, so far stars barely shift while near ones slide past.
Most stars hold steady with a faint shimmer and a few glint, each on its own phase, so the sky never pulses in unison.
drift adds a constant sideways scroll, faster for nearer layers, for a screen whose camera never moves. Stars keep
their size and density on a high-density display.
Features
- Three depth layers — each with its own cell size, star size and parallax rate.
- Endless and repeatable — placed by a hash, so it never runs out and looks the same every run.
- Natural twinkle — a steady shimmer with occasional glints; 0 is still, higher is faster and stronger.
- Density — from sparse (0.3) to busy (2), or empty at 0.
- Drift — a constant sideways scroll, either way, for a still camera.
- One tint — the star colour, whose alpha fades the whole field.
Good for
- Space shooters — horizontal and vertical scrollers where depth comes from parallax.
- Fixed-screen shooters and menus —
driftkeeps the stars moving when the camera does not. - Night skies — over a sky gradient above a platformer.
- Cockpits and starship bridges — a field behind the window.
Make it yours
A busy, fast-twinkling white field drifting left behind a menu is one setting; a sparse, steady, warm field over a navy sky for a platformer's night is another. For warm and cool stars together, stack two fields with different tints and densities.
A quick look
const stars = game.backdrop.add('stars', { density: 1, twinkle: 1, drift: 0.2 }, { tint: '#cfe6ff' });
stars.set('twinkle', 3); // live
stars.setColor('tint', '#ffe9c4'); // live
Works with
backdrops— the runtime; required.backdrop-skyandbackdrop-nebula— the layers to put under it.rig-follow— the camera whose movement drives the parallax.backdrop-trippatron— has a reactive starfield style of its own, for psychedelic arenas.
Good to know
- Parallax follows the camera only: with a still camera and
driftat 0 the field is a still image. - All stars share one colour; stack two fields for a mix.
- Each layer checks a cell's neighbours for every pixel: cheap, but not free on a phone at high resolution.






