What it does
shake jitters the camera by up to a given power and lets it fall away over a duration, linearly, with a strong
start and a long tail, or at full strength until it stops. It can shake both axes, one axis or along a single
direction, which makes a knock that pushes the view the way the bullet was going. A frequency turns the per-step buzz
into a slower rumble, and a roll also tips the view by a few degrees while the HUD stays level.
addTrauma is for impacts that pile up. Each knock adds to a meter between 0 and 1, the shake follows the meter
raised to a power so small knocks stay small and big ones jolt, and the meter drains by itself. Three quick hits shake
harder than one, and a chain of explosions builds instead of each replacing the last.
The rest are timing and framing. flash washes the whole screen in a colour and fades it out. hitstop freezes the
game's clock for a few frames of real time, so a heavy hit lands with a pause. slowMotion runs the game at a
fraction of its speed for a moment and eases back. zoomPunch kicks the camera in and eases out. In a 3D world the
shake becomes a small turn of the look and the punch a narrower lens, because sliding a 3D eye sideways would move the
whole scene instead of reading as a knock. The jitter comes from the game's seeded random stream, so it repeats on
every replay, and everything resets when the scene exits.
Features
- Camera shake — power, duration and decay, on both axes, one axis or one direction, as a buzz or a rumble.
- Rotational shake —
rolltips the view by up to 30 degrees while the HUD stays level, in 2D and 3D. - Trauma —
addTraumabuilds a meter that drives its own shake and drains, so repeated knocks accumulate. - Screen flash —
flashwith a colour, duration and opacity, following a resized screen. - Hit-stop —
hitstopfreezes the simulation for a few frames of wall time, with overlapping calls taking the longer. - Slow motion —
slowMotionat a scale for a time, easing back, with a hit-stop able to freeze on top. - Zoom punch —
zoomPunchkicks in by a fraction and eases back. - Replay-safe — shake and punch write only render offsets, and the jitter is seeded.
- 2D and 3D — the same calls work in a 2D world and in
world-3d.
Good for
- Shooters — a directional knock on every hit and trauma that builds under heavy fire.
- Brawlers and fighting games — a hit-stop and a flash on every heavy blow.
- Platformers — a short shake and a tipped view on a heavy landing or a boss stomp.
- Breakout and arcade games — a small punch and shake when a brick or an asteroid breaks.
- Boss defeats and finales — a hit-stop, slow motion, a warm flash and a zoom punch together.
- Pickups and power-ups — a quick flash and zoom to mark the moment.
Make it yours
Each call takes its own strength and timing, and shake takes an axis, a direction, a decay, a frequency and a roll.
The pack's options set the default decay for shakes, and tune trauma: its power at full strength, how fast it drains,
the exponent that keeps small knocks small, its frequency and how far it tips the view.
Two very different feels: a twin-stick shooter where every bullet hit is a tiny shake in the bullet's direction and every explosion adds trauma, so a big fight rattles the screen and calms the moment it ends; and a slow, heavy platformer with a low-frequency rumble on each landing, a tipped view when the boss stomps, and a hit-stop, slow motion and flash when it falls.
A quick look
A knock in the bullet's direction, trauma for explosions, and a boss defeat:
game.feel.shake(5, 0.15, { angle: Math.atan2(bullet.vy, bullet.vx) });
game.feel.addTrauma(size > 2 ? 0.6 : 0.25);
game.feel.hitstop(0.1);
game.feel.slowMotion(0.25, 0.8, 0.4);
game.feel.flash('#fff4d0', 0.3, 0.8);
game.feel.zoomPunch(0.15, 0.5);
Works with
world-screen— needed for the screen flash, which is a screen-space object.post— needed for the rotational shake, which turns the finished world image.world-3d— turns the shake into a look offset and the punch into a narrower lens.tween— for motion that belongs to an object rather than the screen.effects-2d— to flash one sprite rather than the whole screen.transition— for fades between scenes.
Good to know
- A new
shakereplaces the running one rather than adding to it; useaddTraumato accumulate. - Hit-stop and slow motion set the clock's time scale and count real time, restoring the scale they found.
- Without
world-screena flash does nothing and warns once; withoutposta roll throws in development. - The shake is a random offset, not noise with a spectrum, and two packs shaking the camera at once overwrite each other.






