pixi-reels
All mechanics

Mechanics

Skip and slam

Decide what a tap does mid-spin: stop every reel, land them one by one, or let a tease finish.

Demos

A press during a spin is a skip. By default it force-completes every phase, AnticipationPhase included, so every reel lands at once and a tease ends before the player sees it. The first demos show that plain press. The later ones land only some reels, keep a tease on screen, and change how a phase answers a press.

The basic press#

Land every reel now#

The player presses and the reels land on the result. Call requestSkip() from the button. skipSpin() throws if the result has not arrived yet, while requestSkip() waits for it.

Loading recipe…

Press before the result arrives#

skipSpin() throws before setResult(), because there is nothing to land on yet. requestSkip() queues the press and fires it when the result arrives, with protection applied. The result in this demo is delayed on purpose.

A queued press can only protect a tease the engine already knows about, so call setAnticipation before setResult.

Loading recipe…

Land some reels#

Leave some reels spinning#

slamStop({ except: [3, 4] }) lands reels 0 to 2 now and leaves 3 and 4 to stop on their own.

A partial slam does not end the round. The button stays live. Only a full slam moves skipStage to 2 and applies the speed boost.

Loading recipe…

Name the reels that land#

slamStop({ reels }) names the reels to land instead of the ones to spare. Here a plan of three presses lands the board from the outside in.

Neither form needs a guard. Out-of-range indices are ignored, and held or landed reels are never slammed.

Loading recipe…

Protect a tease#

Keep the tease for one press#

protect: 'once' makes the engine apply the partial slam for you. Press 1 lands every reel outside the tease and leaves the tease running, so the trigger symbols are on screen. Press 2 ends it.

Call setAnticipation before setResult. A press made before the result arrives is queued by requestSkip() and fires as soon as the result does, so the tease has to be registered by then.

Loading recipe…

One tease reel per press#

protect: 'stepwise' applies the same rule reel by reel. Press 1 lands everything outside the tease, and each press after it releases the next tease reel, so the player sets the pace.

Release order follows the tease order you passed, not the reel index. setAnticipation([4, 2, 3], ...) releases reel 4 first.

Loading recipe…

A tease no press can end#

With protect: 'always', press 1 lands everything outside the tease, as with 'once', and every later press is ignored. Use it when the tease is the reward, such as a jackpot reveal or a bonus landing on the last reel.

A refused press emits no events and does not throw. slamStop() still lands everything, because the engine refuses the player’s press and never your own code’s.

Loading recipe…

Your own release order#

For an order the built-in modes do not cover, use protect: 'always' and release the reels yourself with slamStop({ reels }) from a queue in your code. 'always' guarantees that no press ends a tease behind the queue’s back. Here three teasing reels come down in two presses.

Loading recipe…

Button state#

reelSet.skipStage is 0 before any press, 1 after a press that landed the reels around a protected tease and left it running, and 2 after the press that ended the round. Stage 1 only happens with protection, so a game without protected teases sees a button with two states. Read the stage off reelSet.skipStage every frame instead of counting presses.

Loading recipe…

Turbo has nothing to protect#

The turbo profiles set anticipationDelay: 0. With a hold of 0 ms there is no tease, and protect does nothing. Protecting a tease that never plays would stall the reels and bring back the response-time tell. The spins here alternate on one turbo profile, and only duration differs between them. Pass duration to get a tease in turbo too.

Loading recipe…

Skip without a tell#

This demo shows why you protect the tease instead of slowing the skip down. Spins alternate between no scatters and a tease, and both press at the same moment. The panel times the last reel outside the tease. The two times match, and the only difference is what happens on screen after the press.

Raising minimumSpinTime instead gets the pacing right but leaks the outcome through response time. The player can tell a feature is coming from how the button felt.

Loading recipe…

Stop and skip in groups#

Reel index is the engine’s only order by default. It cannot express “reels 1 and 2 land together, 3 and 4 tease one press each, reel 5 lands last”. Reel 5 is index 4, so its stop delay comes due in the middle of the tease.

reelSet.setReelGroups([[0, 1], [2, 3], [4]]);
reelSet.setAnticipation([2, 3], { stagger: 'sequential', protect: 'stepwise' });
// Presses walk the board: [1,2] -> 3 -> 4 -> [5].

A group is a barrier for stopping and for skipping. When stopping, no reel starts its stop sequence, anticipation included, until every reel in the earlier groups has landed, and it keeps spinning at full speed while it waits. When skipping, a press releases the next group that has not landed, with protection still applied inside it. Stop delays count from the start of the group. An explicit setStopDelays() still wins.

You can set groups any time up to setResult(). The barrier is read as each reel’s SpinPhase resolves, so a round can take its grouping from its own server response. Every reel must appear exactly once, and changing the layout after reels have begun landing throws. null clears it.

Loading recipe…

Quicken#

Land with a bounce#

A slam places the frame and lands in the same tick, so the press reads as a cut. requestSkip({ mode: 'quicken' }) frees the same reels a slam would, with protection, 'stepwise' and groups all applied, and asks each one for its normal landing. The tease ends, the stop delay is cut, and the reel spins its frame in and bounces. speed: 'turbo' lands the quickened reels on the turbo spin-out and bounce. builder.skipMode('quicken') makes quicken the default mode.

A quicken is a skip. skipStage advances, wasSkipped is true, and SpinResult.skipMode says which mode ended the round. A mode: 'slam' press after it still cuts whatever is moving. Tapping the readout sends that slam press, so you can see the cut on the same spin.

Loading recipe…

Quicken with groups#

A quicken walks the same groups a slam would and quickens each one instead of placing it. A freed group turns violet, which is the stop phase spinning in, instead of going straight to grey. The cards are PhaseCardSymbol, so each colour is a phase.

A quickened reel counts as released, so a quick second press is taken early. The reel behind the barrier still waits for the group before it to land: reel 5 stays blue until reel 4 is down, however fast you press.

Loading recipe…

Quicken, then slam#

One button with two presses. The first calls requestSkip({ mode: 'quicken', speed: 'turbo' }) and the second calls requestSkip({ mode: 'slam' }). A quicken press passes over the reels it already quickened, and a slam press cuts them. Both are skips, and SpinResult.skipMode names the one that ended the round.

Each press carries a payload ({ press: 1 }, { press: 2 }), and the HUD reads it back off skip:requested, along with the profile a quicken named as speed.name. The event carries the whole press, which is the same context every phase’s onSkip(ctx) receives, and SpinResult.skipContext keeps the last one.

Decide whether the round has been quickened from skip:requested and its mode, not from a local counter. A press that freed nothing must not arm the slam.

Loading recipe…

Minimum spin time#

Per-reel floor#

There is no slam in this demo. minimumSpinTime is one value on the speed profile, shared by every reel. setMinimumSpinTime([0, 0, 0, 1000, 1000]) overrides it per reel, so reels 0 to 2 take the result as soon as it arrives while 3 and 4 spin for a full second.

The setting stays across spin() and refill() until you clear it with null, like setStopDelays(). Set it once at boot, not on every spin.

The floor only applies to natural landings. A slam ignores it, so a tap mid-spin lands all five reels together and the labels read -> slam.

Loading recipe…

One floor for every reel#

A single number raises the floor on every reel. null hands the floor back to the speed profile, which is not the same as a floor of 0. The spins alternate so you can compare the two back to back.

Loading recipe…

Other spin modes#

Cascades#

Anticipation runs before the cascade and standard paths split, so a cascade spin teases and protects the same way a strip spin does. What a press carries differs in three ways:

Behaviour
Initial spinprotect applies unchanged. Press 1 lands the reels outside the tease, press 2 ends it.
Round side effectIn cascade mode the side effect is that later refills slam on their own, not a speed boost. A protected press does not spend it. The press that ends the tease does, and every refill after that lands instantly.
RefillsNo tease. refill() clears the anticipation set on entry, so a press during a refill is an ordinary full slam. slamStop({ reels }) still works per reel there.

A partial slam does not abort the chain, but it does mark the whole result wasSkipped: true.

Loading recipe…

Hold & Win#

This section has no demo. A Hold & Win board is one single-reel ReelSet per cell, so slamStop({ reels }) can only name reel 0. To skip per cell, use BoardGrid.skipSpinning() or HoldAndWinBoard.skip().

Protection on a cell’s set behaves consistently but is rarely useful, because the set of reels outside the tease is empty:

  • 'once': press 1 spends the protection and lands nothing, press 2 lands the cell. This is intended.
  • 'stepwise': the release group is the tease reel, so one press lands it.
  • 'always': do not use it here. No press can land the cell, and the recovery path in BoardGrid.skipSpinning() needs the cell to land or the next respin() throws.

Custom phases#

Every built-in phase is exported, so you can subclass one or write your own. See Phases for the full extension contract.

Subclass a built-in phase#

This StopPhase subclass adds a backlight on landing. It inherits the sequencer, the bounce and the skip pose. Register it under the same key to replace the built-in.

Call super from every hook you override. A reel whose onEnter never reaches super spins forever. Override onSkip too if the backlight should also show on a slammed reel.

Loading recipe…

A spin floor computed by the phase#

A SpinPhase subclass sets a per-reel floor in one line. setMinimumSpinTime([...]) does the same from configuration. Subclass when the floor is computed instead of configured.

Merge the config instead of replacing it: super.onEnter({ ...config, minimumSpinTime }).

The staircase only applies to natural landings. A slam ignores the floor, so a tap mid-spin flattens it and the labels read -> slam.

Loading recipe…

A countdown during the tease#

An AnticipationPhase subclass draws a countdown on each teasing reel. onEnter shows the label and then calls super, update(deltaMs) runs every frame, and onSkip clears the label when a press force-completes the phase.

update adds up ticker time, not wall-clock time, so it stays correct in a background tab. The active SpeedProfile is on this._speed.

Loading recipe…

A phase from scratch#

Extend ReelPhase when you replace the whole behaviour instead of adjusting it. This one replaces StartPhase with a linear ramp and no step-back pull.

Register it under the lifecycle key it replaces. The controller only asks for lifecycle keys, so a phase registered as register('myPhase', ...) is never used. Call this._complete() exactly once, or the spin promise never settles.

Loading recipe…

Phases with constructor arguments#

The cascade phases and AdjustPhase take build-time config as extra constructor arguments, so a subclass needs registerFactory and must pass them on. resolveTumbleConfig(config) builds the shape they expect.

Here .phases(...) comes before .tumble(...) and still wins, because configurators are deferred to build() and applied after the built-in registrations.

Loading recipe…

A phase that can be quickened#

A custom phase hears a press in onSkip(ctx) and reads ctx.mode to decide what to cut. This instant stop holds its frame a tenth of a cell short for 900 ms before it slides in. Under 'quicken' the hook drops the hold and slides at once. Under 'slam' it rests on the frame. The class sets quickenable = true to say its hook handles the mode. Without the flag, a quicken leaves the phase alone: the reel still lands, and the press shortens nothing.

The quicken branch should cut a wait, never the landing. Keep land() and bounce() where the natural path calls them, or a quickened reel lands differently from one that was left alone.

Loading recipe…

Concept

Spin lifecycle
The phases of a spin, the events they fire, and where to hook in.

A spin has three phases, and a fourth when you ask for it.

The start phase pulls back a little and then accelerates, like a lever. The spin phase runs at full speed and waits for the server. The anticipation phase is optional. It slows one reel to build tension, and it only runs if you called setAnticipation() before the result arrived. Most scatter games use it, so it ships with the library. The stop phase brakes onto the target frame, overshoots, and settles.

What events the reel set fires#

The reel set reports each step as an event, so you do not need to poll. One await reelSet.spin() fires them in this order.

spin:start fires on every spin(), however the spin ends. The reels are moving.

spin:allStarted fires when every reel except the held ones is at full speed. This is the event that matters for timing. You can call setResult() earlier, and the engine holds it until this event has fired.

spin:stopping fires once per reel, with its index, as the reel starts braking. Held reels never fire it.

spin:reelLanding fires when a reel is on its result frame: the strip has snapped, every visible symbol has been told it landed, and the bounce is about to start. It carries the reel index and its symbols. Start anything tied to the landing here, such as an overlay growing over the reel, a per-reel sound, or a symbol takeover.

spin:reelLanded fires when that reel has settled, a full bounceDuration after spin:reelLanding. On a slam, which has no bounce, the two fire on the same tick. It carries the index and the symbols. Use it for per-reel effects that should wait for the bounce, such as a scatter ping or a column glow, without waiting for the whole grid.

Each symbol hears the landing too. onReelLanded(ctx) runs on every visible symbol immediately before spin:reelLanding, and the context says which reel and cell it landed in. A Spine symbol’s autoPlayLanding option can be a function of that context, returning true, false or an animation name. That lets the symbols on a reel that a takeover is about to cover skip their landing while the rest land as usual:

new SpineReelSymbol({
  spineMap,
  autoPlayLanding: ({ reelIndex }) => !copyReels.has(reelIndex),
});

reelSet.events.on('spin:reelLanding', (reelIndex) => {
  if (copyReels.has(reelIndex)) overlay.growOver(reelIndex);
});

A symbol that starts a landing animation this way exposes it as symbol.landing, a promise that holds until the reel moves again. Code that should play after the landing can await it instead of taking over the animation track.

spin:allLanded fires when the last non-held reel is down, with the full result attached.

spin:complete fires right after, with the same SpinResult, which already carries duration. Start the win presentation here.

Fetch the result mid-spin#

A slot calls the server while the reels spin.

const promise = reelSet.spin();
const response = await fetch('/api/spin').then((r) => r.json());
reelSet.setResult(response.symbols);
if (response.anticipationReels?.length) {
  reelSet.setAnticipation(response.anticipationReels);
}
const result = await promise;

Call setResult() while the reels are spinning. Calling it early is fine, because the engine holds the stop until every reel is in the spin phase. If you never call it, the promise waits forever.

The skip calls#

There are three calls, and you pick one by what the player did.

skipSpin() is for a player press on the slam button. It knows about the round. It throws if the result has not arrived yet, so use requestSkip() in that window. The first press also raises the speed in standard mode, or makes later refills slam on their own in cascade mode. It fires skip:boosted when it raises the speed.

requestSkip() slams as soon as it can. It is safe to call before setResult(): it queues and fires once, with no boost. Use it for a player pressing the button before the server answers.

slamStop() lands the reels now, with no boost and no queueing.

All three land on whatever setResult() gave the engine and set result.wasSkipped to true. Every lifecycle event still fires on the slam path, so the win presenter needs no second code path.

skipStage tells you where the round is: 0 before any press, 2 after the press that ended it, and 1 while a protected tease is still running (see below). Drive the button’s look from it.

Skip granularity#

By default a slam lands every reel. It force-completes every active phase, including the skippable anticipation phase, so a press on a teasing spin ends the tease before the player sees it.

To land some reels and let others keep playing:

// The tease rule, applied by the engine.
reelSet.setAnticipation([2, 3, 4], { stagger: 'sequential', protect: 'once' });
// press 1 -> reels 0-1 land now, 2-4 keep teasing, skipStage becomes 1
// press 2 -> the tease ends too, skipStage becomes 2

// 'stepwise' releases the tease one reel per press instead.
reelSet.setAnticipation([2, 3, 4], { protect: 'stepwise' });
// press 1 -> reels 0-1;  press 2 -> reel 2;  press 3 -> reel 3;
// press 4 -> reel 4, and that press ends the round

// Or do it by hand, for your own rule.
reelSet.slamStop({ except: [3, 4] });

For a grouping the built-in modes do not cover, use protect: 'always', so no press can end a tease, and land your own groups with slamStop({ reels }) on each press.

protect applies to skipSpin() and requestSkip(), including a press queued before the result arrived, which is the case it exists for. Call setAnticipation before setResult so the queued press can see the tease. A bare slamStop() always lands now.

skip:requested and skip:completed carry { reels, partial }, so a listener can tell a partial slam from the one that ends the round.

In a tumble cascade the initial spin protects the same way. Two things change. The round’s side effect is that refills slam on their own instead of a speed boost, and refills carry no tease, since refill() clears the anticipation set on entry. A Hold & Win board is one single-reel set per cell, so a per-reel slam has nothing to divide there and BoardGrid.skipSpinning() skips per cell instead. The cascade protect demo and the section after it cover both.

Two mid-spin calls look like they would help here and do not. Both are covered by tests. Shrinking the set with setAnticipation() does not release a reel that is already teasing, because the set is read once, when a reel leaves the spin phase. And setSpeed() does not re-time the round in flight, because spin() captures the active profile and hands that instance to every phase. That is also why the skipSpin() boost takes effect on the next spin.

Spin floor#

minimumSpinTime sets how long a reel spins before it may stop. It lives on the speed profile, so it is one value shared by every reel. setStopDelays() is per reel but cannot go under it, so on their own the two settings could not make one reel land on arrival while another kept spinning. setMinimumSpinTime overrides the floor per reel and covers that case.

reelSet.setMinimumSpinTime([0, 0, 0, 900, 900]); // last two hold longer
reelSet.setMinimumSpinTime(null);                // back to the profile

On teasing spins, use protect instead of a raised floor. If a scatterless skip lands instantly but a teasing one settles slower, the response time tells the player a feature is coming before the reels have landed.

Holding some reels#

Expanding wilds and single-reel respins need some reels to stay put.


const spin = reelSet.spin({ holdReels: [0, 4] });
reelSet.setResult(serverGrid);
await spin;

A held reel does not spin and keeps what it is showing. It counts as already landed, so spin:allLanded waits only on the others, and it fires neither spin:stopping nor spin:reelLanded. setAnticipation([...]) drops held indices without an error.

Overriding the spin mode#

Some slots spin first and then cascade. The mode spin option swaps the phase chain for one call.

const reelSet = new ReelSetBuilder()
  // ...
  .tumble({
    fall:   { duration: 280, ease: 'power3.in',  cellStagger: 60 },
    dropIn: { duration: 450, ease: 'power3.out', cellStagger: 60, distance: 'perHole' },
  })
  .ticker(app.ticker)
  .build();

await reelSet.spin();                  // round 1: strip-spin (default mode)
await reelSet.spin({ mode: 'cascade' }); // respin: cascade drop-in

Picking 'cascade' without .tumble(...) throws, and the error names the missing method. See the spin-then-cascade demo.

Nudge#

After a spin lands, you can move one reel a few cells to reveal symbols you choose. The spin pipeline is idle while this runs, and the nudge drives the strip itself.

await reelSet.spin();
await reelSet.nudge(2, { distance: 1, direction: 'forward', incoming: ['wild'] });

The direction is relative to the reel’s own travel, not to the screen. See Orientation & direction. For several reels at once, run independent calls under Promise.all.

A nudge can be cancelled mid-tween through its signal option, which rejects with an AbortError and fires nudge:cancelled, or finished early with skipNudge, which resolves normally.

The nudge page has the full contract and these demos: nudge, skip, abort, stagger, spotlight after a nudge, big symbols.

Full event map#

EventPayloadWhen
spin:startnoneAny spin() call
spin:allStartednoneEvery non-held reel is in the spin phase
spin:stopping(reelIndex)A reel begins its stop (held reels never fire)
spin:reelLanding(reelIndex, symbols)A reel is on its result frame, bounce not started, after every onReelLanded(). Every landing path, cascade refill stages included
spin:reelLanded(reelIndex, symbols)A reel landed (held reels never fire)
spin:allLanded(result)The last non-held reel landed
spin:complete(result)Just after spin:allLanded
skip:requested({ reels, partial })A slam fired, from skipSpin(), requestSkip() (after setResult) or slamStop(). partial is true when reels are still spinning after it
skip:completed({ reels, partial })Those reels have been force-landed
skip:boosted({ previous, current })First skipSpin() press of a standard-mode round. The engine bumped the speed to the fastest registered profile for the rest of the round. Cascade mode auto-slams refills instead
speed:changed(profile, previous)setSpeed() called
spotlight:start(positions)spotlight.cycle(...) began
spotlight:endnoneThe spotlight finished
pin:placed(pin)reelSet.pin(...) succeeded
pin:expired(pin, reason)A pin was removed by unpin, by its turns running out, by an 'eval' reset, or by a 'collision' (a reshape clamped it onto an occupied cell)
pin:moved(pin, from)reelSet.movePin(...) resolved
pin:migrated(pin, info)A MultiWays reshape moved a pin to a new cell
pin:overlayCreated(pin, symbol)A mid-spin overlay symbol was mounted for a pin
pin:overlayDestroyed(pin, symbol)A mid-spin overlay was torn down on land
shape:changed(cellsPerReel)MultiWays setShape(...) accepted
adjust:start({ reelIndex, fromCells, toCells })The adjust phase entered for a reel
adjust:complete({ reelIndex })The adjust phase finished
nudge:start({ reelIndex, distance, direction })reelSet.nudge(...) pre-placement done, tween about to begin
nudge:complete({ reelIndex, distance, direction, symbols })The nudged reel snapped to its new grid position
nudge:cancelled({ reelIndex, distance, direction, reason })The nudge signal aborted or the reel was destroyed mid-tween. Never fires together with nudge:complete
destroyednonedestroy() called

Reference#

API

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

  • Tween-only phase between SPIN and STOP for MultiWays slots.

  • Anticipation phase: the tease before a reel stops.

  • A grid of cells that each spin independently - the generic "board of reels" primitive. Every cell is its own 1×1 ReelSet, so it inherits the engine's phases…

  • One visible cell on a reel. the thing that actually draws.

  • Drop-in half of the tumble cascade. Animates each visible symbol from its computed origin (above the viewport for new symbols, its old grid cell for…

  • A small readable card: rows of monospace text on a smooth rounded plate, with optional swatches (legends) and meters (a speed, a progress). The building block…

  • A Hold & Win board: a grid of independently spinning cells plus the round choreography every H&W game repeats - spin the free cells, lock the hits…

  • The PhaseCardSymbol class in the pixi-reels API.

  • Factory for creating reel phase instances.

  • Reelclass

    One vertical column of a slot board.

  • ReelSetclass

    The whole slot board as one object.

  • The configurator you call before every reel set.

  • ReelSymbol implementation using Spine 2D skeletons.

  • Continuous spinning at constant speed.

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

  • Accelerates the reel from rest to full spin speed.

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

  • Stops the reel on the target frame.

  • insetfunction

    Shrink (or grow) any strategy's mask by a number of pixels - one number for all four sides, or { top, right, bottom, left } for a different trim per screen…

  • The resolveTumbleConfig function in the pixi-reels API.

  • Add a rounded rectangle to g as one closed PATH instead of a shape, and return g so the stroke chains on.

  • stepfunction

    Build a PhaseStep.

  • The AnticipationPhaseConfig interface in the pixi-reels API.

  • The CascadeDropInPhaseConfig interface in the pixi-reels API.

  • ReelBounceinterface

    A landing bounce in flight, returned by ReelPhase.bounce.

  • SkipContextinterface

    What a phase receives in onSkip(ctx): the mode of the press that reached it, the profile it should finish on (a 'quicken' that named one), and whatever the…

  • The SpinPhaseConfig interface in the pixi-reels API.

  • SpinResultinterface

    Result returned when a spin completes.

  • The StartPhaseConfig interface in the pixi-reels API.

  • The StopPhaseConfig interface in the pixi-reels API.

  • TumbleConfiginterface

    The TumbleConfig interface in the pixi-reels API.

  • Timing and animation profile for a speed mode.

  • 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 start a spin?open

Call await reelSet.spin(). It starts every reel with a staggered delay and resolves with a SpinResult once all reels have landed.

Question page
How do I stop the reels on a result?open

Once the server responds, call reelSet.setResult(grid) while the spin promise is still pending. The stop sequence consumes it and each reel lands on its target.

Question page
How do I know when a spin has completely finished?open

await reelSet.spin() resolves with a SpinResult once every reel lands, or listen for the spin:complete event.

Question page
How do I play a sound when a reel stops?open

Listen for spin:reelLanded (or spin:stopping) and play the stop sound.

Question page
How do I show a spin while waiting for the server, then snap to its result?open

Call spin() immediately, then setResult(grid) when the server replies. The stop sequence lands on it.

Question page