What it does
createProjectiles gives you a projectile system. You emit a pattern from a point along an aim for a team, with the
damage each shot carries, and the system schedules every launch: a fan or a ring leaves at once, a burst or a spiral
one shot at a time, and a staged pattern ring after ring. patternShots returns the same schedule as plain times and
angles if you want to drive your own bullets.
Each tick moves the shots in substeps of at most 1/120 second and tests their swept path against circular targets
and rectangular walls, so a fast shot cannot pass through a target or a wall between frames. A shot ignores targets
of its own team, hits and grazes each target at most once, passes through as many extra targets as its pierce allows,
and bounces off walls while it has ricochets left. Homing shots turn toward the nearest living target of another team
at a limited rate.
Everything that happens comes out of drain as an event: spawn, hit with its damage, graze, bounce and
expired. The pack never changes anyone's health, so it fits whatever combat rules you use, and snapshot and
restore include the launches still waiting.
Features
- Six patterns —
aimed,fan,ring,spiral,burstandstaged, with count, spread, interval, stages and rotation set explicitly. - Swept hits — continuous tests against circles and rectangles in short substeps, with no tunnelling.
- Piercing and ricochet — a count of extra targets to pass through and of wall bounces.
- Homing — a turn rate toward the nearest living enemy, from the
actorspack's steering. - Grazes — near-miss events within a distance you choose, each target once per shot.
- Teams, events and snapshots — friendly fire ignored by team, events for damage, sound and effects, and full snapshot and restore.
Good for
- Bullet-pattern shooters, where enemies fire rings, spirals and staged waves to dodge, with grazes for score.
- Room-by-room robot shooters in the style of Berzerk, with aimed shots and walls that stop them.
- Twin-stick arena shooters in the style of Robotron, with player and enemy shots kept apart by team.
- Top-down action games with piercing lances, ricocheting bolts and homing missiles.
Make it yours
Every volley is an explicit definition: the kind, the count per volley or per ring, the speed, the fan's spread, the interval between shots or rings, the number of stages, the turn per shot or ring, each projectile's radius and life, and its pierce, ricochet and homing. The damage and team go with each emit, and the graze distance with each tick.
Two different uses: an enemy that fires a staged pattern of three rotating rings of twelve slow shots for the player to weave through, scoring a graze for every close pass; or a player's gun that fires a five-shot fan of fast, piercing shots that bounce once off the arena walls.
A quick look
A fan of five piercing shots, ticked against the hero:
import {createProjectiles} from '@phaser-ae/projectile-patterns';
const shots = createProjectiles();
shots.emit({kind:'fan', count:5, spread:1, speed:180, life:4, pierce:1},
{x:100,y:100}, Math.PI/2, 'enemy', 10);
shots.tick(1/60, [{id:'hero',team:'hero',x:100,y:150,r:12,alive:true}], []);
const events = shots.drain();
Works with
actors— required: the homing steering.combat-rules— damage, armour and shields, a ready combat layer to apply hit events to.platform-hazards— for enemy shots in side-view platform games over a tile map.
Good to know
- Projectiles and targets are circles and walls are axis-aligned rectangles; there is no 3D or mesh collision.
- A volley holds 1 to 256 shots, and there is no cap on shots in flight, so a game should bound its own population.
- Hits report damage but never apply it.






