pixi-reels
All mechanics

Mechanics

Cascades

Winning symbols burst, the rest fall into the gaps and new ones drop in, until nothing else wins.

Demos

A cascade round removes the winning symbols, lets the survivors fall into the holes and drops new symbols in, then checks for wins again. The first demo is that loop with nothing changed. The ones after it each change one part of it.

Basic cascade#

A 6x4 board where runCascade runs the loop. You pass detectWinners and nextGrid, and it destroys, refills and asks again until detectWinners returns no cells. The second canvas is the same recipe with Thunderkick Spine symbols; only the symbol registration differs.

Loading recipe…

Loading recipe…

Removing winners#

Each cascade step runs in a fixed order: present the win, destroy the winning symbols, refill the holes. Work out the winners from your match logic. Diffing the grid before and after does not work, because survivors slide past the cleared cells and a diff reads them as changed.

Present the win first#

Two winning combinations share reel 2. runCascade hands them to a WinPresenter through its presentWinners hook, which shows each one in turn before the winners explode and the refill drops.

Loading recipe…

Default destroy#

No out animation is registered, so destroySymbols plays the engine’s scale and fade implode. Use this when you have no destruction art.

Loading recipe…

Spine explosion#

The same board with outAnimation: 'explode' set at registration. destroySymbols plays the skeleton’s explosion instead of the implode.

Loading recipe…

Timing and motion#

These demos run the same spin and the same win. Only the timing or the motion of the fall and the refill changes.

Delay before the fall#

The pause between the spin press and the first frame of the fall: 0, 150, 350 and 700 ms. A longer pause adds suspense before the board clears.

Loading recipe…

Loading recipe…

Loading recipe…

Loading recipe…

Refill order#

The order the new symbols arrive in after a win. All reels at once with setDropOrder('all'), a left-to-right wave, and bottom-up, where the bottom cell lands first (cellOrder: 'endFirst').

Loading recipe…

Loading recipe…

Loading recipe…

Tumble motion#

Five .tumble({ fall, dropIn }) configs on the same round: classic, slow drop, slam, rain column and wave. They differ in durations, eases and per-cell stagger.

Loading recipe…

Loading recipe…

Loading recipe…

Loading recipe…

Loading recipe…

Two-stage refill#

refill({ mode: 'gravity-then-drop' }) splits the refill in two. Survivors slide down first, the engine holds for gravityHoldMs, then the new symbols drop in. Put a multiplier or a mascot beat in the hold. The second canvas drops the reels one after another instead of in a wave, with a longer hold.

Loading recipe…

Loading recipe…

Opening the round with a spin#

Many cascade games open each round with an ordinary strip spin and only cascade the follow-ups. The first canvas does that with spin({ mode: 'standard' }). The second opens with a cascade drop instead, so the old board falls out and the new one drops in. The third is the spin opener tuned for turbo: the strip spins on cached textures and the cascade uses a shorter drop-in and a faster explode.

Loading recipe…

Loading recipe…

Loading recipe…

Gravity and orientation#

By default a reel drains toward the edge it travels toward and refills from the other one. Gravity also decides the server contract. Survivors must be packed against the edge they drain through, and the engine animates the grid you send as it is. It never reorders it.

Sideways#

The same tumble on .orientation('horizontal'). Reels are screen rows, the strip travels along X, and tumble({ gravity }) stays on its default 'auto'. Under forward gravity, nextGrid returns [...fresh, ...survivors].

Loading recipe…

Upward#

A .direction('reverse') set with no gravity key. Gravity follows travel, so the top cell falls and lands first and the column empties upward. The survivors now pack against the top, so nextGrid returns [...survivors, ...fresh]. If you reverse the reels and keep the old grid order, the board looks scrambled.

Loading recipe…

Spin up, settle down#

Reels built .direction('reverse') roll upward, and tumble({ gravity: 'forward' }) makes the tumble settle downward anyway. Set gravity only when you want travel and settling to disagree.

The cell stagger follows gravity too. cellOrder defaults to 'auto', which starts at the end symbols leave through. Here the bottom cell still goes first; without the gravity override the top cell would lead. Pass 'endFirst' or 'startFirst' to fix the starting end whatever the gravity.

Loading recipe…

Teaser in the buffer#

A strip spin with no cascade. A symbol placed in the bufferStart slot sits above the window and scrolls through it at the start of the next spin, so the player sees it briefly before the random symbols take over.

Loading recipe…

Assets provided by Thunderkick

Concept

How cascades work
The two moments of a cascade round, the three phases behind them, and the calls that drive them.

A cascade round has two different moments. Keeping them apart makes .tumble() and refill() easier to reason about.

The two moments#

Moment A is the player pressing spin. Everything falls off the bottom, the reels sit empty while the server thinks, and the new symbols drop in when the answer arrives.

Moment B is a cascade refill. You clear the winning cells. Survivors above a hole slide down into it, and new symbols drop in from off-window to fill the gap at the top, as many per reel as that reel lost. The reels never re-spin.

The same animation engine runs both. The split matters because A is one beat (fall, wait, drop) with the same shape as spin() followed by setResult(), while B is as many beats as there are cascade levels, one per refill until nothing wins, each starting on whatever the last one landed.

fall
CLICK
wait
place
dropIn
refill
WIN!
refill
WIN!
(end)
no wins
Moment A
Moment B
Moment B

The three phases#

The engine runs both moments with three ReelPhase subclasses:

PhaseFires onWhat it does
cascade:fallMoment A, the spin() callTweens every visible symbol off the bottom of the viewport, then waits at speed 0.
cascade:placeBoth momentsSwaps the symbol identities for the new grid and snaps every view to its grid position. Survivors become visible at once. New arrivals stay at alpha 0 until cascade:dropIn moves them above the viewport.
cascade:dropInBoth momentsTweens each moving view from its origin (above the viewport for new symbols, its old cell for survivors) down to its grid position. Survivors that did not move skip the tween.

The per-symbol events (cascade:fall:symbol, cascade:dropIn:symbol) fire before the library’s own tween, so a tween you start in the listener finishes in step with it.

The chain and destroy events sit on the same bus:

EventWhenWhat it is for
cascade:chain:startA chain stage opens, after detectWinners and before destroySymbolsA per-chain sound cue, a chain counter, freezing the spin button.
cascade:destroy:start / cascade:destroy:endAround every destroySymbols(...) batch, direct calls includedA shatter sound, a viewport dim independent of destroyOptions.dim.
cascade:chain:endA chain stage closes, after the refill drop-in settledPer-chain teardown, queueing the next decoration.

runCascade emits the chain events. A loop you write yourself with bare refill() calls only gets the per-phase ones.

You can override any phase by registering a subclass under its name:

builder
  .tumble({ /* ... */ })
  .phases((f) => f.register('cascade:fall', MyCometFallPhase));

The other two keep their defaults. Override a phase only when events and config cannot do what you want. A per-symbol listener is usually enough.

Survivor order#

The grid you pass to a refill follows one rule per reel. The first cells, as many as that reel had winners, are new symbols. The rest are the survivors in their original order. A server-side gravity simulation already produces this.

Take the reel ['A','B','C','D','E'] with winners at cells 1 and 3:

Pre-refillcell 0Acell 1Bcell 2Ccell 3Dcell 4E
Post-refillWhycell 0?(new)new symbol enters from abovecell 1?(new)new symbol enters from abovecell 2Asurvivor cell 0 slid down 2cell 3Csurvivor cell 2 slid down 1cell 4Esurvivor cell 4, no movement

A grid that follows the rule goes straight into refill({ winners, grid }). One that does not needs a transform on the client first.

computeDropOffsets is exported. It is the algorithm the engine uses, so you can check your server output against it offline.

The three calls#

A cascade game needs three calls:

// 1. Fall, wait, drop. Symmetric to a normal spin.
const spinDone = reelSet.spin();                  // or spin({ mode: 'cascade' }) if you also use standard mode
reelSet.setResult(await server.spin());
await spinDone;

// 2. Clear winning cells. The library defers to each symbol's playDestroy().
const winners = detectWinners(reelSet.getVisibleGrid());
await reelSet.destroySymbols(winners);

// 3. Refill survivors + new symbols.
//    grid is ColumnTarget[]. For the common per-reel visible case, wrap
//    your server's string[][] with .map(visible => ({ visible })). For
//    big-symbol anchors that land into the buffer, use the full
//    ColumnTarget shape with bufferStart / bufferEnd.
const next: string[][] = await server.cascade(winners);
await reelSet.refill({ winners, grid: next.map((visible) => ({ visible })) });

That is one win and one refill. For a chain, loop it:

while (true) {
  const winners = detectWinners(reelSet.getVisibleGrid());
  if (winners.length === 0) break;
  await reelSet.destroySymbols(winners);
  await wait(PAUSE_AFTER_REMOVAL_MS);
  const next = await server.cascade(winners);
  await reelSet.refill({ winners, grid: next.map((visible) => ({ visible })) });
}

Or call runCascade with your two callbacks. It runs the same loop, fires the per-stage chain events, and resolves with a RunCascadeResult summary. Both callbacks may be async. nextGrid is where you await the server.

await reelSet.runCascade({ detectWinners, nextGrid });

Per-cascade options#

The options a tumble game usually sets:

OptionDefaultWhen to set
pauseAfterDestroyMs250Lower it to 150 for a turbo mode, raise it to 500 for a slower round.
maxChain32A safety cap. Raise it only if your game can legitimately exceed 32 cascades.
onCascadenoneRuns once per cascade. Update a multiplier or play a sound here. Return a promise to delay the next refill.
destroyOptions{}Forwarded to destroySymbols(...): per-cell stagger, lifted z-index, viewport dim.
signalnoneAn AbortSignal that cancels the chain. See cancelling a chain.
await reelSet.runCascade({
  detectWinners,
  nextGrid,
  pauseAfterDestroyMs: 180,        // snappy
  destroyOptions: {
    delay: (cell, i) => i * 0.03,  // left-to-right disintegration
    dim:   true,                   // dim the viewport while pops play
  },
  onCascade: async ({ chain }) => {
    bumpMultiplier(chain);
    await playWinSound(chain);     // delays the next refill until the sound resolves
  },
});

DestroySymbolsOptions has four fields: delay, zIndex, dim and signal. The delay can be a function of the cell:

destroyOptions: {
  delay:  (cell, i) => i * 0.02,   // first-to-last stagger
  zIndex: 1500,                    // lift above the default 1000
  dim:    0.5,                     // custom viewport dim alpha
}

Cancelling a chain#

skipSpin() slams the phase in flight, but it returns early when the engine is idle, which it is between two refills and during the pause. A tap in that window does nothing and the chain keeps going. Use an AbortController for the chain:

const controller = new AbortController();
skipButton.addEventListener('click', () => controller.abort());

await reelSet.runCascade({
  detectWinners,
  nextGrid,
  signal: controller.signal,
});
// summary.wasSkipped === true after an abort

When the signal aborts, runCascade sets its skipped flag, calls slamStop() if a refill is in flight so the await unblocks at once, exits at the next await boundary, and resolves with wasSkipped: true in the result.

Wire both to the skip button: skipSpin() cuts the phase that is moving, and the abort ends the chain.

refill() or runCascade()?#

Start with runCascade. It is a short wrapper around refill and handles the skip path for you. Use bare refill when the chain needs something the options do not cover, such as different pauses per level, branching per level, or a game loop that already owns the chain. Writing it yourself means the loop above, plus the chain events and the abort handling if you need them.

Other features in a cascade#

The rest of the reel set API keeps working during a cascade:

  • setDropOrder('all') makes every reel drop together. Set it once before runCascade and it holds for every refill in the chain.
  • setStopDelays([...]) sets per-reel delays, for a V-shape or an outside-in reveal.
  • speed.set('turbo') changes the strip-spin speed on standard rounds. Cascade phase durations are static (see TumbleConfig), so for fast cascades you swap the .tumble({}) config or override the phase.
  • pin(...) persists a cell across cascades. A pinned wild stays put through every refill in the round.
  • reelSet.viewport.showDim(alpha) dims the whole board. Pair it with destroySymbols(..., { dim: true }) to draw the eye to the winners.

The empty wait#

Between cascade:fall:end and cascade:dropIn:start the board is empty and the server has not answered. Show a spinner on fall end and hide it on the first drop-in, or show nothing. A server reply under 100 ms is not noticed. If the gap still shows, shorten fall.duration.

The pause matters#

Leave a pause between the winners fading out and the refill starting. Without it the refill begins on the frame the winners reach alpha 0, and the symbols look like they teleported. With 150 to 500 ms between them the player sees two events, the wins clearing and then the new symbols arriving. The default is 250 ms. Around 120 ms feels fast, around 350 ms feels relaxed. Set it with pauseAfterDestroyMs in runCascade(), or with your own wait in your own loop.

Override a phase, or listen to events?#

To run something alongside the library’s tween, listen to cascade:fall:symbol or cascade:dropIn:symbol. They fire first, so your tween stays in step with theirs.

To decorate symbols after they land, listen to cascade:place:end. Its isInitial and winnerCells fields let you skip survivors.

To hold a beat between fall and drop-in, override cascade:place and put the beat in its onEnter. A listener cannot gate a phase.

To make symbols fly sideways instead of falling, override cascade:fall.

Override only when a listener cannot do it. A phase of your own has to implement the whole ReelPhase contract, which is onEnter, update, onSkip and _complete.

Recipes by purpose#

If you wantLook at
The smallest working cascade gameBasic cascade
Tumble motion comparedTumble motion
Refill orders comparedRefill order
The delay between the press and the fallDelay before the fall
Cascades after a strip spinOpening the round with a spin
Cluster wins and cascades on MultiWaysMultiWays cascade
Win presentation with WinPresenterRemoving winners
The longer write-updocs/recipes/tumble-cascade.md

API

Every exported name the concept, the demos and their sources use, with the one-line summary from the generated reference.

  • ReelSetclass

    The whole slot board as one object.

  • The configurator you call before every reel set.

  • ReelSymbol implementation using Spine 2D skeletons.

  • Per-symbolId cache of "spin textures". flat snapshots a reel shows instead of the live symbol (Spine skeleton, animated sprite, ...) while it spins.

  • Wraps any ReelSymbol and swaps it for a cached snapshot texture while the reel spins. "spin static, not Spine."

  • Highlights winning cells on a reel set. One job: animate the symbols.

  • Compute per-cell drop offsets for one reel given its winner set.

  • Bake spin textures for every symbolId up front (at load or between rounds) so the first spin never pays a capture hitch. Ids that already have a user-provided…

  • stepfunction

    Build a PhaseStep.

  • Cellinterface

    A cell coordinate on the reel set. reel is column, cell is visible cell.

  • ColumnTargetinterface

    Per-reel target shape for ReelSet.setResult and ReelSetBuilder.initialFrame. One object per reel.

  • Options for ReelSet.destroySymbols. Every field is optional; the defaults produce the canonical "winners poof" look (no stagger, no viewport dim, zIndex…

  • TumbleConfiginterface

    The TumbleConfig interface in the pixi-reels API.

  • Wininterface

    One "win" as the presenter sees it: an ordered set of cells to highlight.

  • Summary returned by ReelSet.runCascade. Re-exported from the canonical definition in events/ReelEvents.ts so the events module stays the single source of…

  • Standard high-card deck for prototyping. Each card has its own color so a full grid is visually unambiguous at a glance.

  • Built-in speed profiles covering common slot game needs.

  • A pale-yellow WILD card for sticky/expanding-wild prototypes.

Questions

From the FAQ, the questions tagged with this mechanic. Open one here, or follow it to its own page.

How do I make symbols drop in from above instead of scrolling?open

Make the spin a drop-in: build with .tumble({ dropIn }) and spin { mode: 'cascade' }, or register ImmediateMode for an instant land.

Question page
How do I stagger the fall of individual symbols into place?open

.tumble({ dropIn: { cellStagger } }) delays each symbol's fall; the cascade:dropIn:symbol events expose per-symbol timing.

Question page
How do I peek the next symbol from above before it lands?open

Pre-fill the bufferStart slot so a teaser symbol sits just out of frame and scrolls into view on the next spin.

Question page
How do I cycle through multiple winning lines one at a time?open

reelSet.spotlight.cycle(lines) (or WinPresenter with a cycles count) steps through each winning line in turn.

Question page
How do I remove the winning symbols and drop new ones in?open

Build with .tumble(...), then after fading the winners call reelSet.refill({ winners, grid: nextGrid }) with the cleared cells and the new symbols. Survivors fall into the gaps and fresh symbols drop in from above.

Question page
How do I run a tumble sequence until there are no more wins?open

reelSet.runCascade({ ... }) runs the full detect, destroy, refill loop until there are no new wins.

Question page
How do I play a destroy/pop animation on cleared symbols?open

Override playDestroy(opts) on the symbol; reelSet.destroySymbols(cells) plays it on the cleared cells.

Question page
How do I make survivors fall down into the gaps?open

reelSet.refill({ winners, grid }) slides survivors into the gaps and drops new symbols in from above.

Question page
How do I control the fall delay between columns?open

.tumble({ fall: { cellStagger } }) plus the refill order set the per-column timing.

Question page
How do I increment a multiplier on each cascade step?open

Listen for cascade:chain:start / cascade:chain:end and bump your multiplier each chain; the meter itself is game-layer.

Question page
How do I keep a cluster-pays board (8+ connected) tumbling?open

Detect 8+ connected in your win logic and feed the winners to runCascade / refill; the engine tumbles whatever cells you clear.

Question page
How do I drop multiplier orbs that sum up at the end of the tumble?open

Track orb values across the tumble via the cascade events and apply the sum on the final cascade:chain:end.

Question page
How do I spin once and then cascade (spin-then-tumble)?open

One ReelSet, override the mode per spin: classic strip-spin first, then spin({ mode: 'cascade' }) for the refills.

Question page
How do I show the win presenter between cascade steps?open

Run WinPresenter.show(wins) inside your cascade loop, between destroySymbols and refill.

Question page
How do I order the refills (which column fills first)?open

setDropOrder('all' | 'ltr' | 'rtl' | [perReelDelaysMs]) chooses which reel refills first, simultaneous, a left-to-right wave, right-to-left, or explicit per-reel delays. Which cell inside a reel lands first is a separate knob: .tumble({ dropIn: { cellOrder: 'endFirst' | 'startFirst' } }).

Question page
How do I play a different destroy animation per symbol art (shatter vs disintegrate)?open

Override playDestroy(opts) per symbol class, Spine plays a disintegration track, a sprite swaps to a shatter. The default is a scale-and-fade implode, no rotation.

Question page
How do I make a hammer/object smash specific cells and clear them?open

Tween the object to the target cell's getCellBounds, then clear those cells with destroySymbols / setSymbolAt.

Question page
How do I carry a running multiplier meter through the whole feature?open

Keep the meter in your state, apply it to wins, and persist it across the feature yourself.

Question page