# pixi-reels pixi-reels 4.4.1 is a reel engine for PixiJS v8. It ships reel-only primitives. Win math, paytable math, RNG, and audio live in consumer code. This file inlines every guide, API page, recipe (with source) and answered FAQ entry for offline LLM context. The index alone, one line per page, is https://pixi-reels.schmooky.dev/llms.txt. Site: https://pixi-reels.schmooky.dev Repo: https://github.com/schmooky/pixi-reels Package: https://www.npmjs.com/package/pixi-reels ## Quick start ```bash npm install pixi-reels pixi.js gsap ``` ```ts import { Application } from 'pixi.js'; import { ReelSetBuilder, SpriteSymbol } from 'pixi-reels'; const app = new Application(); await app.init({ width: 800, height: 480 }); const reelSet = new ReelSetBuilder() .reels(5).visibleCells(3).symbolSize(120, 120) .symbols(r => r.register('cherry', SpriteSymbol, { textures: { cherry: cherryTex } })) .ticker(app.ticker) .build(); app.stage.addChild(reelSet); const result = reelSet.spin(); reelSet.setResult([{ visible: ['cherry','cherry','cherry'] }, /* one per reel */ ]); await result; ``` ## Mechanics ### Anticipation URL: https://pixi-reels.schmooky.dev/mechanics/anticipation/ Hold the last reels back when a bonus is one scatter away, so the player watches them land. Tags: anticipation, tension, scatter, near-miss, spine, horizontal, reverse, curve, acceleration An anticipation tease slows the reels that could still complete a win, so the player watches them land. Call `setAnticipation(reelIndices, options)` after `spin()` and before `setResult()`. The named reels run an anticipation phase before they stop. The set is cleared at the start of every `spin()`. ```ts const spinDone = reelSet.spin(); const grid = await server.spin(); // ColumnTarget[] reelSet.setAnticipation(anticipationForScatters(grid, { symbol: 'SCAT', trigger: 2 })); reelSet.setResult(grid); await spinDone; ``` The second argument is either a stagger (`0`, a number of ms, a list of ms, or `'sequential'`) or an options object with `stagger`, `slowdown`, `duration`, `protect`, `curve` and `cells`. The demos above cover each of them. The speed profile's `anticipationDelay` sets how long a tease lasts, and a profile with `anticipationDelay: 0` skips the tease unless you pass `duration`. ##### Demos #### Slow the last reels Two scatters land on reels 0 and 2, and `setAnticipation([3, 4])` slows the last two reels so they land late. Live demo (anticipate-a-reel): https://pixi-reels.schmooky.dev/mechanics/anticipation/#anticipate-a-reel #### Choose the reels from scatters `anticipationForScatters` reads the result grid and returns the reels to tease. The demo alternates its two modes. `'all-remaining'` teases every reel after the one where the scatter count reaches `trigger`, empty reels included. `'scatter-only'` teases only the reels that hold a scatter, and the others stop as usual. Live demo (scatter-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#scatter-driven-anticipation #### Pacing several reels ##### One after another `setAnticipation(reels, 'sequential')` holds each teasing reel until the one before it has landed, instead of slowing them all at once. Live demo (staggered-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#staggered--sequential-anticipation ##### Slower on each reel Each teasing reel slows further than the last, from 0.5x to 0.1x of spin speed, holds longer, and lands at that slow speed without returning to full speed first. Live demo (slowing-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#slowing-anticipation #### Teaser symbol `setAnticipation` plus a `bufferStart` prefill. A chosen symbol sits in the slot above the window while the slow reels decelerate, so the player sees it approach, but it never lands. Live demo (anticipation-teaser): https://pixi-reels.schmooky.dev/mechanics/anticipation/#anticipation-teaser #### Turbo The SuperTurbo profile sets `anticipationDelay` to 0, so a plain `setAnticipation` call skips the tease. Pass a `duration` override and the tease plays in every speed mode. Live demo (turbo-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#anticipation-in-turbo #### Skipping the tease ##### Skip at any point A long sequential tease. A press mid-tease slams the reels onto the result. Live demo (skip-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#skip-the-tease ##### Protected tease The same long tease, but the first press only lands the reels around it. `protect: 'once'` makes sure both scatters are on screen and the slowdown has visibly started before a second press can end it. Call `setAnticipation` before `setResult`. A press before the result arrives is queued by `requestSkip()` and fires the moment the result comes in, so the tease has to be registered by then or there is nothing to protect. Live demo (protected-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#skip-that-cannot-hide-the-tease `protect: 'stepwise'` moves the tease on by one reel per press instead of ending it in one go. Partial slams, per-reel spin floors and the case for protecting a tease over slowing the skip are on [Skip and slam](/mechanics/skip/). #### Spine scatter animation The scatter skeleton's own near-win clips. The leftmost scatter snaps its jaw, the loop holds while the tease runs, and the rightmost plays the result as it lands. Spins alternate between a hit and a miss. Live demo (spine-scatter-jaw-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#scatter-jaw-anticipation #### Shaping the slowdown The default tease only slows down. These demos replace that shape with explicit speed segments, anchor the tease to a number of symbols, or limit acceleration for the whole spin. ##### Surge, then crawl An ease applied to a speed changes the acceleration in one step. With `power2.out` the hardest deceleration is on the first frame, so the reel looks like it was switched to a lower speed instead of slowing down. `curve` replaces the fixed shape with explicit segments. Speeds are multiples of `spinSpeed`, so `2` is a real surge and `0.08` a crawl. Segment eases default to `power2.inOut`, which ramps the acceleration in and out. ```ts reelSet.setAnticipation([2, 3, 4], { stagger: 260, curve: [ { speed: 2, duration: 240, ease: 'power2.in' }, { speed: 0.08, duration: 620, ease: 'power3.inOut', hold: 300 }, ], }); ``` Passing `curve` and `slowdown` together throws, because `slowdown` is shorthand for a two-segment curve. The profile's `anticipationDelay` still decides whether the tease runs at all, so Turbo needs a `duration` override. The curve's own durations set the length. Live demo (anticipation-surge-curve): https://pixi-reels.schmooky.dev/mechanics/anticipation/#shape-the-tease-surge-then-crawl ##### A curve per reel Two curves of different lengths have no sensible midpoint, so instead of interpolating, `curve` takes a function, `(order, total) => AnticipationSegment[]`. `order` is the reel's position in the anticipation set, not its index. `setAnticipation([4, 2, 3], ...)` passes `order: 0` to reel 4, the same as `slowdown` and `protect: 'stepwise'` do. Live demo (anticipation-curve-per-reel): https://pixi-reels.schmooky.dev/mechanics/anticipation/#a-different-curve-per-reel ##### Tease for a number of symbols `duration` is a time budget, so how far a reel moves depends on its speed. When the tease is timed to symbols passing the window, as in "three more and it lands", use `cells: n`. It ends the tease after n symbol pitches, measured on `reel.travelledCells`, a counter that only goes up and is not reset by the snap at the end of each spin. `cells` also accepts a function of order, like `curve`. The count applies to the last segment. Earlier segments always play in full, otherwise a fast opening segment could use up the count and skip the ones after it. `duration` is the backstop on that segment, since a reel at rest never reaches a travel target. Live demo (anticipation-cells): https://pixi-reels.schmooky.dev/mechanics/anticipation/#tease-for-n-symbols-not-n-milliseconds ##### Limit acceleration An ease shapes only the transition it is written for. `motionModel('drive', ...)` limits acceleration instead. Phases set `reel.targetSpeed`, and `Reel.update` moves the speed toward it, so every transition gets the same feel, an interruption is a single new target, and `jerkFrames` ramps the acceleration itself. ```ts builder.motionModel('drive', { accelFrames: 20, decelFrames: 34, jerkFrames: 260 }) ``` The limits are relative to the profile, in frames to reach the active profile's full speed. The presets run `spinSpeed` 30, 50 and 80, so one absolute px/frame^2 limit would make SuperTurbo start slower than Normal. The absolute `{ accel, decel, jerk }` form still works for a game with one profile; mixing the two throws. It is set at build time and off by default. The default `'tween'` model is unchanged. Landing and a skip press are instant, as they are under `'tween'`. If the drive cannot reach a segment's speed in time, it reports that on the notice channel. Live demo (anticipation-drive): https://pixi-reels.schmooky.dev/mechanics/anticipation/#the-gas-pedal-bounded-acceleration #### Tease audio `anticipation:reel` and `anticipation:reelEnd` mark the start and end of a reel's tease, which is where a tension loop starts and stops. `anticipation:segment` (`{ reelIndex, index, total, speed, targetSpeed }`) fires once per curve segment, so a surge can sound different from the crawl after it. For a pitch ramp that follows the actual slowdown, read `reelSet.reels[i].speedNormalized` from your own ticker. It is `1` at full spin speed, `0` at rest and above `1` during a surge. #### Other reel directions Reel indexes do not depend on orientation, so the anticipation code is the same. Only where the teasing reels sit on screen changes. ##### Horizontal set Scatter-driven anticipation with the reels running sideways. `anticipationForScatters` and `setAnticipation` work as on a vertical set. Reels are stacked down the screen here, so the last two reels are the bottom two rows, and they slow while moving sideways. Live demo (anticipation-horizontal-scatter): https://pixi-reels.schmooky.dev/mechanics/anticipation/#tension-on-a-horizontal-set ##### Teaser on reels that spin up The teaser on a `direction('reverse')` set. Buffers are geometric, so `bufferStart` is still the slot above the window, and on a reverse reel symbols have already left through that side. Put the teaser on the feed edge instead. `reel.axis.feedEdge` is `'start'` on a forward reel and `'end'` on a reverse one, so one branch covers both. Live demo (anticipation-reverse-teaser): https://pixi-reels.schmooky.dev/mechanics/anticipation/#teaser-on-a-reel-that-spins-up #### Faking a near-miss Place one scatter fewer than the trigger needs and tease the reel that would have held the last one. The result is always a loss. Some jurisdictions restrict engineered near-misses. Check with compliance before you ship one. Live demo (near-miss): https://pixi-reels.schmooky.dev/mechanics/anticipation/#fake-a-near-miss ### Big symbols and MultiWays URL: https://pixi-reels.schmooky.dev/mechanics/big-symbols/ Symbols that span several cells, and boards whose reels show different numbers of rows. Tags: big-symbols, multiways, pyramid, spine, geometry, sticky-wild, horizontal, reverse, orientation Most slots are uniform: every reel has the same number of cells, and this part does not apply to them. It covers three other shapes: | Shape | Changes when | Where | |---|---|---| | Static pyramid (`3-5-5-5-3`) | Never. Fixed at build. | below | | MultiWays | Every spin | [MultiWays](/mechanics/big-symbols/#concept-multiways) | | Big symbols (`N x M` blocks) | Never. One symbol covers many cells. | [Big symbols](/mechanics/big-symbols/#concept-big-symbols) | #### What cannot be combined Two combinations throw at `build()`. MultiWays and a pyramid. `visibleCellsPerReel()` declares a fixed shape and `multiways()` declares one that the server sets. Both set the cell count, so use one or the other. MultiWays and big symbols. A 2x2 block cannot fit a reel that has reshaped to 2 cells. Whether to truncate it, skip it or shrink it is a game design decision, so the engine does not pick one. Big symbols and pyramids do work together. So do MultiWays and cascades (ADR 015). #### Static pyramid ```ts new ReelSetBuilder() .reels(5) .visibleCellsPerReel([3, 5, 5, 5, 3]) .reelAnchor('center') // 'start' | 'center' | 'end' .symbolSize(120, 120) .build(); ``` Short reels are offset along the strip so they sit where `reelAnchor` says. The default mask clips each reel to its own box, so a short reel never shows its buffer cells. `getCellBounds(reel, cell)` includes the offset. The [per-reel shape demo](/mechanics/big-symbols/#pyramid-shape) runs this. #### Masks The clip mask comes from a `MaskStrategy`. Two ship with the library: | Strategy | Clips | Costs you | |---|---|---| | `RectMaskStrategy` (default) | One rect per reel | A symbol spanning two reels is cut at the gap between them | | `SharedRectMaskStrategy` | One rect over everything | On a pyramid, buffer cells past short reels show (the "pyramid peek") | The engine picks `SharedRectMaskStrategy` when big or unmasked symbols are registered and the gap between reels is non-zero, because per-reel rects would visibly cut a block in that case. Override it with `.maskStrategy()`. ```ts import { SharedRectMaskStrategy } from 'pixi-reels'; builder.maskStrategy(new SharedRectMaskStrategy()); ``` For a rounded frame or a hex grid, implement `MaskStrategy` yourself. It takes one `MaskContext` and returns a `Graphics` filled with any shape Pixi can draw. Set `version = MASK_STRATEGY_VERSION` on it. The [masks page](/mechanics/masks/) has strategies for common shapes. To see what is clipped: ```ts import { debugOverlay } from 'pixi-reels/debug'; // needs pixi-silk, a dev dependency debugOverlay(reelSet, { layers: ['mask', 'cells', 'buffers'] }); ``` #### See also - [MultiWays](/mechanics/big-symbols/#concept-multiways): per-spin shape, the adjust phase, pin migration - [Big symbols](/mechanics/big-symbols/#concept-big-symbols): `N x M` blocks - [Per-reel shape demo](/mechanics/big-symbols/#pyramid-shape): a runnable jagged layout - [Cell bounds demo](/mechanics/cells-and-banners/#cell-bounds): overlays aligned to cells A big symbol is one symbol that covers a rectangular block of cells, such as a 2x2 bonus or a 1x3 bar. You declare it at registration with a `size` in its symbol data. The result format does not change. The server places the symbol id in the anchor cell, and the engine fills the rest of the block with a placeholder. For pyramids, MultiWays and what cannot be combined, start at [Per-reel geometry](/mechanics/big-symbols/#concept-per-reel-geometry). #### Declaration Register it like any other symbol and add a `size`, with a reel count and a cell count, to its symbol data: ```ts .symbols((registry) => { registry.register('bonus', SpriteSymbol, { textures: { bonus: tex } }); }) .symbolData({ bonus: { weight: 0, zIndex: 5, size: { reels: 2, cells: 2 } }, // ^^^^^^^^^ a block wider than one reel must have weight 0. // Random fill feeds one reel at a time and cannot place // it, so the builder throws on a non-zero weight. }) ``` The `zIndex: 5` is a convention in the recipes. It puts the anchor above its 1x1 neighbours so it draws on top. #### The result format The server puts the symbol id in the anchor cell of the block only. Every other cell of the block can hold any string, because the engine overwrites it with the occupied placeholder. ```ts // 5x4 grid, 2x2 bonus anchored at (reel=2, cell=1): setResult([ { visible: ['low1', 'low2', 'low1', 'low2'] }, { visible: ['low1', 'low2', 'low1', 'low2'] }, { visible: ['low1', 'bonus', '?', 'low2'] }, // '?' is whatever; engine paints OCCUPIED { visible: ['low1', '?', '?', 'low2'] }, // '?' is whatever; engine paints OCCUPIED { visible: ['low1', 'low2', 'low1', 'low2'] }, ]); ``` Before the per-reel frames are built, the spin controller reads the result grid, finds the anchors, checks that each block fits, and paints the placeholder across the rest of each block. At landing, the anchor symbol is sized to span the whole block, gaps included: `w` cells wide plus `w - 1` gaps, and `h` cells tall plus `h - 1` gaps. The other cells of the block get an invisible stub, and the anchor's view covers them. The public API never returns the placeholder. `Reel.getVisibleSymbols()` and `ReelSet.getVisibleGrid()` both resolve it to the anchor's id, on the anchor's reel and on the other reels the block covers, so the two return the same data. #### Block lookup `getSymbolFootprint` returns the block itself, its anchor cell and size, for win evaluation and event payloads. `getBlockBounds` returns the pixel rect that covers the whole block, for overlays. ```ts const fp = reelSet.getSymbolFootprint(reel, cell); // { anchor: { reel: 2, cell: 1 }, size: { reels: 2, cells: 2 } } const rect = reelSet.getBlockBounds(reel, cell); // { x, y, width: 2*cellW + symbolGap.x, height: 2*cellH + symbolGap.y } gfx.rect(rect.x, rect.y, rect.width, rect.height).stroke({ color: 0xff6b35, width: 4 }); ``` Both return the same data for any cell of the block, anchor or not. For a 1x1 cell, `getBlockBounds` returns the same rect as `getCellBounds`. #### Validation During a spin, `setResult()` throws at once if a block does not fit: - `"big symbol 'giant' (3x3) at (reel=4, cell=2) exceeds reel count 6."` - `"big symbol 'tallBar' (1x3) at (reel=0, cell=3) extends past the bottom of the strip on reel 0 (anchor cell + h = 6 > visibleCells + bufferEnd = 4)."` The check along the strip counts the visible cells plus the end buffer, not the visible window alone, so a block may land partly in either buffer. A `setResult()` with no spin in flight returns early and validates nothing. Pinning a cell of a big symbol other than the anchor is not supported, and it does not throw either. The engine repaints that cell as occupied at the next `setResult()` and the pin is lost without a warning. Pin the anchor instead. Its view spans the block, so the whole block looks pinned. `setSymbolAt()` on a cell other than the anchor does throw. The build-time check refuses a block wider than one reel with a non-zero weight, with a message that starts `big symbol 'bonus' (size 2x2) must have weight 0`. Random fill feeds one reel at a time and cannot place such a block, so its weight would never be used. A block one reel wide may have a weight. #### Partial landings An anchor does not have to be in a visible cell. Put a tall block's anchor in the start buffer and only its tail shows, at the top of the window. Anchor it at the last visible cell and its head shows while the rest extends into the end buffer. Use the explicit `ColumnTarget` form to target buffer slots: ```ts // 1x3 wild lands with its tail at visible cell 0; anchor + one stub are // off-screen in bufferStart. Requires bufferSymbols(2) or more. reelSet.setResult([ { visible: [...], bufferStart: [undefined, 'tallWild'] }, // ... ]); ``` For that reel, `getSymbolFootprint(reel, 0)` reports the anchor at cell -2. The index is negative because the anchor sits before the window. `getBlockBounds(reel, 0)` returns the whole block's rect, off-screen part included, and the mask does the clipping. The [partial landing demo](/mechanics/big-symbols/#big-symbol-partial-land) runs this. #### Masks for wide blocks With a gap between reels, the default per-reel mask leaves that gap unmasked. A big symbol's anchor view extends across several reels, and the per-reel mask clips it at every gap, which shows as transparent strips through the symbol. The engine picks `SharedRectMaskStrategy` on its own when all three hold: 1. At least one registered big symbol is wider than one reel, or any symbol sets `unmask: true`. 2. The gap between reels is above 0: `symbolGap.x` on a vertical set, `symbolGap.y` on a horizontal one. 3. No explicit `.maskStrategy(...)` call was made. It reports the choice on the notice channel, and `.maskStrategy(...)` overrides it. A stack one reel wide (`size: { reels: 1, cells: 3 }`) never crosses a gap, so it keeps the per-reel mask. That mask also suits a reel that `setColumn()` or `splitSymbol()` makes taller or shorter than the rest. With one shared box, the buffer cells past the shorter reels would show. Art that extends past its cell into the gap is clipped there. Pass the shared strategy yourself if you want one box. ```ts import { SharedRectMaskStrategy } from 'pixi-reels'; builder .symbolGap(4, 4) // horizontal gap > 0 .maskStrategy(new SharedRectMaskStrategy()) // explicit (or rely on auto-pick) // ... ``` `SharedRectMaskStrategy` draws one rect over the whole set. On a pyramid that means the buffer cells past the ends of short reels become visible, the "pyramid peek". Games usually cover it with frame art. #### Draw order By default an anchor renders at `symbolData.zIndex * 100 + arrayIndex`, about 500 with `zIndex: 5`. The 100x multiplier leaves room for per-cell order inside one layer, so cells further along the strip still draw in front of their neighbours. When you want a different order, pass a resolver and the engine uses its answer instead. For example, the symbol in the bottom row can always draw in front of the one above it, whatever its type: ```ts .symbolZIndex((ctx) => { if (!ctx.atRest || ctx.visibleCell === null) return ctx.defaultZIndex; const grade = GRADES[ctx.symbolId]; return grade === undefined ? ctx.defaultZIndex : grade * 1000 + ctx.visibleCell * 10 + ctx.reelIndex; }) ``` The resolver receives the symbol id and data, the reel index and count, the array index, the visible cell (`null` for a buffer slot), the visible cell count, whether the reel is at rest, and the z-index the engine would have used. The engine calls it again whenever a symbol's id, cell, reel shape or rest state changes, so its answer is never overwritten. Order across reels only exists for symbols that share a container: an `unmask: true` symbol at rest sits in the viewport-wide unmasked container with every other lifted symbol, while a masked one is bounded by its reel container's own z-index (`reelStacking`). That is why the example grades at rest only and keeps the engine's order in motion. Keep every value below `Z_INDEX_BUDGET.pinOverlay`. Pin overlays render at z-index 10000 (`Z_INDEX_BUDGET.pinOverlay`; `Z_INDEX_BUDGET.symbolLayer` is the 100x). So a big symbol that is also pinned at its anchor gets its overlay above the cell. The overlay is sized to a single cell, so while the reel spins it does not cover the rest of the block. The block spans again once the frame commits at landing. | Layer | zIndex | Source | |---|---|---| | 1x1 symbol, default | `0 * 100 + arrayIndex` | `symbolData.zIndex ?? 0` | | 1x1 symbol, elevated | `1 * 100 + arrayIndex` | `symbolData.zIndex: 1` | | Big-symbol anchor (recipe convention) | `5 * 100 + arrayIndex` (~500) | `symbolData.zIndex: 5` | | Pin overlay during spin | `10000` | internal (engine-managed) | | Spotlight (winning symbols) | own container | `viewport.spotlightContainer` | #### Constraints - A block wider than one reel needs weight 0. Random fill cannot place it and the builder throws on a non-zero weight. The server places it through `setResult()`. - A block wider than one reel exists only at landing. During the spin every cell is 1x1, and the block layout is applied at the stop. A block one reel wide with a weight can also scroll past during the spin, as the [tall blocks demo](/mechanics/big-symbols/#tall-symbols-in-spin) shows. - Big symbols and MultiWays are rejected at build. See the [constraint table](/mechanics/big-symbols/#concept-per-reel-geometry). #### See also - [Per-reel geometry](/mechanics/big-symbols/#concept-per-reel-geometry): overview, constraints, mask strategy - [MultiWays](/mechanics/big-symbols/#concept-multiways): cannot be combined with big symbols - [Block shapes](/mechanics/big-symbols/#big-symbols-mxn): 1x3, 2x2, 3x3 and 2x4 blocks - [Partial landing](/mechanics/big-symbols/#big-symbol-partial-land): tail-visible landings through the start buffer - [Held respin](/mechanics/big-symbols/#big-symbol-held-respin): nudge to reveal, then hold across a respin - [Nudge a big symbol](/mechanics/nudge/#nudge-big-symbol): a block through visible and buffer cells - [Cell bounds](/mechanics/cells-and-banners/#cell-bounds): pixel rects for any cell In a MultiWays slot each reel lands on a different cell count, every spin. The reel's length is fixed and the cell size is derived from it: the extent divided by that reel's cell count. A 2-cell reel has big cells and a 7-cell reel has small ones. #### Setup ```ts const reelSet = new ReelSetBuilder() .reels(6) .multiways({ minCells: 2, maxCells: 7, reelExtent: 480 }) .pinMigrationDuration(300) // ms for the pin-overlay tween. 0 = snap .pinMigrationEase('power2.inOut') // any GSAP ease .symbolSize(68, 68) // the spin-time cell size .build(); const promise = reelSet.spin(); reelSet.setShape([3, 5, 7, 4, 6, 2]); // before setResult reelSet.setResult(serverGrid); // serverGrid[i].visible.length === shape[i] await promise; ``` #### Call order 1. `spin()`: the reels scroll at the previous shape's cell size. 2. `setShape(cellsPerReel)`: records the target, emits `shape:changed`, then migrates pins (`pin:migrated`). Call it before `setResult`. Called after, it throws, because the frames are already cached by then. 3. `setResult(grid)`: each column's visible length must equal that reel's entry in the shape. 4. The reshape runs between the spin and stop phases. Per reel it fires `adjust:start`, commits the geometry, refreshes pin overlays, and fires `adjust:complete`. 5. The stop phase lands at the new shape. #### Pin migration A pin remembers the cell it started in, its `originCell`. Every reshape moves it according to its migration policy and fires `pin:migrated` with the old cell, the new cell, the reel index, and whether it was clamped. ##### The origin policy `'origin'` is the default. A pin that a shrink moved down to a lower cell moves back when the reel grows again, which is what a sticky wild needs. | Spin | Cells on reel 2 | originCell | Lands at | Clamped? | |---|---|---|---|---| | 1 | 5 | 4 | 4 | no | | 2 | 3 | 4 | 2 | yes | | 3 | 7 | 4 | 4 | restored | | 4 | 4 | 4 | 3 | yes | ##### The frozen policy With `'frozen'`, each clamp rewrites the origin cell, so the pin never moves back. Use it for walking wilds, or anywhere the pin's current cell matters and its old cell does not. | Spin | Cells on reel 2 | originCell before | Lands at | originCell after | |---|---|---|---|---| | 1 | 5 | 4 | 4 | 4 | | 2 | 3 | 4 | 2 (clamped) | 2 | | 3 | 7 | 2 | 2 | 2 | | 4 | 4 | 2 | 2 | 2 | ```ts reelSet.pin(reel, cell, id, { migration: 'frozen' }); ``` #### What animates `pinMigrationDuration` and `pinMigrationEase` apply to pin overlays only. The cells underneath snap, because the reel is still spinning at full speed during the reshape, and a tween on a cell would conflict with the motion layer over the same coordinate. With no pins on a reel, no tween is built. `adjust:start` and `adjust:complete` still fire around the reshape, because they come from the reshape step and not from the tween. If the shape did not change, neither fires. `skipSpin()` skips the tween. #### MultiWays events - `shape:changed`: `setShape()` accepted a target - `adjust:start` / `adjust:complete`: per reel, around the reshape - `pin:migrated`: a pin moved because the shape changed #### Limits - No big symbols. A 2x2 cannot fit a reel that reshaped to 2 cells, so `build()` throws. - No pyramid. `visibleCellsPerReel()` and `multiways()` both claim the cell count, so `build()` throws. - `reelExtent` is fixed. To change it, rebuild. Cascades do work with MultiWays (ADR 015). See the [MultiWays cascade demo](/mechanics/big-symbols/#multiways-cascade). #### See also - [Per-reel geometry](/mechanics/big-symbols/#concept-per-reel-geometry): the overview - [Big symbols](/mechanics/big-symbols/#concept-big-symbols): what cannot be combined with this - [MultiWays demo](/mechanics/big-symbols/#multiways): the basic per-spin reshape - [MultiWays cascade](/mechanics/big-symbols/#multiways-cascade): reshape plus tumble - [Sticky wild on MultiWays](/mechanics/big-symbols/#sticky-wild-multiways): pin migration running A reel has more cells than the player sees. `ColumnTarget` addresses all of them. #### Why buffers exist Every reel keeps a few hidden cells past each end of the visible window. They hold the next symbol about to wrap onto the strip, and they scroll through view during a spin, so the motion looks continuous. They also let a win animation move past the edge without showing an empty strip. Set the count with `.bufferSymbols(n)`. Most slots use 1 or 2. More than 2 is unusual. #### ColumnTarget One object per reel. Hand an array of them to `setResult` on the reel set or to `initialFrame` on the builder. Both take the same shape. Start is the smaller screen coordinate: above on a vertical set, left on a horizontal one. It does not follow the travel direction. See [Orientation & direction](/mechanics/orientation-and-direction/#concept). #### Which index is which cell One reel, with `bufferSymbols(2)` and `visibleCells(3)`, has seven cells: The buffers hide behind the mask at rest and pass through view during a spin. #### Example ```ts import type { ColumnTarget } from 'pixi-reels'; const grid: ColumnTarget[] = [ { visible: ['A', 'B', 'C'], bufferStart: ['COIN', 'WILD'] }, { visible: ['A', 'B', 'C'], bufferEnd: ['SCATTER'] }, ]; reelSet.setResult(grid); // Same shape at build time: builder.initialFrame(grid); ``` Index 0 of a buffer array is the slot nearest the visible window and index 1 is one further out. An entry past the configured buffer count throws instead of being dropped, so the mistake shows at the call. #### Unset cells Any cell you leave unset gets a random symbol, buffer cells included. By default buffer cells draw from the same weight table as the strip. A pool with `slots: 'buffer'` restricts the cells outside the window only: ```ts // A coin may blur past mid-spin, but must never park half-visible // above or below the grid. reelSet.randomSymbols.set({ exclude: ['COIN'] }, { slots: 'buffer' }); // Same thing at build time, so even the initial strip obeys it. builder.randomSymbols({ exclude: ['COIN'] }, { slots: 'buffer' }); ``` Each end can have its own pool, named after its buffer: ```ts // Nothing peeks in from above; the cell below the grid is left alone. reelSet.randomSymbols.set({ exclude: ['COIN'] }, { slots: 'bufferStart' }); ``` Add `{ reel: n }` to any of them for one reel only, so `{ reel: 2, slots: 'bufferEnd' }` is one end of one reel. A weight of 0 bans a symbol as surely as `exclude` does. Each layer applies on top of the wider ones. A symbol the strip may not show cannot appear in a buffer cell either, and a symbol a `'buffer'` pool bans is banned at both ends whatever the pools for each end say. An explicit buffer entry in a target always wins over a pool. #### Big symbols in buffers A big-symbol anchor can sit in the start buffer, or in a visible cell whose block extends into the end buffer. Pass the anchor and the engine fills the rest of the block. The block must fit on the strip, not inside the visible window: the anchor cell plus the block's height may not exceed the visible cells plus the end buffer. That is what allows a block that is mostly hidden with one cell showing. #### See also - [Peek symbol from the buffer](/mechanics/cascade/#peek-from-above): the smallest runnable version - [Anticipation teaser](/mechanics/anticipation/#anticipation-teaser): a buffer symbol plus `setAnticipation` - [Partial landing](/mechanics/big-symbols/#big-symbol-partial-land): a tail-visible wild - [ReelSet reference](/reference/api-reelset/): the full `setResult` signature ##### Demos The first half of this page covers big symbols, one symbol that covers a block of cells. It starts with blocks that land in full view and moves on to blocks that land partly hidden in a buffer or scroll past during the spin. The second half covers boards whose reels show different numbers of cells: a fixed pyramid and MultiWays. #### Big symbols ##### Block shapes Four shapes, one demo each: a 2x2 square, a 1x3 tall block, a 3x3 giant and a 2x4 wide block. The server places the anchor cell and the engine fills the rest of the block. Live demo (big-symbols-mxn-square): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#big-symbols-mxn Live demo (big-symbols-mxn-tall): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#big-symbols-mxn Live demo (big-symbols-mxn-giant): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#big-symbols-mxn Live demo (big-symbols-mxn-wide): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#big-symbols-mxn ##### Outline a block `getBlockBounds` returns one rectangle around the whole block, whichever of its cells you pass. For a 1x1 cell it returns the same rect as `getCellBounds`. Live demo (get-block-bounds): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#get-block-bounds ##### Spine art The same 2x2 anchor mechanic with a Spine skeleton in every cell. The big wild reuses the wild rig, scaled to the size of the block. Live demo (spine-big-symbols): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#spine-big-symbols ##### Horizontal reels A 2x3 block on a set built with `.orientation('horizontal')`, outlined on landing with `getBlockBounds`. `size: { reels, cells }` is in index space and does not rotate. `reels` always counts across reels, and `cells` always counts along the strip. The screen shape flips with the orientation. `{ reels: 2, cells: 3 }` is 2 wide and 3 tall on a vertical set, and 2 tall and 3 wide here. `getBlockBounds` works in screen space, so its rect flips too. Live demo (big-symbols-horizontal-block): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#big-symbols-horizontal-block #### Blocks in the buffer A block's anchor can sit outside the visible window, so only part of the block shows when the reel lands. The game then brings the rest into view. ##### Land partly in the buffer A 1x3 block lands with its anchor in `bufferStart`, so only its bottom cell shows, at cell 0. A downward nudge drags the rest into view. Live demo (big-symbol-partial-land): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#big-symbol-partial-land ##### Nudge in, then hold for a respin The partly hidden wild is nudged into full view. Then the other reels respin with `holdReels`, so the block stays where it is. Live demo (big-symbol-held-respin): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#big-symbol-held-respin ##### Reverse reels The same partial landing on a reel built with `.direction('reverse')`, which rolls up. The block is anchored at the last visible cell with its body in `bufferEnd`, and a `'forward'` nudge, which moves up on this reel, drags it into full view. Buffers are positional and do not follow the travel direction. `bufferStart` is above and `bufferEnd` is below in both directions, so a reel that feeds from the bottom shows its partial block out of `bufferEnd`. Live demo (big-symbols-reverse-tail): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#big-symbols-reverse-tail ##### Fall into view in a cascade A tall wild lands with its anchor in `bufferStart` and only its tail showing. The cells below it win, and the wild falls into full view as they clear. The second demo does the same with a 2x2 block across two reels. The anchor's fall distance must equal the number of winning cells cleared below it, or the block snaps instead of falling. Live demo (big-symbol-cascade-fall): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#big-symbol-cascade-fall Live demo (big-symbol-cascade-fall-2x2): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#big-symbol-cascade-fall #### Blocks during the spin ##### Tall blocks in the spin A 1x3 block with a weight scrolls past on reel 0 while it spins, and a scatter only ever scrolls past on reel 4. Both weights are set in per-reel pools: `0` in the base `weights()` table, and raised on the one reel that may show the symbol. Only blocks one reel wide can have a weight. Wider blocks still appear only on landing, because the random fill feeds one reel at a time. A narrower pool cannot lift an `exclude` set by a wider one, but it can raise a weight of `0`. To allow a symbol on one reel only, use weights, not `exclude`. A weighted block also needs `bufferSymbols({ start: size.cells })`, and the builder checks for it. The block enters a forward reel bottom first and leaves a reverse reel anchor first, and the buffer slots hold its covered cells while the anchor that draws them is off the strip. Live demo (tall-symbols-in-spin): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#tall-symbols-in-spin ##### Peek, then bring it up Two scatters slow reel 4 into an anticipation crawl, and the weighted 1x3 keeps sliding past during it. The result lands the block with its head on the last visible cell and its body in `bufferEnd`, so the set uses `bufferSymbols({ start: 3, end: 2 })`: `start` for the weight and `end` for the peek. The two demos then bring the block up in different ways. - Nudge up: `nudge(reel, { distance: 2, direction: 'reverse' })` moves the whole column, and the two cards above scroll out through the top. - Expand up: the landed anchor is already one sprite three cells tall, with its body under the mask. Tween its view up two cells so it grows over the cards, then call `setColumn(reel, { visible: ['tall', ...] })` to commit the block at the top of the column. The rest of the board stays put. In engine terms this is an expanding wild. `getBlockBounds` reports the whole block even while part of it is in a buffer. The mask does the clipping. Live demo (tall-peek-nudge-up): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#tall-peek Live demo (tall-peek-expand-up): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#tall-peek #### Reel shapes ##### Pyramid A set whose reels show 3, 5, 5, 5 and 3 cells. The shape is fixed at build time with `visibleCellsPerReel`. Live demo (pyramid-shape): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#pyramid-shape ##### Pyramid with Spine The same pyramid with a Spine skeleton in every cell. The rigs stay sharp at each reel's cell size. Live demo (spine-pyramid-shape): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#spine-pyramid-shape ##### MultiWays Each reel lands on a different cell count every spin, and the number of ways is the product of the cell counts. Call `setShape(cellsPerReel)` before `setResult()` on every spin. Live demo (multiways): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#spine-pyramid-shape ##### MultiWays cascade A MultiWays shape on a normal strip landing, followed by a cascade that removes the ways winners and drops new symbols in from above. Call `setShape` before `setResult`, and start the round with `spin({ mode: 'standard' })` so `AdjustPhase` reshapes the reels between the spin and stop phases. Live demo (multiways-cascade): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#spine-pyramid-shape ##### Sticky wild on MultiWays A pin keeps its place across reshapes through its remembered `originCell`, with the default `migration: 'origin'`. It moves in when the reel shrinks and returns when the reel grows back. With `'frozen'`, each clamp rewrites the origin, so the pin never moves back. Live demo (sticky-wild-multiways): https://pixi-reels.schmooky.dev/mechanics/big-symbols/#sticky-wild-multiways ### Cascades URL: https://pixi-reels.schmooky.dev/mechanics/cascade/ Winning symbols burst, the rest fall into the gaps and new ones drop in, until nothing else wins. Tags: cascade, tumble, refill, anticipation, spine, thunderkick, horizontal, reverse, orientation, gravity A cascade round has two different moments. Keeping them apart makes [`.tumble()`](/reference/api-builder/#tumble) and [`refill()`](/reference/api-reelset/#cascade-tumble) 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. #### The three phases The engine runs both moments with three `ReelPhase` subclasses: | Phase | Fires on | What it does | |---|---|---| | `cascade:fall` | Moment A, the `spin()` call | Tweens every visible symbol off the bottom of the viewport, then waits at speed 0. | | `cascade:place` | Both moments | Swaps 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:dropIn` | Both moments | Tweens 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: | Event | When | What it is for | |---|---|---| | `cascade:chain:start` | A chain stage opens, after `detectWinners` and before `destroySymbols` | A per-chain sound cue, a chain counter, freezing the spin button. | | `cascade:destroy:start` / `cascade:destroy:end` | Around every `destroySymbols(...)` batch, direct calls included | A shatter sound, a viewport dim independent of `destroyOptions.dim`. | | `cascade:chain:end` | A chain stage closes, after the refill drop-in settled | Per-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: ```ts 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: 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: ```ts // 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: ```ts 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. ```ts await reelSet.runCascade({ detectWinners, nextGrid }); ``` #### Per-cascade options The options a tumble game usually sets: | Option | Default | When to set | |---|---|---| | `pauseAfterDestroyMs` | `250` | Lower it to 150 for a turbo mode, raise it to 500 for a slower round. | | `maxChain` | `32` | A safety cap. Raise it only if your game can legitimately exceed 32 cascades. | | `onCascade` | none | Runs 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. | | `signal` | none | An `AbortSignal` that cancels the chain. See [cancelling a chain](#cancelling-a-chain-via-abortsignal). | ```ts 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: ```ts 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: ```ts 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`](/reference/api-builder/#tumble)), 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 want | Look at | |---|---| | The smallest working cascade game | [Basic cascade](/mechanics/cascade/#cascade-6x5) | | Tumble motion compared | [Tumble motion](/mechanics/cascade/#tumble-feels) | | Refill orders compared | [Refill order](/mechanics/cascade/#refill-orders) | | The delay between the press and the fall | [Delay before the fall](/mechanics/cascade/#fall-delays) | | Cascades after a strip spin | [Opening the round with a spin](/mechanics/cascade/#spin-then-cascade) | | Cluster wins and cascades on MultiWays | [MultiWays cascade](/mechanics/big-symbols/#multiways-cascade) | | Win presentation with `WinPresenter` | [Removing winners](/mechanics/cascade/#cascade-destroy-and-present) | | The longer write-up | [`docs/recipes/tumble-cascade.md`](https://github.com/schmooky/pixi-reels/blob/main/docs/recipes/tumble-cascade.md) | #### Related references - [`ReelSetBuilder.tumble()`](/reference/api-builder/#tumble), the config fields and their defaults - [`ReelSet.refill`, `destroySymbols`, `runCascade`](/reference/api-reelset/#cascade-tumble), the signatures - [Cascade events](/reference/api-events/#cascade-tumble), the payloads ##### 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. Live demo (cascade-6x5): https://pixi-reels.schmooky.dev/mechanics/cascade/#cascade-6x4-tumble Live demo (cascade-6x5-spine): https://pixi-reels.schmooky.dev/mechanics/cascade/#cascade-6x4-tumble #### 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. Live demo (destroy-winpresenter): https://pixi-reels.schmooky.dev/mechanics/cascade/#cascade-wins-present-destroy-refill ##### 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. Live demo (destroy-fade): https://pixi-reels.schmooky.dev/mechanics/cascade/#cascade-wins-present-destroy-refill ##### Spine explosion The same board with `outAnimation: 'explode'` set at registration. `destroySymbols` plays the skeleton's explosion instead of the implode. Live demo (destroy-explode): https://pixi-reels.schmooky.dev/mechanics/cascade/#cascade-wins-present-destroy-refill #### 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. Live demo (fall-delay-instant): https://pixi-reels.schmooky.dev/mechanics/cascade/#lead-in-delay-before-the-fall Live demo (fall-delay-subtle): https://pixi-reels.schmooky.dev/mechanics/cascade/#lead-in-delay-before-the-fall Live demo (fall-delay-anticipation): https://pixi-reels.schmooky.dev/mechanics/cascade/#lead-in-delay-before-the-fall Live demo (fall-delay-suspense): https://pixi-reels.schmooky.dev/mechanics/cascade/#lead-in-delay-before-the-fall ##### 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'`). Live demo (refill-simultaneous): https://pixi-reels.schmooky.dev/mechanics/cascade/#cascade-refill-orders Live demo (refill-ltr-wave): https://pixi-reels.schmooky.dev/mechanics/cascade/#cascade-refill-orders Live demo (refill-bottom-up): https://pixi-reels.schmooky.dev/mechanics/cascade/#cascade-refill-orders ##### 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. Live demo (tumble-classic): https://pixi-reels.schmooky.dev/mechanics/cascade/#tumble-feels-every-preset Live demo (tumble-cartoon-bounce): https://pixi-reels.schmooky.dev/mechanics/cascade/#tumble-feels-every-preset Live demo (tumble-slam): https://pixi-reels.schmooky.dev/mechanics/cascade/#tumble-feels-every-preset Live demo (tumble-rain-column): https://pixi-reels.schmooky.dev/mechanics/cascade/#tumble-feels-every-preset Live demo (tumble-wave): https://pixi-reels.schmooky.dev/mechanics/cascade/#tumble-feels-every-preset ##### 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. Live demo (tumble-anticipation): https://pixi-reels.schmooky.dev/mechanics/cascade/#cascade-anticipation-refill Live demo (tumble-anticipation-stagger): https://pixi-reels.schmooky.dev/mechanics/cascade/#cascade-anticipation-refill #### 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. Live demo (spin-then-cascade): https://pixi-reels.schmooky.dev/mechanics/cascade/#spin-first-cascade-after Live demo (cascade-open-drop): https://pixi-reels.schmooky.dev/mechanics/cascade/#spin-first-cascade-after Live demo (spin-then-cascade-turbo): https://pixi-reels.schmooky.dev/mechanics/cascade/#spin-first-cascade-after #### 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]`. Live demo (cascade-horizontal-tumble): https://pixi-reels.schmooky.dev/mechanics/cascade/#cascade-sideways ##### 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. Live demo (cascade-drain-upward): https://pixi-reels.schmooky.dev/mechanics/cascade/#drain-upward-gravity-follows-travel ##### 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. Live demo (cascade-reverse-gravity): https://pixi-reels.schmooky.dev/mechanics/cascade/#spin-up-drop-down-explicit-gravity #### 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. Live demo (peek-from-above): https://pixi-reels.schmooky.dev/mechanics/cascade/#peek-symbol-from-buffer-start ### Paylines and overlays URL: https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/ Find any cell on screen to draw paylines, badges and highlights over the board, or to make a cell tappable. Tags: paylines, hit-areas, overlays, wins, horizontal, orientation `reelSet.spotlight` dims the losing symbols, lifts the winners above the mask, and can step through several lines in turn. #### One win, one line ```ts reelSet.events.on('spin:complete', async (result) => { const wins = detectWins(result.symbols); // your logic if (wins.length === 0) return; // positions: [{ reelIndex, cellIndex }, ...] await reelSet.spotlight.show(wins[0].positions, { dimAmount: 0.3, playWinAnimation: true, }); }); ``` #### Several lines in turn ```ts await reelSet.spotlight.cycle( wins.map((w) => ({ positions: w.positions })), // WinLine[] { displayDuration: 1000, // ms per line. Default 2000 gapDuration: 300, // ms between lines cycles: 1, dimAmount: 0.3, // losers fade to 30% }, ); ``` #### Symbol animations With `playWinAnimation: true` the spotlight calls `playWin()` on each highlighted symbol. The three built-in symbol classes all implement it. ```ts await reelSet.spotlight.show(wins[0].positions, { playWinAnimation: true }); ``` `show()` resolves when the animation is done, so you can await it before the next step. #### Events `spotlight:start` and `spotlight:end` bracket a `cycle()`. Use them to disable the spin button while a win plays. ##### Demos `reelSet.getCellBounds(reel, cell)` returns the screen rect of a visible cell. Paylines, win outlines and hit areas are all drawn from it, so they line up with the symbols. The engine itself draws no paylines. For a banner reel above the grid, see [Sideways and upward reels](/mechanics/orientation-and-direction/#horizontal-banner). #### Cell rects The rect of any visible cell, used here to outline cells and draw a line through them. Live demo (cell-bounds): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#cell-bounds-overlays-paylines--hit-areas #### Paylines ##### From win events `WinPresenter` animates the winning symbols and draws nothing else. Subscribe to `win:group` and draw each line from `getCellBounds`. `win:symbol` fires per winning symbol, for anything drawn per cell. Live demo (paylines-events-only): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#draw-paylines-yourself-from-wingroup ##### With WinLines `WinLines` from `pixi-reels/debug` draws the cells it is given. A payline is one stroke through one cell per reel. A payway joins every winning cell to every winning cell on the next reel. The demo alternates: one spin pays ten fixed lines and draws each as the presenter reaches it, the next pays ways and draws all of them at once. Live demo (win-lines): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#paylines-and-payways-with-winlines #### Tappable cells One pointer target per cell, built from `getCellBounds`. Hover previews a cell, a click toggles a pick, and picks stay through spins. Fill the hit rect with alpha 0 rather than setting `visible = false`. A transparent filled rect still receives pointer events; a hidden one does not. Live demo (cell-hit-areas): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#cell-hit-areas-click-to-pick-hover-to-preview #### Horizontal sets ##### Rects `getCellBounds(reel, cell)` takes the same arguments on either axis, and (0, 0) is still the first cell of the first reel. The rect it returns is transposed: on a horizontal set the reel index goes down the screen and the cell index goes across it. So a line through the same cell index on every reel runs vertically here, where the same code draws a horizontal line on a vertical set. Read the rects instead of working them out from the indices. Live demo (cells-horizontal-bounds): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#cell-bounds-on-a-horizontal-set ##### Hit areas The same loop over reels and cells as the vertical demo, with no orientation check. The rects are already in screen space, so the hit areas sit on the symbols either way. Live demo (cells-horizontal-hit-areas): https://pixi-reels.schmooky.dev/mechanics/cells-and-banners/#hit-areas-on-a-horizontal-set ### Spin feel URL: https://pixi-reels.schmooky.dev/mechanics/feel/ Tune how a spin starts and stops: the stagger between reels, a wind-up, the kick on landing. Tags: phases, steps, timing, fx, anticipation, speed, skip A speed profile holds the numbers that decide how a spin feels, such as the acceleration, the spin speed, the stagger between stops and the bounce. #### The three defaults ```ts import { SpeedPresets } from 'pixi-reels'; // SpeedPresets.NORMAL relaxed feel // SpeedPresets.TURBO faster stop, short acceleration // SpeedPresets.SUPER_TURBO almost instant ``` A builder with no `.speed()` call gets `NORMAL` under the name `'normal'`. #### Switch at runtime ```ts reelSet.speed.addProfile('turbo', SpeedPresets.TURBO); reelSet.setSpeed('turbo'); reelSet.events.on('speed:changed', (p, prev) => console.log(p.name, prev.name)); ``` #### Custom profile ```ts const CINEMATIC: SpeedProfile = { name: 'cinematic', spinDelay: 280, spinSpeed: 38, stopDelay: 180, anticipationDelay: 1200, bounceDistance: 14, bounceDuration: 260, accelerationEase: 'power3.in', bounceEase: 'elastic.out(1, 0.5)', accelerationDuration: 420, minimumSpinTime: 1400, }; builder .speed('cinematic', CINEMATIC) .initialSpeed('cinematic'); ``` The engine fires events for each moment of a round, and your audio engine plays sounds. `attachReelSounds` connects the two with a table that says which sound plays on which event, when a loop starts and when it fades out. #### The cue table ```ts import { createEngine } from '@schmooky/zvuk'; import { attachReelSounds, zvukPort } from 'pixi-reels'; const engine = createEngine({ buses: { reels: {}, anticipation: {}, wins: {}, ui: {} } }); await engine.unlock(); // from a gesture await engine.loadSound('spin', ['/sfx/spin.webm', '/sfx/spin.m4a'], { bus: 'reels' }); await engine.loadVariants('reel-stop', [ ['/sfx/reel-stop.1.webm', '/sfx/reel-stop.1.m4a'], ['/sfx/reel-stop.2.webm', '/sfx/reel-stop.2.m4a'], ], { bus: 'reels' }); // ... anticipation, skip, win, pop const sounds = attachReelSounds(reelSet, zvukPort(engine), { spin: { play: 'spin' }, reelStop: { play: 'reel-stop', pitch: { jitter: 0.04 }, delay: ({ profile }) => profile.bounceDuration / 2000 }, anticipation: { loop: 'anticipation', fadeIn: 0.12, fadeOut: 0.25, pitch: ({ order }) => 1 + 0.08 * order }, skip: { play: 'skip' }, win: { play: 'win' }, cascadeDestroy: { play: 'pop' }, }); sounds.destroy(); // when the reel set goes ``` The demos on this site run a table like this one. `reelSounds(reelSet)` from `@pixi-reels/kit/sound` attaches it to a set, using one audio engine for the whole page, and `boardSounds(board)` does the same for a Hold & Win board. The Sound button under a demo mutes it. The files load on the first press. The spin cue plays once per spin. A loop under every spin (`spin: { loop: 'spin-loop', fadeIn: 0.05, fadeOut: 0.08 }`) is supported and fades out on the last landing, but on a page with many demos it gets tiring. The reel stop sounds are enough to mark the rhythm. #### The beats | Cue | Starts on | A loop ends on | Context | |---|---|---|---| | `spin` | `spin:start` | `spin:allLanded` | | | `reelStop` | `spin:reelLanding`, on every landing path, cascade refills included | | `reelIndex` | | `anticipation` | `anticipation:reel`, one per teasing reel | that reel's `anticipation:reelEnd` | `order`, `total`, `reelIndex` | | `skip` | `skip:requested` | | | | `win` | `spotlight:start`, and `win:group` per presented win | | | | `cascadeDestroy` | `cascade:destroy:start` | | | | `on[event]` | the named event | its `until` event | | Every context also carries `speed` (the active profile's name), `profile` (the profile itself) and `mode` (`'standard'`, or `'cascade'` for a tumble and its refills). The default table the demos run uses `on` for events outside the spin lifecycle. It plays a shove on `nudge:start`, a tick on `column:set` when a symbol splits or a column changes, a rising sweep when a set gains cells or reels (`expand:stepAdded`, `reels:added`, `rows:added`), and a soft pop on `pin:placed`. #### A Hold & Win board `attachBoardSounds(board, port, cues)` is the same table over a board's beats: `featureEnter`, `respinStart` (a loop that runs until `respin:end`), `cellLanded` (with `reelIndex`, `cell` and `hit`), `coinLocked`, `boardFull`, `featureEnd`, and `on` for any other board event. The demos play a quiet kick per respin, a thud when a coin lands, a ring a moment after it locks, and the win sound once when the feature ends. Empty cells land without a sound. A cue is `{ play: name }` for a one-shot or `{ loop: name, fadeIn, fadeOut }` for a bed. `volume` and `pitch` take a number, a `{ base, jitter }` spread so repeated thuds do not sound cloned, or a function of the context. The tease cue above climbs about a semitone per reel, and a spin cue can read `speed` to pitch up in turbo. `delay` is the time in seconds between the event and the sound. The demos delay the thud by half the profile's `bounceDuration`, which is when the reel reaches the bottom of its bounce. Without the delay it would play on the frame the reel snaps. `when(ctx)` keeps a cue quiet. On a tumble, where the symbols drop in one by one, the demos play the kick and the thuds at half level with no delay. Loops are tracked per event, so there is one tease loop per reel. They fade out when their beat ends and stop at once on `destroy()` or when the reel set is destroyed. #### Any engine `attachReelSounds` only needs a `ReelAudioPort`: a `play(name, { bus, volume, pitch })` method and a `loop(name, { ..., fadeIn })` method that returns `{ stop({ fade }) }`. `zvukPort` is that port over a zvuk engine. A variants set plays its next take, and a missing name is skipped with one warning. Wrap Howler or raw Web Audio the same way. ##### Demos These demos change how a spin starts and stops. The first two react to a reel landing. The rest edit the step lists the built-in phases run. #### Landing ##### Landing events `spin:reelLanding` fires on the frame a reel reaches its result: the strip has snapped, every symbol has been told it landed, and the bounce is about to start. `spin:reelLanded` fires once the bounce has settled, a whole `bounceDuration` later, or on the same tick after a slam. Hang anything tied to the landing itself on the first one. The demo grows a takeover plate over the copy reels on `spin:reelLanding` and prints the gap between the two events. Live demo (landing-signal): https://pixi-reels.schmooky.dev/mechanics/feel/#landing-the-frame-and-the-beat ##### Spine landing animation Each symbol hears the same moment through `onReelLanded(ctx)`, with the reel and cell it landed in. A Spine symbol's `autoPlayLanding` can be a function of that context. It returns `true` for the configured landing animation, `false` for none, or an animation name to play something else. Here the copy reels land with no animation, so nothing competes with the takeover, and the last two reels play a reveal as their landing. Live demo (spine-landing-rule): https://pixi-reels.schmooky.dev/mechanics/feel/#spine-landing-rule #### Editing the step lists The built-in phases run named step lists. `StartPhase` runs `delay, launch, pull, accelerate, announce`, `StopPhase` runs `delay, spinOut, land, bounce`, and `AnticipationPhase` runs `tease`. Registering a phase with `f.register('stop', StopPhase, { steps })` passes you the list before it runs. Each demo below changes it with one `insertBefore`, `insertAfter` or `replaceStep` call, or builds the list by hand. Slam and quicken keep working because the waits stay marked `cut`. The step API is on the [Phases page](/reference/api-phases/#steps). ##### Landing kick One step after `land` and before `bounce`. The reel set kicks and a puff of dust spreads under the reel, harder on the last one. The step returns nothing, so the bounce starts on the same frame. If it returned the tween, the phase would wait for it before bouncing. That return value is what decides whether a step is an effect or a beat. A slam lands the reel through `onSkip`, not through the list, so a step after `land` does not run on a slam. Effects that must also play on a slam belong on `spin:reelLanded`. A quicken keeps the list. Live demo (steps-land-impact): https://pixi-reels.schmooky.dev/mechanics/feel/#a-landing-kick-with-dust ##### Stagger curves The flat stagger arrives as `ctx.config.delay`, and the `delay` step is the only place it is used. So a curve is one `replaceStep` per phase. Here the start ripples out from the middle reel, and the gaps between stops grow, so reels 1 to 3 land quickly and reel 5 hangs. The profile still sets the unit. The second line of the readout shows measured landings, not the schedule. Keep `{ cut: true }` on the replacement. It is a wait, and a quicken press has to cut it the same way it cuts the flat one. Live demo (steps-stagger-curve): https://pixi-reels.schmooky.dev/mechanics/feel/#steps-stagger-curve ##### Wind-up launch The built-in `pull` moves the reel back two pixels. This demo replaces it with a pull of most of a cell, inserts a `hold` after it, and leaves `accelerate` as it is, so the reel accelerates from wherever the pull left it. Tap the readout to turn the wind-up off and compare. Handle both motion models the way the built-in step does. Under the drive model, set a `targetSpeed` and wait. Under the tween model, tween `reel.speed`. `reel.hasDrive` tells you which one is active. Live demo (steps-windup-start): https://pixi-reels.schmooky.dev/mechanics/feel/#a-wind-up-launch ##### Extra wait on the last reel Every reel runs the same list, so a beat for one reel is a step that does nothing on the others. `suspense` waits 700 ms before reel 5's spin-out and returns at once on the other reels. The backlight pulses while it waits. A step that starts something has to stop it on every way out. `ctx.wait` resolves early when the step is cut, and `ctx.signal` fires when it is cancelled, so one `stop` call covers the natural end, a quicken and a slam. Live demo (steps-last-reel-suspense): https://pixi-reels.schmooky.dev/mechanics/feel/#one-extra-beat-on-the-last-reel ##### Spotlight around the tease `AnticipationPhase` runs one step and is created only on the teased reel. To shade the other reels while the tease runs, build the list by hand around the built-in step: `[dim, ...steps, lift]`. Both added steps are awaited, 150 ms each, so the shade is on before the reel starts to crawl and off before the stop phase takes over. A slam cancels the list in flight and `lift` never runs, so also clear the shades on `spin:complete`. A quicken cuts the `tease` step and `lift` still runs. Live demo (steps-anticipation-spotlight): https://pixi-reels.schmooky.dev/mechanics/feel/#a-spotlight-around-the-tease #### Steps that read the speed profile ##### Per speed mode `ctx.profile` is the profile the game registered under the active speed name, custom fields included. A `breath` step before the spin-out and a `glow` step after `land` both read it, so normal gets both and turbo gets neither, and the glow's fade follows `bounceDuration`. Tap the readout to switch speeds. The skip button here calls `requestSkip({ mode: 'quicken', speed: 'turbo' })`, which switches the profile the same way. Do not check for turbo inside a step. Put the decision on the profile, and every speed mode you add later carries its own setting. Live demo (steps-fx-per-profile): https://pixi-reels.schmooky.dev/mechanics/feel/#beats-and-fx-that-follow-the-speed-mode ##### Profile sections The demo above puts a step's settings on the profile as flat fields. That works, but every phase sees them and nothing says which phase they belong to. A section does. Both steps here are inserted into `StopPhase`, so their settings live under `stop`, keyed by step name. The `whenAnticipated` half is merged on top for a reel that teased, so reels 4 and 5 land with a deeper bounce and a heavier impact, and the same step draws them amber based on `ctx.anticipated`. Nothing checks the speed name. ```ts stop: { steps: { breath: { duration: 140 }, impact: { lift: 8, duration: 420 } }, whenAnticipated: { bounceDistance: 30, steps: { impact: { lift: 24 } } }, } ``` A step reads its own entry as `ctx.step`, in segment order. One object in the profile arrives as one entry; a list is for a step written to read several segments. Declare the two names once by merging them into `StopSteps`, and `stop.steps` is type-checked and autocompleted like the built-in steps. `whenAnticipated` applies only to a tease that ran to the end. Press skip mid-tease and that reel uses the section's base settings (blue puff, small lift), because the press cut the tease the variant is there to follow. Live demo (steps-profile-sections): https://pixi-reels.schmooky.dev/mechanics/feel/#a-step-you-added-tuned-from-the-profile ### Hold & Win URL: https://pixi-reels.schmooky.dev/mechanics/hold-and-win/ Coins stick where they land and the empty cells respin until the counter runs out or the board fills. Tags: hold-and-win, coins, collector, respin, spine, horizontal, reverse, orientation, rectangular, clovers Hold & Win, also sold as Lock & Respin or Hold & Spin, is a feature where coins land, stick, and refill a respin counter until the board fills or the respins run out. pixi-reels ships it as a built-in board: ```ts import { HoldAndWinBuilder } from 'pixi-reels'; ``` The demos above each show one technique. This part explains how the board works as a whole and how a game client drives it. #### How the board is built A Hold & Win board is a grid of cells that spin independently. The engine spins in columns, each a `ReelSet`, but the mechanic works in cells. So each cell is its own 1x1 reel set, and `HoldAndWinBuilder` lays out the grid and runs the round across them. The board does not know what a coin is worth. A coin is an opaque record: ```ts { cell: { reel, cell }, id: 'coin', data: /* anything you want */ } ``` The `id` picks the registered symbol art. The `data` belongs to you and can hold values, jackpot tiers, multipliers or collector flags. The board never reads it. Adders, doublers, collectors and flights to a meter are game logic you write on top of the board, using these: | API | What it gives you | |---|---| | `board.events` | each step of the round, with the coin payload | | `board.symbolAt(cell)` | the live symbol instance, so you can call your own symbol's methods | | `board.cellCenter(cell)` / `board.cellBounds(cell)` | exact pixel geometry for flights and trails | With that split, a new Hold & Win variant is mostly game code and the board stays the same. #### The round The board is a three-state machine. `board.phase` reports where it is: `'idle'`, `'active'` or `'spinning'`. 1. `enter(seed)` seeds the board with the trigger coins. They lock at once, without a spin, and the respin counter arms. The board goes from idle to active. 2. `respin(hits)` spins each free cell. The cells named in `hits` land their coins and the others land blank. The board goes from active to spinning and back. If a coin landed in this wave the counter resets to full. If nothing landed it goes down by one. 3. The feature ends when the board fills or the counter reaches zero, and the board returns to idle. Then you collect. ##### Events in one respin Events come in a fixed order. Cells land in stagger order, so the landing and lock events arrive one at a time: #### Driving it from your game client The board runs the animation of each round. You own the loop and the source of results, which can be an RGS, a mock server or an RNG. The driver is short: ```ts const board = new HoldAndWinBuilder<{ value: number }>() .grid(5, 3) .cellSize(72, { gap: 4 }) .symbols((r) => r.register('coin', CoinSymbol, COIN_OPTS)) .weights({ coin: 1, empty: 4 }) // how often coins flash past during the spin .respins(3) .ticker(app.ticker) // required: drives every cell's reel .build(); app.stage.addChild(board.container); // React to the round however your game presents it: HUD, sounds, flights. board.events.on('coin:locked', ({ coin, locked, capacity }) => { hud.total += coin.data?.value ?? 0; // you own the value; the board does not hud.text = `${locked} / ${capacity}`; }); // 1. trigger board.enter(await server.triggerCoins()); // 2. the respin loop: one round per iteration, you pace it while (true) { const round = await server.nextRound(board.freeCells); // your result source const result = await board.respin(round.hits); // the board animates the wave if (result.done) break; // full or out of respins // anything between rounds (celebrate, delay, play a teaser) happens here } // 3. collect: release the coins and fly them wherever you like for (const coin of board.lockedCoins) flyToMeter(board.cellCenter(coin.cell), coin.data?.value ?? 0); board.release(board.lockedCoins.map((c) => c.cell)); ``` `respin()` resolves only after the whole wave has landed and the counter has been updated, so the loop reads top to bottom. For a [skip button](/mechanics/hold-and-win/#hold-and-win-skip), call `board.skip()`. It slams each cell that is still spinning. The landing, lock and feature-end events still fire, so the rest of your code does not change. The quicken form, `board.skip({ mode: 'quicken' })`, lands the cells instead of cutting them. Each spinning cell drops its minimum spin time, so the wave lands together, and each cell still spins its symbol in and bounces. Add `speed: 'turbo'` to land it on turbo, or make quicken the board's default with `skipMode('quicken')` on the builder. #### Events Each event carries your `TData` on its coins. | Event | Payload | Fires when | |---|---|---| | `feature:enter` | `{ seed, respins }` | `enter()` seeds the board | | `respin:start` | `{ round, respinsLeft, spinning }` | a wave begins | | `cell:landed` | `{ cell, coin }` (`coin: null` on a miss) | each cell settles, in stagger order | | `coin:locked` | `{ coin, locked, capacity }` | a hit cell locks | | `cells:activated` | `{ cells, capacity }` | `activate()` woke dormant cells; `capacity` is the new full-board count | | `speed:changed` | `{ name, previous }` | `setSpeed()` moved every cell to another profile | | `respins:changed` | `{ value, reason }` | the counter changed (`seed`, `hit-reset` or `miss`) | | `respin:end` | `{ round, hits, respinsLeft }` | the wave finishes | | `board:full` | `{ coins }` | the last free cell locks | | `feature:end` | `{ coins, rounds, full }` | the feature is over and the board is idle | | `coin:released` | `{ coin, remaining }` | `release()` removed a coin (the collect moment) | | `feature:reset` | `{ clearedCoins }` | `reset()` hard-cleared the board | | `feature:skip` | `{ inFlight, mode, speed?, payload? }` | `skip()` freed the in-flight cells, placed (`'slam'`) or landing through their stop (`'quicken'`). `speed` and `payload` are the press's options as given | `release()` means "collect this coin" and fires `coin:released` once per coin. `reset()` is a hard clear back to idle and fires a single `feature:reset`, so a HUD that counts down on collect does not tick on a reset. `setSymbolAt(cell, id, data)` rewrites a locked coin in place, for example a coin becoming MINI and then MAJOR, and keeps the board's ledger correct. It throws on a free cell. New tracked coins are placed only by `enter` and `respin`. #### Other builder options Production boards often need more than the square default. These builder options cover cell shape, the lock animation and cells that start outside the feature: ```ts const board = new HoldAndWinBuilder() .grid(5, 3) // art is 202x170: a seam between columns, rows touching .cellSize({ width: 101, height: 85 }, { columnGap: 6, rowGap: 0 }) // 'win' (default) plays playWin() on every lock; 'landing' plays the // symbol's playLanding() settle instead; 'none' plays nothing .lockAnimation('landing') // built, drawn as `sealed`, but outside the feature until activate() .inactive(row(0).concat(row(4)), 'sealed') ... ``` With `'landing'` or `'none'` the celebration is up to you. `await board.playWin()` pulses each locked coin, and `board.playWin(cells)` pulses a subset. Call it when the game decides, usually on `board:full` or after `feature:end`. Some coins start their own landing beat when they land, such as a Spine coin with `autoPlayLanding` or a sprite that reports its settle through `trackLanding`. They keep it. `'win'` waits for that beat before the celebration, and `'landing'` does not play it a second time. The mode can also be a function of the coin that locked, so a collector celebrates while plain coins only settle: ```ts .lockAnimation((coin) => coin.id === 'collector' ? 'win' : 'landing') ``` `board.activate(cells)` wakes dormant cells between waves. They show the empty symbol, join the next respin and count toward `isFull` from then on. `reset()` seals them again. The rectangular cells, landing only and growing board demos above show each of these. #### Draw order between cells Each cell is its own reel set, so a coin's `zIndex` only sorts it against its own cell's buffers. Art that the engine lifts above a cell's mask at rest (`unmask: true`) renders in one layer above all cells, in attach order, which is column by column. As a result the next column covers the overflow of a lower coin. `cellZIndex` makes that layer sortable, and the board asks it for each cell's order on each place and landing: ```ts .cellZIndex(({ cell, symbolId, cols }) => (symbolId === 'grand' ? 1000 : 0) + cell.cell * cols + cell.reel) ``` `board.liftedLayer` is that layer, for an effect that has to sit between the cells and their lifted art. `symbolZIndex(resolver)` is the per-symbol form from `ReelSetBuilder`, applied inside each cell. See [big symbols](/mechanics/big-symbols/#zindex-layering). #### Speeds Each cell is its own reel set with its own `SpeedManager`. The board registers speeds in all of them and switches all of them together: ```ts const board = new HoldAndWinBuilder() .speeds({ normal: NORMAL, turbo: TURBO, superTurbo: SUPER_TURBO }) ... board.setSpeed('turbo'); // every cell, at once; fires speed:changed board.addSpeed('cinematic', slow); // one more, after build ``` Cells land in a diagonal wave, and the wave's step is the active profile's `stopDelay`. On a reel set that value is the time between reels stopping. On a board it is the time between steps of the wave. Each cell spins `(reel + cell) * stopDelay` ms on top of the profile's `minimumSpinTime`, so NORMAL's 140 ms steps the wave and TURBO's 0 lands all cells together. `.stagger(fn)` replaces the shape of the wave. It receives the speed's name and profile: ```ts .stagger((reel, cell, speed, profile) => reel * profile.stopDelay) // column by column .stagger((reel) => reel * 120) // fixed, whatever the speed ``` The rule is the same as for `reelSet.setSpeed()`. A cell already in flight finishes on the profile it started with, and the next wave runs on the new one. To cut a wave in progress on a turbo press, call `board.skip()`. To land it on turbo instead, call `board.skip({ mode: 'quicken', speed: 'turbo' })`. Each speed name also gets a `name:tension` variant that the board uses for an anticipating wave. #### When the board does not fit pixi-reels ships boards in two layers: - `BoardGrid` is the primitive. It is a grid of cells that each spin independently. It knows geometry, instances and spinning, and nothing about coins, locks, respins or value. - `HoldAndWinBoard` is one board built entirely on the primitive's public API. It adds the rules for locking, respins and collecting. If the built-in board does not do what your game needs, these are the options, from least to most work: 1. Configure it. Stagger, respins, weights, anticipation and cell chrome are all builder options. Most games stop here. 2. Build on the primitive. If your feature is not lock and respin at all, for example pick and reveal, cluster collect or a scratch card, skip `HoldAndWinBuilder` and use `BoardGrid` directly. The [board grid reveal demo](/mechanics/layers/#board-grid-reveal) is a board on the primitive that is not Hold & Win. 3. Fork the board. For lock and respin with different rules, copy `HoldAndWinBoard` and `HoldAndWinState` into your project and point their imports at `pixi-reels`. Everything they use (`BoardGrid`, `EventEmitter`, the `Hw*` types, `cellKey`, `HwEffect`) is public API, so the copy stays on supported ground. Then rewrite the reducer. The rule that a hit resets the respins and the rule that a full board ends the feature both live in `HoldAndWinState`. The board never reads your `data` and has no paytable. What a coin means is decided in your code, and the board only moves the reels. #### Where to go next - The [event trace](/mechanics/hold-and-win/#hold-and-win-trace) prints each event as it fires. - The [respin round](/mechanics/hold-and-win/#hold-and-win) is the smallest board. - A coin's value can live [in the coin's data](/mechanics/hold-and-win/#coin-value-data) or [in a symbol class](/mechanics/hold-and-win/#coin-value-symbol). - For collecting, see the [collector with flights](/mechanics/hold-and-win/#hold-and-win-collector) and [fly to a meter](/mechanics/hold-and-win/#hold-and-win-meter). - For tension on the last cell, see [anticipation](/mechanics/hold-and-win/#hold-and-win-anticipation). - To go from the base game into the feature and back, see [from the base game](/mechanics/hold-and-win/#hold-and-win-base-to-feature). ##### Demos The demos start with the smallest board and add one idea at a time. The last sections cover draw order and dimming, which most boards only need once the art is in. #### The basic board ##### Respin round Coins lock where they land and the free cells respin until the grid fills or the respins run out. The board runs the round. The coin values belong to your game. Live demo (hold-and-win): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win ##### Event trace A board plays a whole feature while each `board.events` event prints to a log as it fires. Use it to see the order of the round before you hook your HUD and sounds onto it. Live demo (hold-and-win-trace): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-trace ##### Sprite coins The board built from TexturePacker sprites, with no Spine runtime. The numbers blur while they spin and each coin plays a 30-frame flip when it lands. Live demo (hold-and-win-sprites): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-sprites ##### Spine coins The board with production Spine coins. MINI and MAJOR tiers reveal on lock, plaques sit beside the grid, and the collect flies the coins into a counter. Jackpot coins (MINI and MAJOR) are placed by the server only. Their weight is 0, so they never come up on a random strip. Live demo (hold-and-win-spine): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-spine #### Coin values ##### Value in the symbol class A `ReelSymbol` written from scratch that draws a coin with a number on it. The value is read back off the landed symbol. Start here if you have not written a symbol class before. Live demo (coin-value-symbol): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#coin-value-symbol ##### Value in the coin data The same coin, with the number kept in `data` instead of the class. One generic coin then carries whatever value the server sends, and the number is painted from `coin:locked`. Live demo (coin-value-data): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#coin-value-data ##### Number on existing art When the coin art already exists as a sprite, keep it and add the number on top as a second child of the symbol's view. Live demo (coin-value-overlay): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#coin-value-overlay ##### Coefficient values Each coin carries a coefficient between x2 and x50 in `coin.data`. The board locks the hits and respins only the free cells. The total is summed from `board.lockedCoins`. Live demo (value-coin-pin): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#value-coin-pin ##### Count-up coin Each coin's amount counts up from 0.00 to its value as it settles. The coins start in reading order, so the count runs across the board as a wave. Live demo (hold-and-win-countup-coin): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-countup-coin ##### Mystery value Coins land blank. On lock, a strip of candidate amounts spins inside the coin face and slows down onto the real value. Live demo (hold-and-win-mystery-coin): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-mystery-coin ##### Upgrade in place A held coin steps up the value ladder (5, 10, 25, 50, 100) with a flip and a pop. Nothing respins and no cell moves. Live demo (hold-and-win-upgrade-coin): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-upgrade-coin ##### Swap to a jackpot tier `board.setSymbolAt(cell, id, data)` puts a different symbol in one cell and rewrites that cell's entry in the board's ledger. Here a coin turns into MINI, then MAJOR, and the neighbouring coins stay where they are. Live demo (hold-and-win-tier-swap): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-tier-swap ##### Badge that survives a swap An x100 badge is stored in `coin.data` and attached as a child of the symbol's view. Because it is rebuilt from the data, it comes back after an in-place swap and travels with the coin on a collect flight. Live demo (hold-and-win-sticky-overlay): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-sticky-overlay #### Collectors and special coins ##### Collector When the collector orb locks, the game walks `board.lockedCoins`, flies the values of the orb's neighbours into it and calls `release()` on those cells. Live demo (collector-symbol-pin): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#collector-symbol-pin ##### Collector with flights A collector orb lands and pulls a copy of each coin's value along a bezier arc, adding to its total as each one arrives. Live demo (hold-and-win-collector): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-collector ##### Collector with particles The same collect, with a stream of particles trailing each value into the orb. Live demo (hold-and-win-collector-particles): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-collector-particles ##### Fly to a meter On collect, each coin's value flies into a meter above the reels. The meter adds up the total and fills a bar toward a target. Live demo (hold-and-win-meter): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-meter ##### Payer coin A payer orb lands and adds its value to each of the other coins. Changing one line turns it into a doubler. The payer is placed by the server only. Its weight is 0, so it never comes up on a random strip. Live demo (hold-and-win-payer-coin): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-payer-coin ##### Multiplier coin A multiplier coin lands, a strike effect plays, an xN badge pops and each coin's value is multiplied. Live demo (hold-and-win-multiplier): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-multiplier ##### Row jackpot When a coin completes a row, the row flashes coin by coin, the MINI plaque lights and the row total flies into it. Live demo (hold-and-win-row-jackpot): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-row-jackpot ##### Bonus cells Some cells are marked as bonus cells from the start. A coin that lands on one lights the cell and doubles its value. Live demo (hold-and-win-bonus-cell): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-bonus-cell #### Entering the feature ##### From the base game A normal 5x3 spin that drops into the Hold & Win board when 3 BONUS symbols land, in the same chain, and switches back on `feature:end`. Live demo (hold-and-win-base-to-feature): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-base-to-feature ##### Feature mode by middleware This one does not use the board. It switches a plain `ReelSet` into a bonus mode at runtime by adding a frame middleware, and back by removing it, with no rebuild. In the bonus mode the middleware turns some visible cells into WILD. Give your middleware a priority above 10, the priority of target placement, so it runs after the server's grid is placed and can react to it. The recipe uses 20. Live demo (feature-mode-swap): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#feature-mode-swap #### Pacing the wave ##### Last-cell anticipation The `anticipateWhen` builder option slows the last spinning cell to a tension profile, for the moment when one more coin would fill the board. Live demo (hold-and-win-anticipation): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-anticipation ##### Skip `board.skip()` puts each spinning cell at its landed position and fires `feature:skip`. `feature:end` is still the one event that says the feature is over. Live demo (hold-and-win-skip): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-skip ##### Quicken `board.skip({ mode: 'quicken' })` lands each spinning cell through its stop instead of placing it. The board's stagger lives in each cell's minimum spin time, so dropping it lands the whole wave together, and each cell still spins its symbol in and bounces. Add `speed: 'turbo'` to land the wave on the turbo profile, or call `HoldAndWinBuilder.skipMode('quicken')` to make quicken the default. `feature:skip` reports the count and the mode, and the landing events fire as usual. Live demo (hold-and-win-quicken): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-quicken ##### One speed switch `speeds(normal, turbo, superTurbo)` registers each profile in each cell's `SpeedManager`, and `board.setSpeed(name)` switches them all at once, the board's version of `reelSet.setSpeed()`. A wave already in flight finishes on its own profile, so a turbo press in the middle of a wave is `setSpeed` plus `skip()`. The landing wave steps by each profile's `stopDelay` (70, 25 and 0 ms here), so it tightens as the speed goes up and lands in one go on superTurbo, without a stagger function. Live demo (hold-and-win-clover-speeds): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-speeds ##### One cell at a time `board.reelAt(cell)` returns the cell's own 1x1 `ReelSet`. You can start it, slam-stop it and read the symbol in it without touching the other cells. Use this when a feature needs a cell to move outside the normal wave. Live demo (hold-and-win-cell-control): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-cell-control #### A clover game These demos use the art of one real game, where the coins are clovers. Each clover is a Spine 4.2 skeleton. ##### Base game into the feature A fruit base game. Gold clovers show bet-scaled money as they spin past, and the collect, multi, mystery and super clovers carry no amount. Three or more clovers on the stop hand their cells to the Hold & Win board. Live demo (hold-and-win-clover-base-game): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-base-game ##### Bonus board The feature on its own. Gold clovers lock with their amounts, the blank cells are the game's dark clover tile, and the 1 2 3 lamps below are the respin counter. Live demo (hold-and-win-clover-bonus): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-bonus ##### Respin counter Three lamps driven by `respins:changed` alone. Its `reason` says whether the count changed on seed, hit-reset or miss, so the lamps light or dim without the game working the count out again. Live demo (hold-and-win-clover-respin-counter): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-respin-counter ##### Feature clovers Clovers without an amount act on the held gold between waves. MULTI doubles each amount, MYSTERY becomes a gold clover with a revealed amount through `setSymbolAt`, and COLLECT adds the board up onto its own face. Live demo (hold-and-win-clover-feature-clovers): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-feature-clovers ##### Lightning collect Held clovers idle until the feature ends. When COLLECT locks, lightning strikes from it to each gold clover's number and the collect face counts the values into its own. The gold clovers keep their values, and the spent collector turns grey and stays held. Live demo (hold-and-win-clover-collect): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-collect ##### Mystery jackpot capsule The sealed capsule locks like a coin. Between waves the jackpot titles flick across its face through `setBadge` and stop on the tier the server sent. Then the plaque lights and the amount appears. Live demo (hold-and-win-clover-mystery-capsule): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-mystery-capsule #### Lock animation ##### Landing only `lockAnimation('landing')` plays the landing settle on each lock and nothing more. `board.playWin()` is the single celebration, called when the game decides. Live demo (hold-and-win-landing-only): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-landing-only ##### Per coin `lockAnimation` can be a function of the coin that locked. Here gold clovers settle with their landing only and COLLECT also celebrates. The celebration waits for the skeleton's own landing beat (`symbol.landing`) instead of replacing its track, so the landing plays first and the win follows. The HUD prints when each one finishes. Live demo (hold-and-win-clover-lock-rule): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-lock-rule #### Board size and cell shape ##### Rectangular cells Hold & Win art is usually wider than it is tall. `cellSize` takes a width and a height, plus a `columnGap` and a `rowGap`, so the board lays out to the art's own rectangle and the game's grid shows through the gaps. The clovers are the Spine 4.2 skeletons from the clover game, with idle, landing, win and blur tracks that the engine plays through `SpineReelSymbol`. Live demo (hold-and-win-rect-cells): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-rect-cells ##### 5x5 board The clover board with five rows, all cells live from the start. Live demo (hold-and-win-clover-bonus-5x5): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-bonus-5x5 ##### Growing board Built 5x5 with the top and bottom rows inactive behind a purple sealed tile. Holding enough clovers opens a row with `board.activate()`, and the next respin spins it too. Live demo (hold-and-win-clover-growing): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-growing ##### Background grid Real gaps between the cells (`columnGap` and `rowGap`) and no cell chrome, so the background shows through. Behind the board is a gradient panel and one rounded frame per cell, drawn with plain `PIXI.Graphics` on each cell's exact bounds. A rounded cell mask cuts the tiles' corners to match. Live demo (hold-and-win-clover-grid-bg): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-grid-bg ##### Rounded outer corners Each cell has its own mask. `cellMask` takes a function that is called once per cell with its column, its row and the board size, and returns that cell's mask strategy. Here the cells clip to a plain rectangle, except the four corner cells, which each round their one outer corner through `RoundedRectMaskStrategy({ radius, corners })`. With no gap, the fifteen masks read as one rounded window with the panel's radius. The info argument also carries `corners`, that same per-cell object worked out for you. Live demo (hold-and-win-outer-corners): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-outer-corners ##### Blur while spinning Each skeleton has a blur animation that swaps its body to a motion-blur frame, and `SpineReelSymbol` plays it while the reel moves. The two rows are identical except that the second one opts out of the blur track. Live demo (hold-and-win-clover-blur-strips): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-blur-strips #### Travel direction ##### Sideways The round on `.axis('horizontal')`. Each cell is its own 1x1 `ReelSet`, so the axis only decides which edge a coin scrolls in from. The board still lays out columns by rows, and a lock still claims one cell. Don't build this on a plain `ReelSet` with `.orientation('horizontal')`. There a reel is a whole row, so the row moves as one strip across the gaps and past the cells that should be locked. Live demo (hold-and-win-horizontal-lock): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-horizontal-lock ##### Upward The round on `.axis('vertical', 'reverse')`. It also shows the hold that goes with it. `respin()` spins `board.freeCells` and nothing else, and `respin:start` reports which cells are in flight. On a `ReelSet` the equivalent is `spin({ holdReels })`, which holds a whole reel. A board has no `holdReels` because Hold & Win holds single cells. Live demo (hold-and-win-reverse-respin): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-reverse-respin #### Draw order and dimming ##### Cell draw order Each cell is its own reel set, so the clovers the engine lifts above the cells at rest share one layer, drawn in attach order. That order is column by column, which lets the next column's clover cover a lower clover's glow. `cellZIndex` sorts the layer by whatever the board returns, here lower rows in front and the capsule above everything, and the board asks again on each place and landing. Live demo (hold-and-win-clover-cell-order): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-cell-order ##### Lift one cell `cellZIndex` is the order at rest, and the board asks for it again on each place and landing. A clover that must stay on top while it upgrades can't get there by returning a bigger number, because the next landing overwrites it during the animation. `board.lift(cell)` raises the cell on a separate channel and returns a release function. The refresh keeps running underneath without touching the lifted cell, and the release puts the cell back without recomputing anything. Live demo (hold-and-win-clover-lift): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-lift ##### Lift and dim `board.dim({ except })` goes with `lift()`. The dim draws above the clovers and below anything lifted, so a lifted cell stays in front of it whether or not it is in `except`. A dim covers cells, not symbol ids, so this collect works out which cells hold the gold clovers it is about to sweep and spares them. The money stays bright and the blanks go dark. The dim fades in and out over `fade` ms off the board's own ticker, and `fade: 0` cuts. Live demo (hold-and-win-clover-lift-dim): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-lift-dim ##### Dim the cell or the art There are two ways to push a board back. `dim()` lays a rectangle over each cell, so the clover goes dark along with the tile it sits in. `dimSymbols()` tints each symbol towards black instead, so the art sinks and the board stays lit. The same sweep runs twice in the demo, once with each. `amount` sets the strength on both, and both fade over `fade`. This is a board method rather than a few lines of `gsap.to` because a dimmed cell that swaps its symbol has to keep its dim, and the symbol that left has to lose its tint before the pool gives it to another cell. Live demo (hold-and-win-clover-dim-symbols): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-dim-symbols ##### Dimming one cell up close One cell, scaled up, holding a fruit instead of a clover so the cell's background shows all around the symbol. The blue plate is drawn by `cellChrome()` on the board, not by a symbol, so `dimSymbols()` never touches it. `amount` steps through 0.3, 0.6 and 0.9 and the plate stays the same. Then the same 0.6 through `dim()` takes the whole cell down. In the last step the cell is swapped to the empty id. There is no art left to dim, so `dimSymbols()` changes nothing, neither the symbol that has gone nor the plate. Watch for this on a real board. If your blank tile is a registered symbol, as the dark tile is in the clover demos (the `empty` id), it is art and `dimSymbols()` dims it too. Draw anything that must stay lit in `cellChrome()`, or name its cell in `except`. Live demo (hold-and-win-clover-dim-one-cell): https://pixi-reels.schmooky.dev/mechanics/hold-and-win/#hold-and-win-clover-dim-one-cell ### Infinity reels URL: https://pixi-reels.schmooky.dev/mechanics/infinity-reels/ The board gains reels on the right after the spin lands, as many as the result asks for. Tags: expand, addReels, removeReels, addRows, multiways, ways, big-symbols, skip, win-lines In an infinity reels slot the base spin lands, and while the win keeps going the board grows sideways, a reel at a time, for as long as the server's result says. In pixi-reels that is one call per round, `expand()`. #### The server's result The server decides the base board and every reel the board grows by, in order. Each reel is one `ColumnTarget`, the same shape `setResult()` takes. ```ts interface InfinityResult { base: ColumnTarget[]; // one per reel the builder made extra: ColumnTarget[]; // the reels the board grows by, in order; often none } ``` #### Spin the base, then expand ```ts const spin = reelSet.spin(); const res = await server.spin(); reelSet.setResult(res.base); await spin; await reelSet.expand({ columns: res.extra, step: 1, // reels added and spun per step onStepAdded: () => camera.panTo(reelSet.viewport.maskWidth), // the board's new width onStepLanded: (step) => showWin(step.result.symbols), // the whole board so far }); ``` Each step adds its reels, spins only those while every earlier reel is held, and lands them on their columns. The call awaits your hooks, so a camera pan or a win readout finishes before the next step. It validates every column before the first reel is added, so a bad result throws before the board changes. #### Shrink back next round ```ts reelSet.removeReels(); // back to the reels the builder made; a no-op when the board did not grow ``` #### Growing rows `addRows(count, { cells })` makes every reel `count` rows taller at its own cell size, and the viewport and mask grow with it. The `cells` option is what the new rows show, one array per reel, from the server. Inside an expansion, grow the rows between steps in `onStepLanded`. The reels after that arrive at the new height. `removeRows()` goes back to the rows the builder made. ```ts await reelSet.expand({ columns: res.extra, // a column may be taller than the board once a row unlocks onStepLanded: (step) => { const row = res.rows[step.index]; // the server's cells for an unlocked row, or nothing if (row) reelSet.addRows(1, { cells: row }); }, }); // next round reelSet.removeReels(); reelSet.removeRows(); ``` On MultiWays the rows are each reel's shape. The length of a column's `visible` array is that reel's cell count, inside the fixed reel height. #### Stacked symbols that split Some infinity slots land a symbol stacked two to four cells tall. When it wins, the stack splits into more single symbols than it had cells, and its reel grows past the frame. A stack is a big symbol one reel wide, and the server says what it splits into. ```ts // .symbolData({ Q3: { weight: 0, size: { reels: 1, cells: 3 } } }) const { from, count } = reelSet.splitSymbol(reel, cell, res.split); // e.g. six 'Q's ``` The reel grows by the difference. The cells above and below keep their symbols, and the board re-centres around the taller reel. Keep the other reels still on screen while your camera eases out, or they jump. Split at rest, or between steps in `onStepLanded`. Next round, `resetColumns()` puts every reel back. Any symbol one reel wide can split, a 1x1 too. To keep the reel's height instead, with its cells shrinking to share it, pass `{ height: 'keep' }`. That is the default on MultiWays, where a reel's height is fixed. For any other change to one reel, `setColumn` shows a column of any length. The [split symbols page](/mechanics/split-symbols/) compares the two modes and has a demo where you tap to split and a demo of splits on MultiWays. #### Counting and drawing ways The library computes no wins (ADR 007). The server does. The library helps you show them in two ways. The board's ways is the product of the reels' row counts: ```ts const ways = reelSet.reels.reduce((ways, reel) => ways * reel.visibleCells, 1); ``` Eight reels of three rows is 6,561 ways. Eight MultiWays reels of seven is 5,764,801. `WinLines` in `pixi-reels/debug` draws a payway as a lattice: every winning cell joined to every winning cell on the next reel. A win of millions of ways is still a few dozen segments. It draws the cells you pass it. ```ts import { WinLines } from 'pixi-reels/debug'; const lines = new WinLines(reelSet); lines.ways(win.perReel); // winning cell indices per reel, from your server: [[0, 2], [1], [0, 1, 2]] reelSet.events.on('spin:start', () => lines.clear()); ``` The demos on this site use `evaluateWays()` and `countWays()` from `@pixi-reels/kit/ways` in place of a server. Copy them if you want the same left-to-right ways math in a prototype. #### Skip The steps count as one round. The first `skipSpin()` lands the step in flight and speeds up the rest. In standard mode they run on the fastest profile, and in cascade mode every later step lands at once. A press between steps, while a hook runs, carries over to the next step. To land everything still to come at once, abort the expansion's `signal`. An aborted expansion lands the remaining reels in one step, at the height the board has at that moment. If your rows grow during the expansion, slam each step instead of aborting. #### Events | Event | When | |---|---| | `expand:start` | The chain starts: the board grows from `from` reels to `to`. | | `reels:added` | A step's reels are on the board. Move the camera here or in `onStepAdded`. | | `expand:stepAdded` / `expand:stepLanded` | A step's reels arrived or landed, before its hooks. | | `rows:added` / `rows:removed` | `addRows()` or `removeRows()` changed every reel's height. | | `column:set` | One reel changed its cells: `setColumn()`, `splitSymbol()` or `resetColumns()`. | | `expand:complete` | Every step landed. Carries the final board. | | `expand:end` | Always last, with `'complete'` or `'failed'`. Put the UI back here. | Each step also fires the usual `spin:*` events. `reelSet.isExpanding` tells them apart from a new round. ##### Demos The base spin lands, and then the board grows. `reelSet.expand({ columns })` adds the reels the server's result has beyond the base board, a step at a time, and spins only the new reels while the earlier ones hold. `addReels()` and `removeReels()` are the calls underneath it, and the next round shrinks the board back with `removeReels()`. The [infinity reels guide](/mechanics/infinity-reels/#concept) has the short version: what the server sends, the calls, and the events. The first demo is the plain mechanic. The next ones change the board's shape during the expansion, and the last covers skipping. #### Add one reel per step While the win still reaches the last reel, the server adds another reel to its result. Each step pans the camera to the new reel in `onStepAdded`, spins and lands it, then counts the ways and draws them with `WinLines` in `onStepLanded`. The steps count as one round for skipping. The first press slams the step in flight and switches the rest to turbo, the same boost `skipSpin()` gives the rest of any round. In cascade mode the later steps land at once instead, the way one press ends a cascade. The second press aborts the expansion's `signal`, which lands every reel still to come in one step. Live demo (infinity-reels): https://pixi-reels.schmooky.dev/mechanics/infinity-reels/#infinity-reels #### Board shape ##### Add rows A wild on a new reel unlocks a row. `addRows(1, { cells })` in `onStepLanded` makes every reel one cell taller, with the server's cells for the new row, and the reels after it arrive at the new height. The camera zooms out to fit, reading the board's size from `viewport.maskWidth` and `maskHeight`. The next round goes back with `removeReels()` and `removeRows()`. Rows change only between steps. Inside `onStepAdded` the step's reels are about to spin on columns sized for the board's old height, so `addRows()` throws there. A fast-forward, which aborts the `signal`, lands every remaining reel in one step at the board's height at that moment. That is why this demo's skip slams one step at a time instead. Live demo (infinity-reels-rows): https://pixi-reels.schmooky.dev/mechanics/infinity-reels/#infinity-reels-rows ##### MultiWays The length of each column's `visible` array is that reel's cell count, applied with `setShape()` for its step, so every reel the expansion adds multiplies the ways. Eight reels of seven cells give 5,764,801 ways, and ten give 282,475,249. Each step here adds two reels (`step: 2`). Live demo (infinity-reels-multiways): https://pixi-reels.schmooky.dev/mechanics/infinity-reels/#infinity-reels-multiways ##### Big symbols The steps add one reel each, but a 2x2 wild arrives in one of the columns. A step of one reel cannot land half a block, so that step adds two reels and the block lands whole. The step plan is read from the `symbolData` sizes, and every block is validated before the first reel is added. A block has to end on a reel the expansion adds. A block that would run past the last of them, or past the bottom of a strip, throws before any reel is added. Live demo (infinity-reels-big-symbol): https://pixi-reels.schmooky.dev/mechanics/infinity-reels/#infinity-reels-big-symbol ##### Split stacked symbols Q lands either one cell tall or stacked two to four cells tall. When Q wins on every reel, each stack splits into more single Qs than it had cells, and its reel grows past the frame in both directions. `reelSet.splitSymbol(reel, cell, ids)` places the server's split: the stack covering `(reel, cell)` becomes `ids`, one per cell, the cells above and below keep their symbols, and the board re-centres around the taller reel. While the win reaches the last reel, `expand()` adds another reel and the multiplier goes up by one. The next round goes back with `removeReels()` and `resetColumns()`. The [Split symbols](/mechanics/split-symbols/) page has a reel that keeps its height, splits on MultiWays and a playground where you tap to split. Because the board re-centres around the taller reel, hold the other reels still on screen and let the camera ease out, or they jump. This demo moves its camera by the amount they shift. Live demo (infinity-reels-split): https://pixi-reels.schmooky.dev/mechanics/infinity-reels/#infinity-reels-split #### Skipping steps Press as often as you like and read the log. The base board is grouped, shown by the dashed boxes, so a press lands one group. Each step's reel teases "will the win continue?" with `anticipation: { protect: 'once' }`, so the first press during a tease is spent and the next one lands the reel. A press while the camera pans is queued for the next step. The button calls `skipSpin()` and nothing else. Live demo (infinity-reels-skip): https://pixi-reels.schmooky.dev/mechanics/infinity-reels/#infinity-reels-skip ##### Skip policies - Turbo for the rest, the default. The first `skipSpin()` frees the step in flight and moves every later step to the fastest profile. The next round starts at normal speed again. - Slam each step. Every press frees the step in flight. Presses made during `onStepAdded` or `onStepLanded`, for example while the camera pans or a win readout shows, are kept and free the next step as soon as it has its result. - Fast-forward. Abort the expansion's `signal` and every reel still to come lands in one step. A quick-spin or autoplay mode can pass a signal that is already aborted, so the whole expansion lands at once, with the same events and hooks. - Quicken. With `.skipMode('quicken')`, or `requestSkip({ mode: 'quicken', speed: 'turbo' })`, a press shortens the step's spin but keeps its spin-out and bounce, so a long chain never looks cut. - One reel per press on wide steps. A step's reels arrive as one group. Call `setReelGroups()` in `onStepAdded` to split them so each press frees one, or use `slamStop({ reels: [...] })` to land part of a step and let the rest play. - Keep the deciding tease. `anticipation: (step) => stillWinning ? { protect: 'once', duration: 900 } : false` keeps the "will it continue?" tease through the first press, only on the steps where it matters. `slamStop()` between steps has nothing to land, and a press after the last step has no step left, so both do nothing. A named `setDropOrder('ltr' | 'rtl' | 'all')` follows the reels that spin, so it covers the added reels and orders a step by position. A sticky `setStopDelays()` array covers only the reels it was given, and reels past its end stop with no delay. #### What carries across steps - Events. Each step fires the usual `spin:*` events for its own reels, plus `reels:added`, `expand:stepAdded` and `expand:stepLanded`, and `rows:added` when a hook adds rows. The chain opens with `expand:start` and closes with `expand:complete` and then `expand:end`, which carries `'complete'`, or `'failed'` when the chain threw. `reelSet.isExpanding` is `true` in between, so a `spin:start` listener can tell a step from a new round. - Stagger. Start and stop delays count a reel's position in its step, not its index, so reel 40 does not wait forty delays. - Pins. A sticky pin's turns and an `'eval'` pin belong to the round, so a step does not use them up. - Memory. Added reels are real reels while they are on the board. `removeReels()` destroys them and shrinks the viewport, mask and symbol pool back. ### Layers URL: https://pixi-reels.schmooky.dev/mechanics/layers/ Draw a symbol over its neighbours or outside the reel frame, and build your own board out of the same cells. Tags: layering, zindex, unmask, spotlight, board Every symbol lives inside its reel, and every reel sits under the viewport mask. That works until a symbol's art is bigger than its cell, such as a scatter with a glow, a wild with a crown, or a winning symbol that should rise above the rest. There are three ways out, from smallest to largest. A `zIndex` in the symbol's data draws it above the other symbols in the same reel. Unmasking moves it to the layer above every reel and above the mask, so it can spill past the frame. Promoting raises one instance for as long as a win shows, then puts it back. `BoardGrid`, in the last demo, is the same cell layout without the reels: a grid you fill and animate yourself. ##### Demos The demos go from the smallest change to the largest: a `zIndex` inside one reel, unmasking above every reel, and raising one symbol while a win shows. The last demo builds a board out of cells with no reels. #### Within one reel A `zIndex` in `symbolData` draws the scatter above the other symbols in its reel, so its art is never covered by the cell below. The mystery bush keeps the default layer, and the cell below it draws over its leaves. This orders symbols within the reel only. Art that reaches over the next reel or past the frame needs `unmask`. Live demo (layering-scatter-zindex): https://pixi-reels.schmooky.dev/mechanics/layers/#symbol-layering-zindex-unmask-promote #### Above every reel ##### Unmasked symbols `unmask: true` in `symbolData` moves a landed symbol into the viewport's `unmaskedContainer`, above every reel and outside the mask. The scatter's art now spills past the grid edge and over the reel to its right, with no code in the demo. It works on jagged boards with centred reels too. Live demo (layering-unmask): https://pixi-reels.schmooky.dev/mechanics/layers/#symbol-layering-zindex-unmask-promote ##### Buffer cells stay masked Only visible cells are unmasked. The same id in a buffer cell stays under the mask, so oversized art never hangs into the window from a cell the player should not see. The demo lands both at once and holds through a skip. Live demo (unmask-stays-in-the-grid): https://pixi-reels.schmooky.dev/mechanics/layers/#symbol-layering-zindex-unmask-promote ##### Your own draw order The engine orders symbols by type first: `symbolData.zIndex * 100` plus the cell's stacking index. Some art specs order by row first: within a grade the lower row is in front, then the reel to the right, and only then a higher grade. Pass that rule to `symbolZIndex(resolver)` and the engine applies it after every wrap, swap and landing. Every mid and high symbol here is unmasked, so at rest they share one container and the resolver orders them against each other. While the reels move the resolver returns `ctx.defaultZIndex`, so the spin looks as it did before. Live demo (layering-graded-zindex): https://pixi-reels.schmooky.dev/mechanics/layers/#layering-graded-zindex #### One symbol at a time ##### With promote `reelSet.promote(positions)` raises the symbols at those positions above the mask and above their neighbours, and returns a function that drops them again. It attaches the views to a render layer instead of reparenting them, so nothing moves and nothing has to be put back. Unlike `spotlight.show()` it does not dim, does not call `playWin()` and has nothing to await, so the game's own animation stays in control. The same tween runs twice in the demo, once clipped and once promoted. Watch the top row swell past the grid edge. Live demo (clover-promote-win-line): https://pixi-reels.schmooky.dev/mechanics/layers/#clover-promote-win-line ##### By hand The older way to do the same thing. Each landed scatter's view is moved into `viewport.spotlightContainer`, the layer the win spotlight uses, and handed back to its reel on the next `spin:start`. The recipe stores each view's parent and position and restores them before the strip moves. Like `promote`, it raises one landed cell without making its id unmasked everywhere. Live demo (layering-promote-jagged): https://pixi-reels.schmooky.dev/mechanics/layers/#clover-promote-win-line #### Your own board `BoardGrid` is a grid of cells that each spin on their own. Hold & Win is built on it. This demo uses it directly for a reveal and collect prize grid: every cell spins to a prize, the values add up and the top cell is highlighted. There is no locking and no respin, because those are Hold & Win's rules and this board has its own. Live demo (board-grid-reveal): https://pixi-reels.schmooky.dev/mechanics/layers/#board-primitive-build-your-own-board ### Reel windows URL: https://pixi-reels.schmooky.dev/mechanics/masks/ Show the reels through a rounded window, a card per reel or any shape you draw. Tags: mask, rounded, silhouette, pyramid, jagged, frame The viewport clips the reels through a `MaskStrategy`, so buffer cells never show past the grid. The default is `RectMaskStrategy`, and the strategies below are options you add on top. | Board | Strategy | |---|---| | Square frame art | `RectMaskStrategy` (default) | | Rounded frame, reels flush | `RoundedRectMaskStrategy` (`scope: 'set'`) | | Reels as separate cards, with a cross gap | `RoundedRectMaskStrategy` (`scope: 'reel'`) | | Rounded frame, one rect per reel, any gap | `RoundedRectMaskStrategy` (`scope: 'outer'`) | | Hold & Win board, a mask per cell | `cellMask((cell, { corners }) => ...)` | | Pyramid or MultiWays, rounded, reels flush | `SilhouetteMaskStrategy` | | Hexes, holes, cut-outs | `PathMaskStrategy` | `inset(strategy, px)` shrinks any of them by a margin, and `composeMasks(a, b, ...)` joins several, your own strategies included. #### Writing your own Implement `build(ctx)` and `update(g, ctx)`, set `version = MASK_STRATEGY_VERSION`, and pass it to `.maskStrategy(...)`. Try `PathMaskStrategy` first. A class is only worth it when it keeps state between draws. Two things to respect. `ctx.axis` matters because `rects` are in screen space in every orientation (`axis.toLocal(w, h)` gives `{ cross, main }`). `ctx.bleed` inflates the cross axis only. Add the optional `draw(g, ctx)` and your strategy composes like the built-in ones. ##### Demos Each demo passes a mask strategy to `.maskStrategy(...)`. Rounded windows come first, then the helpers that trim or combine a mask, then a mask drawn from your own path. #### Rounded corners ##### The whole window `RoundedRectMaskStrategy` with `scope: 'set'` rounds the corners of the box around all the reels. It works at any cross gap, which is why it is the default scope. Live demo (mask-rounded-set): https://pixi-reels.schmooky.dev/mechanics/masks/#a-rounded-window ##### Each reel as a card `scope: 'reel'` rounds every reel's box instead, so the reels read as separate cards. It needs a cross gap above `0`. At gap `0` neighbouring reels share an edge, and rounding both sides of it cuts a notch into every seam. The strategy warns once when it sees touching reels. Live demo (mask-rounded-reels): https://pixi-reels.schmooky.dev/mechanics/masks/#each-reel-as-its-own-card ##### Outer corners only `scope: 'outer'` keeps one rect per reel, as the default mask does, so buffer cells past a short reel stay hidden. It rounds a corner only where it is also a corner of the box around all the reels: the outer pair on the first reel and on the last. The inner edges stay square, so it works at cross gap `0`, where `scope: 'reel'` notches. `corners: { topLeft: true, ... }` limits any scope to the named screen corners. On a jagged set the corners of the box may not touch any reel, and then nothing is rounded. Use `SilhouetteMaskStrategy` there. Live demo (mask-outer-corners): https://pixi-reels.schmooky.dev/mechanics/masks/#one-rect-per-reel-the-windows-corners-only ##### Jagged boards A pyramid has no single rectangle to round. Rounding each reel notches the seams, and rounding the bounding box hides the staircase and shows buffer cells past the short reels. `SilhouetteMaskStrategy` follows the outline of all the reels together and rounds every corner of it. The inward corners, where a short reel meets a taller one, use `concaveRadius`. On a board with no steps it gives a plain rounded rect. The reels must touch, at cross gap `0`. With a gap the strategy warns and falls back to a rounded rect per reel. Live demo (mask-silhouette-pyramid): https://pixi-reels.schmooky.dev/mechanics/masks/#rounding-a-jagged-board ##### Hold & Win cells Every Hold & Win cell is its own 1x1 reel set with its own mask. `cellMask` on the Hold & Win builder takes a function that is called once per cell with `{ reel, cell }` (column and row) and `{ cols, rows, corners }`, and returns that cell's strategy. Here every cell gets a plain rect except the four corner cells, which each round their one outer corner, so the gapless board clips as one rounded window made of fifteen masks. `corners` is the cell's corner set already worked out, for the short form `(_, { corners }) => new RoundedRectMaskStrategy({ radius, corners })`. Live demo (hold-and-win-outer-corners): https://pixi-reels.schmooky.dev/mechanics/masks/#a-mask-per-hold--win-cell-from-its-row-and-column #### Trimming and combining ##### Inset and compose `inset(strategy, px)` shrinks what any strategy draws by `px` on every side, and a negative value grows it. Use it when the art shows a pixel past the frame. `composeMasks(a, b, ...)` joins several strategies into the viewport's one mask. Here a rounded window inset by 4px is joined with a banner strip above the reels. `composeMasks` can only form a union, because a `Graphics` mask is the union of its filled shapes. To subtract, use `.cut()` inside a `PathMaskStrategy`. Live demo (mask-inset-compose): https://pixi-reels.schmooky.dev/mechanics/masks/#insetting-and-composing ##### A different trim per side Frame art rarely has four equal lips. `inset(strategy, { top, right, bottom, left })` trims each side by its own amount, for example `inset(new RoundedRectMaskStrategy({ radius: 43 }), { top: 4, bottom: 12 })`. Sides are screen sides in every orientation, and a side you leave out is not trimmed. Here the bottom lip is four times thicker than the top one. Live demo (mask-inset-sides): https://pixi-reels.schmooky.dev/mechanics/masks/#mask-inset-sides #### Any shape `PathMaskStrategy` takes a `(graphics, context) => void` callback. The context carries `rects`, `width`, `height`, `axis` and `bleed`. Do not call `g.clear()`, because the strategy already has. The demo fills the board and cuts a hole in the middle, so only the outer ring of symbols shows. `cut()` subtracts from the last shape filled, so fill first. If you draw the hole before filling, the mask is empty and the board disappears, with no error. Live demo (mask-path-custom): https://pixi-reels.schmooky.dev/mechanics/masks/#any-shape-without-a-class ### Nudge URL: https://pixi-reels.schmooky.dev/mechanics/nudge/ Push a reel that has already stopped up or down a few places to pull a symbol into view. Tags: nudge, stagger, spotlight, big-symbols, abort, skip, horizontal, reverse, orientation A nudge moves one reel a few cells after it has landed, and brings in symbols you choose. The classic use is a near-miss: the reels land one symbol short, then one reel nudges by one cell to reveal the symbol that was missing. ```ts await reelSet.spin(); await reelSet.nudge(2, { distance: 1, direction: 'forward', incoming: ['wild'], }); ``` Reel 2 moves one cell. Everything on it shifts along, the last symbol leaves the window, and the wild arrives at the front. Live demo (nudge): https://pixi-reels.schmooky.dev/mechanics/nudge/ #### The contract ```ts interface NudgeOptions { /** * Number of full positions to shift. Positive integer, strictly less than * the reel's total strip capacity (bufferStart + visibleCells + bufferEnd). */ distance: number; /** * - 'forward': the way this reel travels; new symbols enter at its * feed edge. * - 'reverse': the other way; new symbols enter at the opposite edge. * * Relative to the reel, not the screen. On a reel built with * direction('reverse'), 'forward' nudges upward. */ direction: 'forward' | 'reverse'; /** * Symbol ids in top-down order of their final on-strip position, * including any overflow into the off-screen buffer. Length must equal * `distance` exactly. */ incoming: string[]; /** Tween duration in ms. Default: `200 * distance`. */ duration?: number; /** GSAP ease name. Default: `'power2.out'` (smooth deceleration, no overshoot). */ ease?: string; /** Delay before the tween begins (ms). Sugar for staggered Promise.all. */ startDelay?: number; /** Abort the nudge mid-flight. Strip still snaps to landed position. */ signal?: AbortSignal; } reelSet.nudge(reel: number, options: NudgeOptions): Promise<{ symbols: string[] }>; reelSet.skipNudge(reel?: number): void; ``` The promise resolves with the reel's new visible cells, in order, which you can feed straight into win detection. It rejects with an `AbortError` if the signal aborts or the set is destroyed mid-tween. #### How `incoming` lays out For a 3-cell reel landed on `['A', 'B', 'C']` (first, middle, last): | Call | New visible (first to last) | | --- | --- | | `nudge(r, { distance: 1, direction: 'forward', incoming: ['X'] })` | `['X', 'A', 'B']` | | `nudge(r, { distance: 2, direction: 'forward', incoming: ['X', 'Y'] })` | `['X', 'Y', 'A']` | | `nudge(r, { distance: 1, direction: 'reverse', incoming: ['X'] })` | `['B', 'C', 'X']` | | `nudge(r, { distance: 2, direction: 'reverse', incoming: ['X', 'Y'] })` | `['C', 'X', 'Y']` | The first entry always ends up nearest the start of the reel and the last entry nearest the end. A nudge further than the visible cell count pushes the overflow into the buffer on the matching side. With `'forward'`, the trailing entries spill into the buffer at the exit edge. With `'reverse'`, the leading entries spill into the other one. Nothing is thrown away. Every entry stays on the strip, ready for a follow-up nudge or the next spin's opening frame. A distance equal to or larger than the strip capacity throws, because a full rotation would silently overwrite a pre-placed buffer entry. #### Sequential or parallel One nudge moves one reel. When several reels nudge, you choose how to start them. The engine output is the same either way; only the pacing differs. ##### Sequential Live demo (nudge-sequential): https://pixi-reels.schmooky.dev/mechanics/nudge/#sequential-three-separate-beats ```ts for (const reel of [1, 2, 3]) { await reelSet.nudge(reel, { distance: 1, direction: 'forward', incoming: ['wild'], duration: 480 }); } ``` Each `await` waits for that reel to land, so the player sees reel 1's wild before reel 2 starts. The total time is the number of reels times the duration. ##### Parallel Live demo (nudge-parallel): https://pixi-reels.schmooky.dev/mechanics/nudge/#parallel-one-synchronised-beat ```ts await Promise.all( [1, 2, 3].map((reel) => reelSet.nudge(reel, { distance: 1, direction: 'forward', incoming: ['wild'], duration: 480 }), ), ); ``` All the tweens start on the same frame and the whole line arrives together. The total time is one duration, however many reels. ##### Stagger The `startDelay` option gives you a wave without a loop: ```ts await Promise.all( [1, 2, 3].map((reel, i) => reelSet.nudge(reel, { ...opts, startDelay: i * 80 }), ), ); ``` The tweens start at 0, 80 and 160 ms and run concurrently. Validation still throws synchronously at the call site. Only the movement is delayed. #### Big symbols on the reel A tall block moves as one piece, as long as the whole block is still on the strip afterwards: | Direction | Survival condition | | --- | --- | | `'forward'` | `anchorStripIdx + h - 1 + distance < total` | | `'reverse'` | `anchorStripIdx - distance >= 0` | Here `total` is the strip capacity (buffer start plus visible cells plus buffer end) and `anchorStripIdx` counts from 0 at the outermost start-buffer cell, so the index of visible cell 0 equals the buffer start count. A block may sit partly in a buffer and still render correctly. The engine sizes the anchor to span the whole block wherever it lives, and the mask clips the rest. This is how a tail reveal works: land a tall wild with its anchor in the buffer, nudge, and the rest of it moves into view. A block wider than one reel always throws. Nudging one reel would tear the block off its cells on the next one. ```ts // A 1x2 wild sits at visible cell 1 with its tail in bufferEnd. // Nudge back by 1 and the whole block lands at cells 0 and 1. await reelSet.nudge(2, { distance: 1, direction: 'reverse', incoming: ['filler'] }); ``` #### Skip and abort There are two ways to cut a nudge short. ```ts // 1. Skip: fast-forward to landed. The promise resolves normally. const p = reelSet.nudge(2, { ...opts }); button.onclick = () => reelSet.skipNudge(2); const { symbols } = await p; ``` ```ts // 2. Abort: reject with AbortError. The strip still snaps to landed. const controller = new AbortController(); const p = reelSet.nudge(2, { ...opts, signal: controller.signal }); button.onclick = () => controller.abort(); try { await p; } catch (e) { if (e.name !== 'AbortError') throw e; } ``` The difference is what happens to the promise. `skipNudge` resolves it, so your success path runs. An abort rejects it and fires `nudge:cancelled`, so your error path runs. Skip when the win plays next, and abort when you are tearing the feature down. Either way the strip lands where it was going to land. A nudge never stops half-tweened. #### Events | Event | Payload | When | | --- | --- | --- | | `nudge:start` | `({ reelIndex, distance, direction })` | Pre-placement is done and the tween is about to begin. | | `nudge:complete` | `({ reelIndex, distance, direction, symbols })` | The strip snapped to the post-nudge grid. `symbols` is the new visible column. | | `nudge:cancelled` | `({ reelIndex, distance, direction, reason })` | The signal aborted or the reel was destroyed mid-tween. Never fires together with `nudge:complete`; the promise rejected instead. | | `phase:enter` (per reel) | `('nudge')` | Mirror of `nudge:start`, on the affected reel's bus. | | `phase:exit` (per reel) | `('nudge')` | Mirror of `nudge:complete`. | The per-reel `landed` event does not fire on a nudge. It belongs to the spin pipeline. Listen to `nudge:complete` instead. ```ts reelSet.events.on('nudge:complete', ({ reelIndex, symbols }) => { console.log(`reel ${reelIndex} now reads`, symbols); // Re-run win detection on reelSet.getVisibleGrid() here. }); ``` #### When `nudge()` throws or rejects Bad arguments throw at the call. Cancellation rejects later. It throws synchronously when: - The reel set is spinning, refilling, or in a cascade. - `reel` is out of range. - The target reel has an active pin. Call `unpin` first. - `distance` is below 1, not an integer, or at least the strip capacity. - `direction` is neither `'forward'` nor `'reverse'`. - The length of `incoming` differs from `distance`. - An incoming id is not registered, or is a big symbol. - A block on the target reel would not survive the rotation. - A cell on the target reel belongs to a block wider than one reel. It rejects with an `AbortError` when: - The signal aborts before or during the tween. - `reelSet.destroy()` is called mid-tween. A nudge touches one reel. The other reels, their pins and any spotlight are left alone. #### Recipes - [Single nudge](/mechanics/nudge/), the smallest demo. - [Spotlight after a nudge](/mechanics/nudge/#nudge-spotlight), a nudge that completes a line, then the win. - [Big symbols](/mechanics/nudge/#nudge-big-symbol), the block survival rule and the tail reveal. - [Land a big symbol partially in buffer](/mechanics/big-symbols/#big-symbol-partial-land), land with the tail showing, then nudge to reveal it. - [Nudge a big symbol in, then hold it across a respin](/mechanics/big-symbols/#big-symbol-held-respin), reveal a buffer-anchored wild, then hold the reel while the others respin. ##### Demos Each demo shifts a reel that has already landed by a few positions and brings in symbols you choose. The first one is a single nudge. The rest cover nudging several reels, presenting the win, big symbols, other reel directions and cutting a nudge short. #### Single nudge After the reels land, reel 1 nudges `'forward'` by one and a wild enters at the top, then reel 3 nudges `'reverse'` by one and a wild enters at the bottom. `incoming` lists the symbols in their final order on the strip, top to bottom on a vertical set. Live demo (nudge): https://pixi-reels.schmooky.dev/mechanics/nudge/#nudge-a-reel #### Several reels The same row of wilds nudged into reels 1 to 3 in three ways. The engine output is the same each time; only the pacing changes. ##### One after another Each `await` waits for the previous reel to land, so the player sees three separate reveals. The total time is the number of reels times the duration. Live demo (nudge-sequential): https://pixi-reels.schmooky.dev/mechanics/nudge/#nudge-several-reels ##### All at once `Promise.all` starts every tween on the same frame and the wilds arrive together. The total time is one duration. Live demo (nudge-parallel): https://pixi-reels.schmooky.dev/mechanics/nudge/#nudge-several-reels ##### Staggered `Promise.all` with a per-reel `startDelay`. The tweens run at the same time but start one after another, so the wilds arrive in a wave. Bad arguments still throw at the call; only the movement waits. Live demo (nudge-stagger): https://pixi-reels.schmooky.dev/mechanics/nudge/#staggered-nudge-wave-reveal #### Spotlight after a nudge The reels land one wild short of a line. Three reels nudge in parallel to complete it, then `SymbolSpotlight` presents the new winning cells. Live demo (nudge-spotlight): https://pixi-reels.schmooky.dev/mechanics/nudge/#nudge-spotlight #### Big symbols A 1xH block on the target reel moves as one piece. In the first demo a 1x2 wild nudges down by two, so its lower half moves into the buffer below the window, then up by one into full view. In the second the block nudges up so only its lower half shows, then back down into full view. Only blocks one reel wide (`size.reels === 1`) can be nudged. A block that spans reels throws. Live demo (nudge-big-symbol): https://pixi-reels.schmooky.dev/mechanics/nudge/#nudge-through-a-big-symbol Live demo (nudge-tail-reveal): https://pixi-reels.schmooky.dev/mechanics/nudge/#nudge-through-a-big-symbol #### Other reel directions `direction` is relative to the reel's own axis, so the nudge code is the same on any set. What changes is where on screen the new symbol enters. ##### Horizontal set On `.orientation('horizontal')` a reel is a screen row, so a nudge shifts it sideways. One press nudges row 0 `'forward'`, where a wild enters at the left edge, and row 2 `'reverse'`, where a wild enters at the right. `incoming` reads left to right here. Live demo (nudge-horizontal): https://pixi-reels.schmooky.dev/mechanics/nudge/#nudge-a-horizontal-set ##### Reels that spin up Two wilds land on the middle line and the third stops one cell below it. On a `.direction('reverse')` reel a `'forward'` nudge travels upward, so the incoming symbol enters at the bottom cell and the wild rolls onto the line, which then lights up. Live demo (nudge-reverse-rollup): https://pixi-reels.schmooky.dev/mechanics/nudge/#nudge-on-a-roll-up-set #### Cutting a nudge short Both ways end with the strip where the nudge was going. They differ in what the promise does. ##### Skip `reelSet.skipNudge(reel)` jumps a running nudge to its end. `nudge()` resolves as usual, so the success path still runs. Use it when the win plays next. Live demo (nudge-skip): https://pixi-reels.schmooky.dev/mechanics/nudge/#skip-an-in-flight-nudge ##### Abort Abort through `NudgeOptions.signal`. The strip still snaps to its landed position, but `nudge()` rejects with `AbortError` and `nudge:cancelled` fires. Use it when you are tearing the feature down. Live demo (nudge-abort): https://pixi-reels.schmooky.dev/mechanics/nudge/#abort-a-nudge ### Sideways and upward reels URL: https://pixi-reels.schmooky.dev/mechanics/orientation-and-direction/ Reels that run sideways or upward, for banners and portrait layouts. The art stays upright. Tags: horizontal, orientation, direction, reverse, roll-up, banner, ways, axis A reel can travel down, up, or sideways. Two builder settings control that, and they do not affect each other: ```ts new ReelSetBuilder() .orientation('horizontal') // which screen axis the strip travels along .direction('reverse') // which way along it symbols move ``` That gives four combinations. The engine is written against the reel's axis instead of against `y`, so anticipation, cascades, the spotlight, pins, big symbols, pyramids and MultiWays work the same in all four. | | `direction('forward')` | `direction('reverse')` | |---|---|---| | `orientation('vertical')` | symbols fall (the default) | symbols rise, a roll-up | | `orientation('horizontal')` | symbols move right | symbols move left, a sideways banner | #### Four separate concepts The engine keeps these four apart: - Orientation: which screen axis the strip runs on. Set for the whole set at build time. - Direction: which way along that axis symbols travel. Per reel. - Gravity: which way cascade symbols fall. By default it follows the reel's direction. `tumble({ gravity })` can pin it to `'forward'` or `'reverse'` so a reel spins one way and drops the other. - Facing: which way is up for the art. Never touched by the other three. Travel never changes facing. A reel can spin sideways and its art stays upright. The engine never rotates a container to fake an axis, because that would break sprite anchors, flip filters and draw third-party symbols on their side. A test checks for zero rotation and unit scale on every symbol in all four combinations, at rest, mid-spin and landed. #### Main and cross The main axis is the one the strip travels along: `y` when vertical, `x` when horizontal. The cross axis is the other one, along which the reels are laid out. On a vertical set the reels sit side by side across `x` and cells scroll down `y`. On a horizontal set it is the opposite. `Reel` exposes both for code that must not care which is which: `cellMain`, `cellCross`, `mainGap`, `crossGap`, `extent` and `mainOffset`. #### What stays in screen space Your own symbol classes need no changes, because everything a symbol sees is in screen space, whatever the orientation: `symbolSize(width, height)`, `symbolGap(x, y)`, `ReelSymbol.resize(width, height)`, `CellBounds`, `getCellBounds`, `getBlockBounds`, and the position of the `ReelSet` itself. A horizontal set is the vertical one transposed. Swap width and height and you have the same board on its side. ```ts // A 5x3 vertical board. .symbolSize(120, 100).symbolGap(8, 6) // The same board, sideways. .orientation('horizontal').symbolSize(100, 120).symbolGap(6, 8) ``` Indices do not move either. The same `ColumnTarget[]` goes into `setResult()`, the same shape comes out of `getVisibleGrid()`, and a cell address means the same cell whichever way the strip runs. #### Start and end are geometric The buffers are named `start` and `end`: ```ts .bufferSymbols({ start: 1, end: 1 }) reelSet.setResult([{ visible: ['A','B','C'], bufferStart: ['COIN'] }]); ``` Start is the smaller screen coordinate: above on a vertical set, left on a horizontal one. Direction does not change it. A buffer symbol is placed against an edge of the window, like a coin peeking above the top row or a big symbol's tail parked outside it. If start and end followed travel, reversing a reel would move all of them to the other side of the screen. So motion follows direction, and buffers follow the screen. The feed edge, the side new symbols arrive from, does follow travel. You do not set it. The engine derives it, and you can read it as `reel.axis.feedEdge`. #### Per-reel direction ```ts .direction('forward') // every reel .directionPerReel(['forward','reverse','forward','reverse','forward']) ``` Use it for alternating columns or a single reversed reel. A big symbol wider than one reel cannot be combined with mixed per-reel directions. The block coordinator assumes every reel a block covers feeds from the same edge, and with mixed directions the block would split mid-spin. So `build()` throws when the per-reel array holds more than one distinct value. An array with one value throughout is fine. Keep blocks inside one reel, or give the whole set one direction. #### Render order Direction does not change which symbol overlaps which: ```ts .cellStacking('ascending') // default: the cell at the larger coordinate draws in front .reelStacking('ascending') // default: the last reel draws in front ``` Stacking follows the screen, not travel. Art is lit from above, and flipping the stacking on a roll-up would make that lighting read backwards. A tease that reverses a reel for one spin would also re-layer the board in front of the player. If your art needs the opposite order, pass `'descending'`. #### Nudge is relative ```ts await reelSet.nudge(2, { distance: 1, direction: 'forward', incoming: ['wild'] }); ``` Here `'forward'` means the way this reel travels, not down. On a reel built with `direction('reverse')`, a vertical reel nudged forward moves upward and takes its new symbols in from the bottom. The same call works on every reel. #### Two sets in one container A banner above a grid is two reel sets in one container. There is no separate API for it. ```ts const main = new ReelSetBuilder().reels(5).visibleCells(3)./* ... */.build(); const banner = new ReelSetBuilder() .orientation('horizontal') .reels(1) // one reel... .visibleCells(5) // ...of five cells, one above each main reel ./* ... */.build(); const stage = new PIXI.Container(); banner.y = 0; main.y = CELL + GAP * 3; stage.addChild(banner, main); ``` Lay each set out from its own top-left. Scale the container, never the sets inside it. If you scale one set, the other keeps its old size and the two no longer line up. The [banner-ways](/mechanics/orientation-and-direction/#banner-ways) demo is the full version, with a banner wild that extends a ways win. #### Seeing the axis The debug overlay draws each reel's axis: ```ts import { debugOverlay } from 'pixi-reels/debug'; // needs pixi-silk, a dev dependency const overlay = debugOverlay(reelSet, { layers: ['axis', 'feed', 'thresholds', 'hud'] }); ``` - `axis`: one arrow per reel, pointing the way it travels - `feed`: the edge new symbols arrive at - `thresholds`: the wrap lines. No symbol should ever be drawn past one - `hud`: a line per reel, such as `r0 VF feed=start spd=... cells=3` `overlay.describe()` returns the same information as plain JSON, for tests and for anything that cannot look at a canvas. See [Debugging](/learn/debugging/). #### Recipes - [Horizontal banner](/mechanics/orientation-and-direction/#horizontal-banner) is a one-reel sideways strip. - [Every reel upward](/mechanics/orientation-and-direction/#roll-up) reverses the whole set. - [Direction per reel](/mechanics/orientation-and-direction/#roll-up-alternating) alternates the columns. - [Banner in a ways win](/mechanics/orientation-and-direction/#banner-ways) puts a banner above a 5x3 that joins the win. ##### Demos {/* The v1 standalone recipes redirect here; keep their fragments alive. `#horizontal-banner` needs no anchor - the heading below auto-slugs to it. */} #### Horizontal banner A one-reel strip that scrolls sideways, such as a banner showing which symbols pay this round. It is `.orientation('horizontal')` on the normal builder, with the same spin lifecycle, events and speed profiles as a vertical set. Live demo (horizontal-banner): https://pixi-reels.schmooky.dev/mechanics/orientation-and-direction/#static-spin-horizontal #### Upward reels ##### Every reel `.direction('reverse')` makes every reel spin upward. The spin, the events and the landing bounce are the same, run the other way. Live demo (roll-up): https://pixi-reels.schmooky.dev/mechanics/orientation-and-direction/#roll-up-reverse-direction ##### Direction per reel `.directionPerReel([...])` sets each reel's direction on its own. Here odd reels spin up and even reels spin down. Each reel still lands the exact result, because it feeds new symbols from its own edge. Live demo (roll-up-alternating): https://pixi-reels.schmooky.dev/mechanics/orientation-and-direction/#mixed-direction-per-reel #### Sideways with mixed direction Orientation is set for the whole set at `build()`, and direction is set per reel, so the two combine. Here the strips run sideways, rows 0 and 2 scroll right, and rows 1 and 3 scroll left. A big symbol wider than one reel (`size.reels > 1`) cannot be combined with mixed per-reel directions. A block assumes every reel it covers feeds from the same edge and would split mid-spin, so `build()` throws. A `directionPerReel` array with the same value throughout is fine. Live demo (orientation-horizontal-per-reel): https://pixi-reels.schmooky.dev/mechanics/orientation-and-direction/#both-knobs-at-once #### Banner in a ways win A horizontal banner above a 5x3 ways set. The banner acts as a sixth reel: a wild in the banner cell above a reel makes that reel count toward the way. These are two `ReelSet`s in one container. The engine spins and lands both. The recipe evaluates the ways and spotlights the cells, because pixi-reels never computes wins. Live demo (banner-ways): https://pixi-reels.schmooky.dev/mechanics/orientation-and-direction/#banner-that-joins-a-ways-win #### Reading the axis Each reel has `reel.axis`, with `orientation`, `direction`, `polarity`, `mainProp`, `crossProp` and `feedEdge`. `axis.toScreen(0, axis.polarity)` turns one step of travel into a screen vector, so the arrows in the demo are drawn with no orientation check. The same code points down on a vertical forward reel and left on a horizontal reverse one. `feedEdge` is the side new symbols arrive from. It is derived from `polarity`: `'start'` for forward, `'end'` for reverse. Read it when you need it instead of tracking it next to `direction`. Live demo (orientation-axis-readout): https://pixi-reels.schmooky.dev/mechanics/orientation-and-direction/#read-the-axis-instead-of-remembering-it ### Curved reels URL: https://pixi-reels.schmooky.dev/mechanics/reel-curvature/ Bend the strip onto a drum so the top and bottom cells lean away, like a physical machine. Tags: curve, curvature, perspective, projection, cylinder, drum, 3d Curvature is presentation only. It never changes what lands where, `getVisibleGrid()`, or any event payload. #### Two drawing modes ```ts builder.curve(0.45).curveMode('warp').renderer(app.renderer); ``` | | `'symbol'` (default) | `'warp'` | |---|---|---| | Spine and composites bend | no | yes | | Atlas art keystones | no | yes | | Motion follows the curve | no | yes | | Cost | free | 1 render pass per reel per frame | | Sharpness | native | one resample | | Needs `renderer()` | no | yes, `build()` throws | `'warp'` renders each reel to a texture and moves the vertices of a mesh, so everything inside the reel bends without any help from the symbols. `'symbol'` projects each cell on its own. It is sharper, but a `Container` transform is affine, so it can only bend content that is a single texture. #### Lifted symbols stay flat Under `'warp'`, anything drawn outside the reel's texture is not bent: `unmask: true` symbols, the win spotlight, pin flights and overlays all draw flat over a curved board. The builder logs a warning when it sees `unmask` with the warp. `'symbol'` mode has no such split. For art that overflows its cell under the warp, use `curveBleed` instead of `unmask`. #### Changing the curve at run time ```ts reelSet.setCurve(0.4); reelSet.setCurve([0.2, 0.35, 0.5, 0.35, 0.2]); reelSet.setCurve(0); // flat ``` #### Extending `'symbol'` mode This only matters if you do not use the warp. The engine hands each symbol a projected quad through `ReelSymbol.applyCellQuad()`. `SpriteSymbol` and `AnimatedSpriteSymbol` map it onto a `PerspectiveMesh`, which keystones the art with no extra render pass, when the texture owns its whole source. `canProjectTexture()` refuses atlas sub-frames: the mesh addresses its source with 0..1 UVs, and remapping them onto the frame has not produced a correct draw yet. Every other symbol gets a uniform scale that fits inside the quad, so no cell overlaps its neighbour and a `7` is never squashed. In this fallback the engine owns `view.scale`. A win animation that tweens `symbol.view.scale` overwrites the projection while it runs, so animate a child of `view` instead. The warp has no such conflict. For your own single-texture symbol, `PerspectiveCell` is exported and does the mesh work. Art that does not fill its cell reports its real rect through `ReelSymbol.cellInset`, which the sprite symbols derive from the texture's trim. ##### Demos `.curve(amount)` bends each reel onto a drum, so the outer cells lean away like the ones on a physical machine. Every demo here uses `.curveMode('warp')`, which bends whatever a reel contains. The Concept section below compares it with the default `'symbol'` mode. #### A curved board A slot reel is a drum. The middle cell faces you and the outer ones have turned away, so a camera draws them as trapezoids rather than smaller rectangles. The grid on the tiles shows it: the lines converge on the outer rows and stay parallel on the middle one. `.curve(amount)` takes `0` for flat, the default, and `1` for a hard barrel. Most boards use `0.3` to `0.5`. Live demo (curved-reels): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#one-number ```ts builder.curve(0.45); // depth defaults to amount * 0.5 builder.curve({ amount: 0.45, depth: 0.35 }); // stronger perspective ``` `depth` is how much smaller an edge cell is than the middle one. At `0` the projection is orthographic: cells bunch up but nothing recedes. It is capped slightly under `cos(arc)`, past which cells would fold back over each other. The middle cell is drawn at its authored size, so the drum cannot also fill a window sized for flat cells. The ends fall short, and the buffer cells show in that band. Cover it with a frame, as a cabinet bezel does. `reel.curve.mapMain(0)` is where the drum's top edge lands, so the frame can be measured. #### Art that bends ##### Atlas sprites Playson's Supercharged Diamonds 3, the sheet the sprite Hold & Win recipes use. The frames are trimmed atlas frames, which `'symbol'` mode cannot keystone. Under `'warp'` they bend like everything else, and the blur during the spin still works. Live demo (curved-reels-gems): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#on-real-art ##### Spine skeletons Spine skeletons, which `'symbol'` mode cannot bend at all. Under `'warp'` they curve and keep animating, and the spin and the stop bounce follow the drum. Live demo (curved-reels-warp): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#curved-reels-warp Symbols that hang over their cell need two settings. `SymbolData.zIndex` stacks them within the reel, and `.curveBleed(px)` keeps the warp texture from cutting the overhang off at its edge. With `curveBleed` under `curveFocus('reel')`, also set `SharedRectMaskStrategy` yourself, or the per-reel mask clips the overhang. ```ts builder.symbolData({ mystery: { zIndex: 2 } }).curveBleed(46); ``` ##### Text A value reel for prize pickers and jackpot ladders. The symbols are drawn at run time and the symbol id is the amount, so `setResult([['100.00', ...]])` lands the value you name. Each cell is a `PIXI.Text`, which has no texture of its own, so only the warp bends the digits. Live demo (curved-value-reel): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#numbers-not-art #### The camera ##### One camera for the board By default each reel has its own camera and is its own drum. `curveFocus('set')` puts one camera in front of the middle of the board, so the outer reels tilt toward the centre and the centre reel barely moves. `'set-lean'` is halfway between and usually looks best on a 5-wide board. ```ts builder.curve(0.5).curveFocus('reel'); // default: five separate drums builder.curve(0.5).curveFocus('set-lean'); // halfway builder.curve(0.5).curveFocus('set'); // one camera, one wide cylinder ``` Leaning cells cross into the next reel's column, so any focus other than `'reel'` selects `SharedRectMaskStrategy`. Pass `.maskStrategy(...)` to override it. Live demo (curved-reels-focus): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#where-the-camera-stands ##### A curve per reel `.curvePerReel([...])` gives each reel its own curve. Bending the middle reels hardest and the outer ones least makes the board read as one wide drum. The array needs one entry per reel, matching `reels()`. Live demo (curved-reels-per-reel): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#one-drum-not-five #### Board shapes ##### A pay band in a taller drum Five rows are drawn and the middle three pay. The outer rows are there to be curved, and they are what makes the board read as a cylinder. On a bare 3-row board the drum has to bend hard enough to distort the symbols people read. Here the bend goes into rows that do not pay, so this board can use a deeper `curve(0.62)`. The dimming over the outer rows is drawn from `getCellQuad()`, the four corners the cell is drawn on. `getCellBounds()` returns the quad's bounding box, which is looser than the cell on a curved reel. Outline with the quad and hit-test with the box. Live demo (curved-reels-payband): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#a-pay-band-inside-a-taller-drum ##### Cascades The warp applies the bend to the rendered reel, so explosions, survivors sliding down and new symbols dropping in all follow the curve. The cascade code does not know the reel is curved. A tumble board needs the frame over both ends. At the top the band would show the buffer cell, which holds the refill queue and does not move when survivors fall. At the bottom a pure tumble sets `bufferSymbols({ end: 0 })`, so there is nothing to show. Live demo (curved-reels-cascade): https://pixi-reels.schmooky.dev/mechanics/reel-curvature/#cascades-on-a-drum ### Skip and slam URL: https://pixi-reels.schmooky.dev/mechanics/skip/ Decide what a tap does mid-spin: stop every reel, land them one by one, or let a tease finish. Tags: skip, slam, anticipation, tease, phases, timing, groups 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: ```ts 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. ```ts 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: ```ts // 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](/mechanics/skip/#skip-cascade-protect) 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. ```ts 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. ```ts 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. ```ts 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](/mechanics/cascade/#spin-then-cascade). #### 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. ```ts 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](/mechanics/orientation-and-direction/#concept). 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](/mechanics/nudge/#concept) has the full contract and these demos: [nudge](/mechanics/nudge/), [skip](/mechanics/nudge/#nudge-skip), [abort](/mechanics/nudge/#nudge-abort), [stagger](/mechanics/nudge/#nudge-stagger), [spotlight after a nudge](/mechanics/nudge/#nudge-spotlight), [big symbols](/mechanics/nudge/#nudge-big-symbol). #### Full event map | Event | Payload | When | | ---------------------- | ----------------------------------------------- | ---- | | `spin:start` | none | Any `spin()` call | | `spin:allStarted` | none | Every 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:end` | none | The 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` | | `destroyed` | none | `destroy()` called | #### Reference * [Phases](/reference/api-phases/): customize start, spin and stop timing * [Events](/reference/api-events/): types and exact signatures * [SpinOptions](/reference/api-builder/#spin-options): `holdReels`, `mode` ##### 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. Live demo (slam-stop): https://pixi-reels.schmooky.dev/mechanics/skip/#slam-stop ##### 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`. Live demo (skip-queued-request): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-queued-request #### 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. Live demo (skip-partial-slam): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-partial-slam ##### 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. Live demo (skip-reels-complement): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-reels-complement #### 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. Live demo (protected-anticipation): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-tease-protect ##### 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. Live demo (skip-stepwise-tease): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-stepwise-tease ##### 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. Live demo (skip-always-protect): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-always-protect ##### 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. Live demo (skip-custom-plan): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-custom-plan ##### 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. Live demo (skip-stage-button): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-stage-button ##### 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. Live demo (skip-turbo-inert): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-turbo-inert ##### 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. Live demo (skip-no-tell): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-no-tell #### 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. ```ts 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. Live demo (reel-groups): https://pixi-reels.schmooky.dev/mechanics/skip/#reel-groups #### 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. Live demo (skip-quicken): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-quicken ##### 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. Live demo (quicken-groups): https://pixi-reels.schmooky.dev/mechanics/skip/#quicken-groups ##### 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. Live demo (quicken-then-slam): https://pixi-reels.schmooky.dev/mechanics/skip/#quicken-then-slam #### 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`. Live demo (skip-min-spin-time): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-min-spin-time ##### 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. Live demo (skip-min-spin-uniform): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-min-spin-uniform #### 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 spin | `protect` applies unchanged. Press 1 lands the reels outside the tease, press 2 ends it. | | Round side effect | In 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. | | Refills | No 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`. Live demo (skip-cascade-protect): https://pixi-reels.schmooky.dev/mechanics/skip/#skip-cascade-protect ##### 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](/reference/api-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. Live demo (phase-subclass-stop): https://pixi-reels.schmooky.dev/mechanics/skip/#phase-subclass-stop ##### 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`. Live demo (phase-subclass-spin): https://pixi-reels.schmooky.dev/mechanics/skip/#phase-subclass-spin ##### 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`. Live demo (phase-subclass-anticipation): https://pixi-reels.schmooky.dev/mechanics/skip/#phase-subclass-anticipation ##### 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. Live demo (phase-from-scratch-start): https://pixi-reels.schmooky.dev/mechanics/skip/#phase-from-scratch-start ##### 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. Live demo (phase-subclass-cascade): https://pixi-reels.schmooky.dev/mechanics/skip/#phase-subclass-cascade ##### 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. Live demo (quicken-custom-phase): https://pixi-reels.schmooky.dev/mechanics/skip/#quicken-custom-phase ### Spinning art URL: https://pixi-reels.schmooky.dev/mechanics/spinning-art/ While a reel spins it shows a blurred still of each symbol, so heavy art costs nothing and reads as motion. Tags: static-spin, motion-blur, spine A symbol at rest can be anything: a Spine skeleton, an animated sprite, a container of layers. Register it through `StaticSpinSymbol` and give it a `createInner` that builds the real symbol. At rest the inner symbol is live, so idle loops and win animations play as usual. When the reel starts, the wrapper deactivates it and spins a plain sprite of it instead. On landing it brings the inner symbol back with the final id. The sprite's texture comes from a `SpinTextureCache` shared by the set, which snapshots each id once. With `spinTexture: 'blurred'`, the default, it also bakes a motion blur along the reel's travel and crossfades to it over `blurRampMs`. `spinTexture: 'static'` spins the sharp snapshot instead. No filter runs during the spin, and no skeleton updates while the strip moves. `prewarmSpinTextures` bakes every id before the first spin. Without it, each id is baked the first time it is needed. If you have hand-drawn blur frames, `cache.setBlurred(id, texture)` makes the cache use them instead. ##### Demos Each demo spins through `StaticSpinSymbol`. The first bakes the blur for plain cards, the second does the same for a Spine set, and the third uses blur frames drawn by hand. #### Baked blur The cache snapshots each card once and bakes a motion blur from the snapshot, and the reels spin on those textures. There is no blur art in the demo, and no filter runs during the spin. `prewarmSpinTextures` bakes every id before the first spin so it does not stall. Live demo (static-spin-blur): https://pixi-reels.schmooky.dev/mechanics/spinning-art/#auto-baked-motion-blur-static-spin #### Spine at rest At rest every cell is a live Spine skeleton with its idle and landing animations. When the reels start, each cell switches to a cached snapshot and the skeleton is deactivated, so no skeleton updates while the reels spin. On landing the skeletons come back and play their landing animation. Live demo (static-spin-spine): https://pixi-reels.schmooky.dev/mechanics/spinning-art/#spin-static-not-spine #### Your own blur art The round symbols use blur frames drawn in the atlas, handed to the cache with `cache.setStatic(id, texture)` and `cache.setBlurred(id, texture)`. The cache uses those as they are and never bakes or destroys them. The royal symbols have no blur frames, so the cache bakes theirs. Both kinds spin through the same `StaticSpinSymbol`. Live demo (static-spin-provided-blur): https://pixi-reels.schmooky.dev/mechanics/spinning-art/#bring-your-own-blur-textures ### Split symbols URL: https://pixi-reels.schmooky.dev/mechanics/split-symbols/ A winning symbol breaks into two or more copies, and its reel makes room for them. Tags: split, splitSymbol, setColumn, resetColumns, ways, multiways, stacked-symbols When a symbol splits, the cell it stands on becomes two or more cells. The server says what the symbol splits into. Pass that list to `splitSymbol` with the symbol's reel and cell, and each id gets its own cell. The cells above and below keep their symbols. Any symbol one reel wide can split, either a 1x1 or a stacked big symbol in full view. The call returns the new cells, so the game can animate them. ```ts const { reelIndex, from, count } = reelSet.splitSymbol(reel, cell, ids, { height: 'grow' }); ``` The `height` option sets what happens to the reel when it gains cells: - `'grow'` is the default. The cells keep their size and the reel gets taller. The board re-anchors around it as the builder's `reelAnchor` says. - `'keep'` keeps the reel's height, and every cell on it shrinks to share that height, as cells on a MultiWays reel do. Nothing else moves. This is the default on MultiWays, where a reel's height is fixed. `resetColumns()` puts every reel back to the cells it was built with, at their original size. Both calls are built on `setColumn`, which shows a column of any length on one reel. The [infinity reels page](/mechanics/infinity-reels/#stacked-symbols-that-split) covers splits of stacked symbols on a board that grows. ##### Demos `splitSymbol()` places the cells of a split. The animation in these demos is each demo's own code. The first demo compares the two `height` modes, the second lets you split cells yourself, and the third splits on MultiWays. #### Grow or keep Both boards land the same result and split the same cells, one copy at a time. On the left the reel grows. On the right the reel keeps its height and its cells shrink. The titles show each reel's cell count and height, read from the engine. Under `'keep'` every symbol on the reel is resized, so its art has to draw at any cell height, as MultiWays art already does. These boards anchor their reels at the top with `reelAnchor('start')`, so a reel grows downward. With the default `'center'` a reel grows in both directions and the board re-centres. Live demo (split-modes): https://pixi-reels.schmooky.dev/mechanics/split-symbols/#split-modes #### Tap a cell to split it Tap any cell to split it in two, and the readout prints the call the tap made. Choose `grow` or `keep` above the board. Spin to start over, which calls `resetColumns()` first. Live demo (split-tap): https://pixi-reels.schmooky.dev/mechanics/split-symbols/#split-tap #### Splits on MultiWays On MultiWays a reel's height is fixed, so a split makes room inside the reel and the ways go up with the cell count. The server names the winning symbol and which of its cells split, into two or three copies each. `WinLines` draws the ways after every split. The cell count stays within the set's `[minCells, maxCells]`, as it would after a `setShape()`. Raise `multiways({ maxCells })` to allow more splits. The next spin's `setShape()` reshapes every reel from the cell count its split left it with. Live demo (split-in-place): https://pixi-reels.schmooky.dev/mechanics/split-symbols/#split-in-place #### Stacked symbols on infinity reels The [infinity reels page](/mechanics/infinity-reels/#infinity-reels-split) has a demo where a stack two to four cells tall splits into more single symbols than it had cells. Its reel grows past the frame in both directions while `expand()` adds reels. A reel that a block wider than one reel covers cannot change on its own, or the block's reels would no longer line up, so `splitSymbol()` and `setColumn()` throw there. Every demo on this page splits a symbol one reel wide. ### Starters URL: https://pixi-reels.schmooky.dev/mechanics/starters/ Small complete slots to copy as a starting point, one for each common layout. Tags: starter, 5x3, cascade, multiways, hold-and-win, horizontal, reverse, orientation Starting templates. Copy one, swap in your art and your math, and build from there. ##### Demos Each starter is a small working slot. The line slots come first, then the other common layouts, then the symbol pools that control what the reels draw while they spin. #### Line slots ##### Classic 5x3 slot A 5x3 slot that pays lines from left to right. Most slot games start from this layout. Live demo (classic-5x3): https://pixi-reels.schmooky.dev/mechanics/starters/#classic-5x3 ##### Horizontal The same template with the reels turned sideways. Three reels are stacked down the screen and each one scrolls along x. The change is one call, `.orientation('horizontal')`, plus the cell size you want on screen. `symbolSize(w, h)` and `symbolGap(x, y)` stay in screen space. On a horizontal set the strip advances by the symbol width, `x` is the gap between cells and `y` is the gap between reels. Index space does not change, so `reels(3).visibleCells(5)` and the `ColumnTarget[]` you pass to `setResult()` stay the same. Live demo (starter-horizontal-5x3): https://pixi-reels.schmooky.dev/mechanics/starters/#starter-horizontal-5x3 ##### Reverse The classic 5x3 with the reels running the other way. Symbols rise and each reel lands from below. The only change from the classic starter is `.direction('reverse')`. Buffers stay geometric. `bufferStart` is still the slot above the window, so on a reverse reel the next symbol to come in sits in `bufferEnd`. Read `reel.axis.feedEdge` instead of assuming. See [orientation and direction](/mechanics/orientation-and-direction/#roll-up) for per-reel and mixed-axis setups. Live demo (starter-reverse-5x3): https://pixi-reels.schmooky.dev/mechanics/starters/#starter-reverse-5x3 #### Other layouts ##### Cascade 6x4 A tumble slot built on `runCascade`. The first demo uses card symbols. The second is the same build with Spine art. Live demo (cascade-6x5): https://pixi-reels.schmooky.dev/mechanics/starters/#cascade-6x5 Live demo (cascade-6x5-spine): https://pixi-reels.schmooky.dev/mechanics/starters/#cascade-6x5 ##### MultiWays Each reel lands on its own number of cells between `minCells` and `maxCells` on each spin. The number of ways is the product of the per-reel cell counts. Call `reelSet.setShape(rowsPerReel)` before `setResult()`, with `serverGrid[i].length === rowsPerReel[i]`. Live demo (multiways): https://pixi-reels.schmooky.dev/mechanics/starters/#cascade-6x5 ##### Hold & Win Coins lock where they land and the free cells respin until the grid fills. Board events drive the HUD. The [Hold & Win page](/mechanics/hold-and-win/) builds on this board. Live demo (hold-and-win): https://pixi-reels.schmooky.dev/mechanics/starters/#hold-and-win #### Which symbols may spawn where `weights()` is one table for the whole set. A pool is layered on top of it for a scope, which can be one reel, the buffer cells, or the buffer cells of one reel. A pool changes only the random draw. An explicit `setResult` target always wins. ##### Keep a symbol out of the buffers Each spin moves to the next pool state. First there is no pool, then COIN is kept out of the buffers of reel 1 (the second reel, since indices start at 0), then out of the buffers above the window, then out of all buffers. The labels above and below the grid show what the hidden cells hold, so you can watch COIN stop parking there. Live demo (buffer-pool-exclude): https://pixi-reels.schmooky.dev/mechanics/starters/#symbol-pools ##### A draw table per reel Each reel can have its own draw table. Watch the spin, not the landing. Reel 0 draws low cards only, reel 2 is mostly wilds while it scrolls, and reel 4 never draws a wild. All five share the same `weights()` underneath. Live demo (per-reel-symbol-pool): https://pixi-reels.schmooky.dev/mechanics/starters/#symbol-pools ### Symbol classes URL: https://pixi-reels.schmooky.dev/mechanics/symbols/ Pick or write the class that draws a symbol, from sprites to Spine, and animate it when it wins. Tags: symbols, pools, buffers, weights, spine, horizontal, orientation A symbol is what fills one cell. Three classes ship with the library, and the abstract base class is there for your own. | Class | Use it for | |---|---| | `SpriteSymbol` | Static images. One texture per id. | | `AnimatedSpriteSymbol` | Sprite-sheet animation loops. | | `SpineSymbol` | Skeletal animation via `@esotericsoftware/spine-pixi-v8`. | | `ReelSymbol` (abstract) | Your own drawing. | #### Register The builder's `symbols()` call hands you a registry. You register a class with its options, not an instance. The engine constructs the symbols and pools them. ```ts builder.symbols((r) => { r.register('cherry', SpriteSymbol, { textures: { cherry: cherryTex } }); r.register('bar', AnimatedSpriteSymbol, { frames: barFrames, animationSpeed: 1.5 }); }); ``` #### Custom symbol Extend `ReelSymbol`. A symbol is activated with an id, may then get `playWin` or `stopAnimation`, and is deactivated when the pool takes it back. `resize(width, height)` runs on every swap, so positioning belongs there and not in the constructor. A symbol that positions itself in the constructor ends up in the wrong place after the first swap. ```ts import { ReelSymbol } from 'pixi-reels'; import { Graphics } from 'pixi.js'; export class BlockSymbol extends ReelSymbol { private _g = new Graphics(); constructor(opts: { colors: Record }) { super(); this.view.addChild(this._g); (this as any)._opts = opts; } protected onActivate(symbolId: string): void { const color = (this as any)._opts.colors[symbolId] ?? 0x888888; this._g.clear().roundRect(0, 0, 140, 140, 10).fill(color); } protected onDeactivate(): void { this._g.clear(); } async playWin(): Promise { // pulse for 400ms this.view.scale.set(1.1); await new Promise((r) => setTimeout(r, 400)); this.view.scale.set(1); } stopAnimation(): void { this.view.scale.set(1); } resize(w: number, h: number): void { this._g.clear().roundRect(0, 0, w, h, 10).fill(0x333333); } } // Register: builder.symbols((r) => { r.register('red', BlockSymbol, { colors: { red: 0xff6d70 } }); r.register('blue', BlockSymbol, { colors: { blue: 0x4cc2ff } }); }); ``` #### Weights A symbol with no weight gets 10. Change it with `weights()` on the builder. ```ts builder.weights({ cherry: 40, bar: 20, seven: 4 }); ``` A bigger number comes up more often. Weights only affect the random fill, which is the strip while it spins and the buffer cells. A grid from `setResult()` ignores weights, because the server decides what lands. `weights()` is one table for the whole set. To keep a symbol out of the buffer cells, or to make one reel draw differently, add a pool on top: ```ts builder.randomSymbols({ exclude: ['EMPTY'] }); // every reel builder.randomSymbols({ exclude: ['COIN'] }, { slots: 'buffer' }); // buffers only builder.randomSymbols({ weights: { WILD: 40 } }, { reel: 2 }); // reel 2 only ``` The same pools are available at run time through `reelSet.randomSymbols`, which is where a game-mode switch belongs. [Buffer indexing](/mechanics/big-symbols/#concept-buffer-indexing) has the layering rules. #### Headless testing `HeadlessSymbol` draws nothing and needs no textures or canvas. Use it in tests. ```ts import { HeadlessSymbol } from 'pixi-reels/testing'; builder.symbols((r) => { r.register('a', HeadlessSymbol, {}); r.register('b', HeadlessSymbol, {}); }); ``` [Cheats & testing](/learn/cheats-and-testing/) has the full setup. ##### Demos Production art comes first, then what you can do to a symbol after it lands. Placeholder classes and symbols for sideways sets are at the end. Art that overflows its cell is on [Layers](/mechanics/layers/). The blurred copies a reel shows while it spins are on [Spinning art](/mechanics/spinning-art/). #### Production art ##### Sprites from an atlas Sprite symbols loaded from one TexturePacker atlas, so every frame comes from one file and one texture upload. Each id is registered with `BlurSpriteSymbol` from `@pixi-reels/kit`, which shows the atlas's blur frame while the reel spins. Live demo (texture-atlas-symbols): https://pixi-reels.schmooky.dev/mechanics/symbols/#texture-atlas-symbols ##### Spine skins Each symbol tier is one Spine skeleton, and each id in the tier is a skin of it. The board is a gapless 3-4-4-4-4-3 grid. The skeletons are wrapped in `StaticSpinSymbol`, so the reels spin on blurred snapshots and no skeleton runs mid-spin. Live demo (spine-skins-3-4-4-4-4-3): https://pixi-reels.schmooky.dev/mechanics/symbols/#multi-skin-spine-tiers-on-a-compact-grid #### After the reels land ##### Your own win animation `WinPresenter` takes a `symbolAnim` callback that runs instead of `playWin()`. It gets the symbol, its cell and the win, so the animation can differ per `win.id`. Here the top line bounces harder than the other two. Live demo (paylines-custom-animation): https://pixi-reels.schmooky.dev/mechanics/symbols/#custom-per-symbol-animation ##### Transform a symbol A low symbol turns into a higher one after the reels stop. `reelSet.setSymbolAt(reel, cell, id)` swaps the one cell and leaves the rest of the reel alone. Call it after `spin:complete` or `spin:reelLanded`: it throws while the reel is spinning and on a big symbol's anchor. Live demo (symbol-transform): https://pixi-reels.schmooky.dev/mechanics/symbols/#symbol-transform #### Blank cells `EmptySymbol` takes a slot on the strip and draws nothing. Register it under an id such as `'empty'` and weight it heavily, and most cells land blank. Hold & Win boards use it for the empty cells between coins. Live demo (empty-symbol): https://pixi-reels.schmooky.dev/mechanics/symbols/#emptysymbol-render-nothing-for-a-registered-id #### Prototype symbols ##### Cards without art `CardSymbol` draws a coloured card with a label using `Graphics`, so it needs no assets and stays sharp at any cell size. The package exports it with a ready deck: `import { CardSymbol, CARD_DECK, WILD_CARD } from 'pixi-reels'`. Use it for prototypes and tests, and ship `SpriteSymbol`, `AnimatedSpriteSymbol` or `SpineSymbol` in the game. Live demo (card-symbol-debug): https://pixi-reels.schmooky.dev/mechanics/symbols/#cardsymbol-debug--prototyping-helper ##### Phase colours `PhaseCardSymbol` is a `CardSymbol` that is grey at rest and takes the colour of the phase its reel is in: sky for `start`, blue for `spin`, amber for `anticipation`, violet for `stop`, and green for a moment after landing. Use it to check phase timing by eye. Register it like any symbol, then call `PhaseCardSymbol.watch(reelSet.reels)`. The watcher colours every card from the reels' `phase:enter`, `landed` and `symbol:created` events, custom phases included, and returns a function that stops it. A card does not know its reel, so without the watcher it stays grey. `setPhase()` is public if something else knows the phase. `colors` overrides or extends `PHASE_CARD_COLORS`, and a phase with no entry uses `other`. Live demo (phase-colors): https://pixi-reels.schmooky.dev/mechanics/symbols/#phasecardsymbol-read-the-phase-off-the-board #### Sideways sets ##### Writing a symbol class A hand-written `ReelSymbol` on a horizontal set with wide cells. The class has no orientation code. `resize(width, height)` is in screen pixels whichever way the strip travels, so the plate's marker and glyph stay upright while the strip scrolls along x. The engine never rotates a symbol container, so third-party symbol classes work unchanged. A symbol can read `this.mainAxis` (`'y'` vertical, `'x'` horizontal) for effects that follow travel, such as motion blur. Do not use it for layout. Live demo (symbols-horizontal-resize): https://pixi-reels.schmooky.dev/mechanics/symbols/#authoring-a-symbol-for-a-sideways-set ##### One registration for both axes Four reels of three cells, built once vertical and once horizontal, landing the same grid. Both sets use the same symbol registration. The builds differ only in `symbolSize`, whose two numbers swap, because a horizontal board is the vertical one transposed. Live demo (symbols-transposed-pair): https://pixi-reels.schmooky.dev/mechanics/symbols/#the-same-symbols-on-both-axes ### Wilds and mystery symbols URL: https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/ Wilds that stay, spread or walk between spins, and mystery symbols that all turn into the same one. Tags: wild, sticky, multiplier, mystery, respin, cell-pin, horizontal, reverse, orientation A pin keeps one cell on one symbol id across spins. Sticky, expanding and walking wilds are all pins, and so are multiplier overlays and mystery reveals. A pin works with any symbol class. ```ts // Pin a cell. The id resolves through the SymbolFactory, like normal placement. const pin = reelSet.pin(reel, cell, 'sticky-wild', { turns: 'permanent' }); // Move it to another cell with a tween. await reelSet.movePin({ reel, cell }, { reel: reel - 1, cell }, { duration: 600 }); // Release it. reelSet.unpin(reel, cell); ``` #### What a pin guarantees - The cell shows the pinned symbol for as long as the pin exists. - The pin survives `spin()`, `setResult()` and `setShape()`. While the reel spins, an overlay symbol holds the cell and the reel scrolls underneath it. - On a MultiWays reshape the pin moves by its `migration` policy. With `'origin'` it returns to the cell it started on when the reel grows back. With `'frozen'` it clamps and forgets where it started. - Pins and nudges do not mix. `spin`, `setResult`, `pin` and `setShape` all throw while a `nudge()` is in flight. The [CellPin reference](/api/interfaces/index.CellPin/) has the full type. #### Three symbol instances One pin can be three different symbol instances at three different moments. All three come from the pool and all three go through `onActivate(symbolId)`. | Instance | When it exists | Where it lives | |---|---|---| | Reel-cell symbol | At rest, idle or landed | `reel.container` inside `viewport.maskedContainer` | | Overlay symbol | During a spin, one per active pin | `viewport.unmaskedContainer`, zIndex 10000 | | Flight symbol | During a `movePin` tween | `viewport.unmaskedContainer` | For a plain sticky cell this does not matter. It matters once you animate the pinned symbol while the reel moves, because the three are separate objects and animation state does not carry from one to the next. #### Lifecycle ``` pin(reel, cell, 'wild', { turns: 'permanent' }) The reel cell gets a fresh symbol from the SymbolFactory; onActivate runs. fires pin:placed(pin) spin() begins For each active pin, an overlay symbol is acquired, positioned at the pin's cell, and added to unmaskedContainer. fires pin:overlayCreated(pin, overlay) <- set the overlay animation here The reel scrolls underneath. The overlay is what the player sees. spin lands fires pin:overlayDestroyed(pin, overlay) <- stop animations here The overlay goes back to the pool. The reel-cell symbol takes over. movePin(from, to, opts) A flight symbol is acquired, positioned at `from`, added to unmaskedContainer. opts.onFlightCreated(flight) fires <- start a motion animation here GSAP tweens the flight's world coordinates from source to destination. opts.onFlightCompleted(flight) fires <- restore an idle animation here The reel cell at the destination is updated, the flight is released. fires pin:moved(newPin, oldCoord) unpin(reel, cell) (or the pin expires after `turns: N`) fires pin:expired(pin, reason) ``` #### Sprite symbol example ```ts import { ReelSetBuilder, SpriteSymbol } from 'pixi-reels'; const reelSet = new ReelSetBuilder() .reels(5).visibleCells(3).symbolSize(140, 140) .symbols((r) => { r.register('wild', SpriteSymbol, { textures: { wild: wildTex } }); // ... }) .ticker(app.ticker) .build(); // Spin once, land, then pin a permanent wild at (2, 1). const spin = reelSet.spin(); // do not await here: spin() does not reelSet.setResult([/* ... */]); // resolve until the result arrives await spin; reelSet.pin(2, 1, 'wild', { turns: 'permanent' }); // The next spin scrolls underneath the pinned wild. await reelSet.spin(); ``` Sprite symbols need no extra wiring. The pin creates the overlay, moves the cell on a reshape, and cleans up on unpin. #### Spine animation hooks With Spine symbols, each of the three instances above runs its own animation track. To show an `idle-sticky` track on the overlay and a `run` track on the flight, set them from the pin lifecycle events. The built-in `SpineSymbol` sets its `idle` and `win` tracks internally. A walking wild needs a small subclass that exposes track control: ```ts import { SpineSymbol, type SpineSymbolOptions } from 'pixi-reels'; export class WalkingSpineSymbol extends SpineSymbol { constructor(options: SpineSymbolOptions) { super(options); } /** Publicly swap the current animation track. */ setAnimation(name: string, loop = true): void { const spine = (this as any)._spine; if (!spine) return; if (!spine.skeleton.data.findAnimation(name)) return; spine.state.setAnimation(0, name, loop); } } ``` Then wire the hooks: ```ts // Overlay: sticky idle while the reel spins underneath reelSet.events.on('pin:overlayCreated', (_pin, overlay) => { (overlay as WalkingSpineSymbol).setAnimation('idle-sticky', true); }); // Flight: run animation during movePin async function walkLeft(pin: CellPin) { await reelSet.movePin( { reel: pin.reel, cell: pin.cell }, { reel: pin.reel - 1, cell: pin.cell }, { duration: 600, onFlightCreated: (flight) => { (flight as WalkingSpineSymbol).setAnimation('run', true); }, onFlightCompleted: (flight) => { (flight as WalkingSpineSymbol).setAnimation('idle', true); }, }, ); } ``` The flight symbol is a fresh instance from the pool, not the reel-cell symbol. Whatever you set on the cell (a track, a tint, a skin) is not on the flight. The flight starts from what `onActivate` gives it, so set its animation in `onFlightCreated` as above. The overlay's animation does not carry over to the landed cell either. When the reel lands, the overlay is released and the reel-cell symbol shows whatever its own `onActivate` set, which is plain `idle`. If the landed cell should keep the sticky animation, set it on the reel cell when the pin is placed: ```ts reelSet.events.on('pin:placed', (pin) => { if (reelSet.isSpinning) return; // the overlay handles it during a spin const sym = reelSet.getReel(pin.reel).getSymbolAt(pin.cell); (sym as WalkingSpineSymbol).setAnimation?.('idle-sticky', true); }); ``` An error thrown inside `onFlightCreated` or `onFlightCompleted` does not stop the move. The engine catches it and reports it on the notice channel as `pin-hook-threw`. The tween still runs, the pin moves and the flight symbol is released, so a bug in animation code does not leave the pin half moved. Every pooled symbol gets `resize(cellWidth, cellHeight)` when it is acquired. For a Spine symbol that computes a scale from the skeleton's bounds. If the skeleton data has not loaded yet, the first frame can show a zero-sized symbol. Once the pool is warm the skeleton is normally ready. If a pinned symbol pops in size, check this first. #### Related - [Walking wild](/mechanics/wilds-and-pins/#walking-wild-pin), the movePin pattern above as a demo - [Sticky wild](/mechanics/wilds-and-pins/#sticky-wild-pin), the smallest pin - [Expanding wild](/mechanics/wilds-and-pins/#expanding-wild-pin), one pin per cell of a reel - [Symbols](/mechanics/symbols/#concept), writing your own symbol class - [Spin lifecycle](/mechanics/skip/#concept), the events around a spin ##### Demos Most of these demos are built on a pin. You pin a cell once and the engine draws the pinned symbol over the spinning reel, counts down its turns and removes it when they run out. The wilds come first, then multipliers, held wins and mystery reveals. #### Wilds ##### Sticky wild The smallest pin. When a wild lands, pin its cell with `turns: N`. The engine keeps it on screen while the reel spins underneath and counts the turns down, so there are no extra sprites to manage and nothing to write into the next result grid. Live demo (sticky-wild-pin): https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/#sticky-wild-cellpin ##### Expanding wild A wild lands and the whole reel turns wild for N spins. The pins expire on their own when the turn counter reaches zero. Live demo (expanding-wild-pin): https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/#expanding-wild-pin ##### Walking wild A wild moves one reel left on each spin with `reelSet.movePin()`. The flight hooks are where a Spine symbol switches to its run animation. Move pins one at a time with `await`, not with `Promise.all`. Two pins moving to the same cell throws. Live demo (walking-wild-pin): https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/#walking-wild-movepin #### Multipliers ##### Multiplier wild Each wild carries its own multiplier in the pin payload. A badge with the value sits over the cell, and the win evaluation reads `pin.payload.multiplier`. Live demo (multiplier-wild-pin): https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/#multiplier-wild-pin ##### Positional multiplier cells The multiplier belongs to the cell, not the symbol. Any symbol that lands on a marked cell boosts the wins that pass through it. Live demo (positional-multiplier-pin): https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/#positional-multiplier-pin #### Sticky win respin Winning symbols lock for N respins while the rest of the grid spins. Pinning a cell that is already pinned resets its counter, so each new win restarts the window. Live demo (sticky-win-respin-pin): https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/#sticky-win-respin-pin #### Mystery symbols ##### Mystery reveal Mystery symbols land, then all of them turn into the same random symbol. The reveal uses `'eval'` pins, which clear themselves on the next spin. Live demo (mystery-reveal-pin): https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/#mystery-reveal-cellpin ##### Animated swap `setSymbolAt` swaps a symbol at once. `swapSymbols` plays the old symbols out, swaps them, holds, and plays the new ones in, with a stagger on each side. ```ts await reelSet.swapSymbols( [0, 1, 2].map((cell) => ({ reel: 1, cell, id: 'WILD' })), { outDelay: (_, i) => i * 0.06, holdMs: 200, inDelay: (_, i) => i * 0.09 }, ); ``` It also handles the details a hand-written reveal tends to miss. It raises the zIndex so an entrance that overshoots its cell is not clipped by the next cell, and it hides the new symbol after the swap, because re-activation resets `alpha` to 1 and the new art would show for a frame before its entrance. Each step can be left out. Pass `skipOut` when the art plays its own Spine `out` track, `skipIn` to leave the cells hidden and reveal them yourself, and `onSwapped` for a step in the middle that has to wait for an animation. `playIn()` and `playOut()` are the per-symbol hooks underneath, on the same contract as `playDestroy`. Override them for entrances and exits that suit your art. Cells are checked before anything starts, and an abort still performs the swap, so the board always matches the result. It works only at rest and only on single-cell symbols. A big symbol covers cells the frame layer reserves, so revealing one is a `setResult` or `setShape` job. Live demo (symbol-swap-reveal): https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/#reveal-a-mystery-symbol-out-swap-in ##### Spine mystery reveal Mystery bushes land and burst. A Spine overlay plays the reveal while `activate()` swaps the symbol underneath, so the player never sees the swap. Live demo (spine-mystery-reveal): https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/#reveal-a-mystery-symbol-out-swap-in #### Other reel directions Pins are in index space, so the pin code does not change when the reels run sideways or upward. ##### Expanding wild sideways The expanding wild on `.orientation('horizontal')`. The code is the same as above. The expansion fills a screen row instead of a column. Live demo (wilds-horizontal-expanding): https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/#expanding-wild-on-a-horizontal-set ##### Sticky wilds on reels that spin up A `.direction('reverse')` set. The reels travel upward through three respins while the pinned wilds hold their cells, and new wilds that land on the way stick too. Pin coordinates are geometric. Cell 0 is the top cell whichever edge the strip feeds from. Live demo (wilds-reverse-sticky-respin): https://pixi-reels.schmooky.dev/mechanics/wilds-and-pins/#sticky-wilds-on-a-roll-up-respin ## Learn ### Cheats & testing URL: https://pixi-reels.schmooky.dev/learn/cheats-and-testing/ Force outcomes with cheats and run full spins in Node, so mechanic tests give the same result every run. pixi-reels is built so you can test mechanics without a canvas. Two tools make that possible. - `createTestReelSet` builds a headless reel set wired to a `FakeTicker`. No renderer, no DOM. - `CheatEngine`, in the private `@pixi-reels/cheats` package, is a pluggable outcome source. It forces grids, scatters, lines and cascades on demand. Together they let you assert things like "this mechanic produces exactly 3 scatters, triggers anticipation on reel 5, and emits `spin:complete`." #### 1. Headless reel set ```ts import { createTestReelSet, expectGrid } from 'pixi-reels/testing'; const { reelSet, spinAndLand, destroy } = createTestReelSet({ reels: 5, visibleCells: 3, symbolIds: ['cherry', 'seven', 'wild', 'scatter'], }); await spinAndLand([ { visible: ['wild','wild','wild'] }, { visible: ['wild','wild','wild'] }, { visible: ['wild','wild','wild'] }, { visible: ['wild','wild','wild'] }, { visible: ['wild','wild','wild'] }, ]); expectGrid(reelSet, /* same 5x3 grid of 'wild' */); destroy(); ``` `spinAndLand()` calls `spin()`, then `setResult()`, then `slamStop()`. That bypasses all timing and resolves on a microtask, which suits CI. Note that `slamStop()` lands every reel outright. It does not go through the two-stage `skipSpin()` boost. #### 2. Force outcomes with cheats Cheats are pure functions that take a context and return a grid. ```ts import { CheatEngine, forceScatters, forceLine, holdAndWinProgress } from '@pixi-reels/cheats'; const engine = new CheatEngine({ reelCount: 5, visibleCells: 3, symbolIds: ['a', 'b', 'scatter', 'coin'], seed: 42, }); engine.register({ id: 'scat3', label: 'Force 3 scatters', enabled: true, cheat: forceScatters(3, 'scatter'), }); const { symbols, anticipationReels } = engine.next(); await spinAndLand(symbols.map((visible) => ({ visible }))); ``` ##### Built-in cheats | Cheat | Effect | |---|---| | `forceGrid(grid)` | Every spin returns this exact grid. | | `forceLine(cellIndex, id)` | Fills one cell index across every reel with `id`. | | `forceScatters(n, id)` | Places exactly `n` of `id` at random cells. | | `forceNearMiss(n, id, nearReel)` | `n-1` scatters, none on `nearReel`. Triggers anticipation there. | | `forceCell(reel, cell, id)` | Places `id` at `[reel, cell]`. | | `holdAndWinProgress(coinId, p)` | Keeps held coins, adds one new coin with probability `p`. | | `cascadeSequence([g1, g2, ...])` | Emits grids in order. | | `forceAnticipation(reels)` | Sets anticipation reels without constraining symbols. | ##### Write your own A cheat is `(ctx) => { symbols, anticipationReels, meta } | null`. Returning `null` passes the spin through, so the next cheat or the RNG handles it. ```ts const forcePairWild: Cheat = (ctx) => { const grid = /* random grid */; grid[2][1] = 'wild'; grid[3][1] = 'wild'; return { symbols: grid, anticipationReels: [] }; }; ``` #### 3. Assert events fired correctly ```ts import { captureEvents } from 'pixi-reels/testing'; const log = captureEvents(reelSet, ['spin:start', 'spin:complete']); await spinAndLand(grid); // grid is ColumnTarget[] expect(log.map((e) => e.event)).toEqual(['spin:start', 'spin:complete']); ``` #### 4. See a mechanic running The standalone demo apps left this repo in 2.0 and live in a separate one. The live, replayable mechanics are the [recipes](/mechanics/) on this site. Each page runs the source it shows, so you can read the wiring and watch it land. ### Debugging URL: https://pixi-reels.schmooky.dev/learn/debugging/ Snapshot the reel state as JSON, render an ASCII grid, trace every event. PixiJS draws to a canvas, so AI agents and automated tooling cannot see the reels. For that, pixi-reels ships three utilities: `debugSnapshot`, `debugGrid` and `enableDebug`. They return data only and live in the main entry. Drawing the same state on the canvas (cell geometry, a per-reel hud, a metrics plaque and a phase timeline for every spin) is the job of the `pixi-reels/debug` subpath, described [further down](#the-visual-overlay). #### One-liner: attach to window ```ts import { enableDebug } from 'pixi-reels'; enableDebug(reelSet); // window.__PIXI_REELS_DEBUG is now live ``` In Node, `enableDebug` does nothing. It checks `typeof window` and returns. In the browser devtools console: ```js __PIXI_REELS_DEBUG.log(); // [pixi-reels debug] spinning=false speed=normal ``` ```js const stop = __PIXI_REELS_DEBUG.trace(); // logs every event on the set bus from now on stop(); // and stops __PIXI_REELS_DEBUG.metrics(); // { rounds: [{ index: 1, profile: 'normal', duration: 2310, landOrder: [0, 1, 2, 3, 4], // reels: [{ phases: [{ phase: 'start', start: 0, end: 212 }, ...], // stoppingAt: 820, landedAt: 1204, tease: null, ... }, ...], // skips: [], ... }], // totals: { rounds: 1, skipped: 0, averageDuration: 2310 } } ``` `metrics()` covers every spin since `enableDebug` was called. For each reel it records when each phase started and ended, when the reel was asked to stop, when it landed, and its tease window. For each round it records every skip press, the landing order, and how many symbols were swapped into cells. Times are in ms since the round's `spin:start`. It is the text half of the timeline described below. `trace()` is `reelSet.events.onAny(...)` with a `console.log` inside. The same hook exists on every bus, and `onNotice` does the same for engine notices. ```ts import { onNotice } from 'pixi-reels'; reelSet.events.onAny((event, ...args) => log.push({ event, args })); reelSet.reels[4].events.onAny((event, info) => { if (event === 'phase:step') console.log(info); // { phase: 'stop', step: 'delay', status: 'cut' } }); const off = onNotice(({ kind, code, message }) => telemetry.note(kind, code, message)); ``` #### The events panel on the recipes site Every live demo on this site has a Debug button under the canvas. It opens the demo in Studio with debug on, at `/studio/#code=...&debug=1`. Studio is a full-viewport workbench: the recipe's code on the left, the reels in the middle, and the events panel on the right while debug is on. The panel lists every event that every reel set, reel and board in the demo raised, as it happens, with a timestamp relative to the round's `spin:start`. The payload is unwrapped under the event, one member per line. The filter takes words and `!words`, for example `skip !symbol:created`. Pause freezes the view while the recorder keeps going. Copy puts the visible rows on the clipboard as JSON. Engine notices show up as `notice` rows. On a recipe that returns a reel set, Studio also draws the overlay described below on it, with a toggle per group of layers: `info` (hud, metrics, timeline), `grid` (mask, cells, blocks, pins), `motion` (axis, feed, buffers, thresholds) and `bounds`. #### Programmatic snapshot ```ts import { debugSnapshot, debugGrid } from 'pixi-reels'; const snap = debugSnapshot(reelSet); // snap: { timestamp, isSpinning, currentSpeed, availableSpeeds, spotlightActive, // reelCount, visibleCells, reels: [...], grid: [[...], ...] } console.log(debugGrid(reelSet)); // ASCII table ``` `debugGrid` returns plain text, so you can log it, assert against it or paste it anywhere. The snapshot shapes are typed as `DebugSnapshot` and `DebugReelSnapshot`. They contain no PixiJS objects, so `JSON.stringify()` always works, and they survive `structuredClone` and `postMessage` without losing anything. #### Using snapshots in tests When `expectGrid()` fails, the test harness puts a snapshot into the error message for you. ``` Grid mismatch: reel 0 cell 1: expected "seven" got "cherry" Current grid: ``` #### Recording sessions When a bug only reproduces across a whole spin, record it and read the sequence back offline. Recording is driven by events rather than frames. `startRecording` listens for `spin:start`, `spin:reelLanded`, `spin:allLanded` and `spin:complete`, and captures a snapshot at each. It also detaches itself when the reel set emits `destroyed`. A spin yields a handful of frames. ```ts import { startRecording, stopRecording, getFrames, clearFrames } from 'pixi-reels'; startRecording(reelSet, 'spin-1'); // (reelSet, tag?, { maxFrames? }) await reelSet.spin(); reelSet.setResult([/* ... */]); await /* the spin */; stopRecording(reelSet); const frames = getFrames('spin-1'); // RecordedFrame[] console.log(`captured ${frames.length} frames`); clearFrames(); ``` Each `RecordedFrame` is `{ tag, trigger, snapshot }`: the tag you passed, the event name that triggered the capture, and the `DebugSnapshot`. The timestamp lives inside `snapshot`. Two things to know about the buffer. - It is shared by the whole process and is not cleared between sessions, so a bare `getFrames()` returns every take since the page loaded. Pass the tag. - It is a rolling window of 1000 frames by default (`maxFrames`). A long session drops the oldest frames without telling you. #### The visual overlay `debugSnapshot` tells you what the engine thinks. `debugOverlay` draws it on top of the canvas, so you can see whether the picture agrees. It lives at the `pixi-reels/debug` subpath and draws with [pixi-silk](https://pixi-silk.schmooky.dev), an optional peer dependency that renders every shape as an exact distance field, so a 1px outline stays a clean 1px line at whatever scale the reel set is fitted to. ```bash pnpm add -D pixi-silk ``` ```ts import { debugOverlay } from 'pixi-reels/debug'; const overlay = debugOverlay(reelSet, { layers: ['cells', 'hud', 'timeline'], // or 'all' live: true, // redraw each tick; false = follow the spin events ticker: app.ticker, // drive the live redraw off your ticker }); overlay.setLayers(['cells', 'pins']); overlay.redraw(); overlay.destroy(); ``` A build that never imports `pixi-reels/debug` never needs `pixi-silk`. The overlay draws through WebGL. On a WebGPU renderer its shapes draw nothing, so debug on `app.init({ preference: 'webgl' })`. Building one in a headless test needs a canvas stand-in; the [4.0 migration guide](/reference/migrating-to-4-0/) has it. | Layer | Draws | Catches | |---|---|---| | `mask` | Mask box and per-reel rects | Pyramid peek; a mask strategy clipping on the wrong axis | | `cells` | Every visible cell, with `reel,cell` labels | Off-by-one in cell indexing | | `buffers` | The off-window strip cells, dimmer | Buffer targets and big-symbol tails, which are otherwise invisible | | `axis` | One arrow per reel, pointing the way it travels | A reverse direction or a horizontal orientation, at a glance | | `feed` | The edge new symbols arrive at | Confirms `feedEdge` follows from the direction | | `thresholds` | The wrap lines | A symbol drawn past one | | `bounds` | Real `view.getBounds()` per symbol | Spine overrun past its cell | | `blocks` | `getBlockBounds` outline for big symbols | 2x2 anchors, and block/screen transposition | | `pins` | Pin cells and pin-overlay positions | A pin overlay drifting off its cell | | `hud` | A row per reel, `r0 VF feed=start spd=0.0 idle cells=3`, with a phase swatch and a speed meter | Reading state without opening the console | | `metrics` | A plaque under the mask for the current round: its length, time to the first stop, landing order and the largest gap, tease windows, the last skip press, symbols built, events, fps | Why a spin felt slow, in numbers | | `timeline` | Every reel's phases for the round on one time axis, the speed trace on top, a tick at the stop request, a dot at the landing, a dashed line per skip press | Stagger, tease holds and a slam that cut a stop short, as shapes | The overlay draws into the `ReelSet` itself, so it renders above the viewport and above the spotlight container. The geometry and the hud stay inside the mask. `metrics` and `timeline` sit under it, side by side when the set is wide enough, so they add to the reel set's bounds. Fit your camera after enabling them. The overlay is dev-only. It reads internals, it is not semver-protected, and it must not reach a production bundle. ##### How to read the timeline Each lane is one reel. The colored blocks are its phases, in the colors `PhaseCardSymbol` paints: sky for `start`, blue for `spin`, amber for `anticipation`, violet for `stop`. The white line on top is `speedNormalized`, so a surge-then-crawl tease shows as a bump and a slope. The white tick is when the controller asked the reel to stop, the green dot is when it came to rest, and the amber underline is its tease window. A red dashed line is a slam press, a yellow one a quicken. While the round runs, a cursor marks now. ##### Recording from the start The `metrics` and `timeline` layers read a `SpinMetrics`. By default the overlay starts its own, so they show the rounds from the moment it was created. To see the spin before that, keep a recorder running and hand it over. ```ts import { SpinMetrics, debugOverlay } from 'pixi-reels/debug'; const metrics = new SpinMetrics(reelSet, { ticker: app.ticker }); // at boot // ... later, when something looks wrong: debugOverlay(reelSet, { layers: ['timeline', 'metrics'], live: true, ticker: app.ticker, metrics }); ``` `metrics.current` is the latest round, `metrics.rounds` the last 20, and `metrics.snapshot()` a plain-JSON copy. Without a `ticker` it still records every event-driven time; the ticker adds the speed trace. It lets go of the buses when the reel set is destroyed. ##### DebugPlaque Every panel is built from this plate, and it is exported for your own readouts. It shows rows of monospace text on a smooth rounded plate, with an optional title, swatches for a legend, and meters for a speed or a progress. It sizes itself from the character count, so it is exact without measuring text and cheap to update every frame. ```ts import { DebugPlaque } from 'pixi-reels/debug'; const hud = new DebugPlaque({ text: 'press spin', minWidth: gridWidth }); hud.position.set(0, gridHeight + 10); reelSet.addChild(hud); hud.text = `landed ${count} reels`; // like a Text hud.update({ rows: [{ text: 'spin', swatch: 0x2563eb, meter: reel.speedNormalized }] }); ``` `minWidth` and `reserveRows` fix its size up front, and `maxWidth` wraps long rows, so a readout never outgrows a camera that was fitted to it once. Every status line, label and legend in the recipes on this site is one of these. Its companion for dashed boxes is `roundRectPath(g, x, y, w, h, r)`. pixi-silk dashes paths but strokes `roundRect` solid, so this helper traces the box as one path. A following `.stroke({ dash: [7, 5] })` then dashes it round the corners. ##### The overlay as data A canvas is opaque to CI and to AI agents, and a screenshot loses some of what the overlay draws anyway. A travel arrow pointing up has the same bounding box as one pointing down. So the overlay also hands back plain JSON. ```ts const info = debugOverlay(reelSet, { layers: 'all' }).describe(); // info.round is the round the metrics and timeline panels show, as plain JSON info.reels[0]; // { // reel: 0, // orientation: 'vertical', direction: 'reverse', feedEdge: 'end', // axisArrow: { fromMain: 249.6, toMain: 62.4 }, // signed: to - from is the direction // feedMain: 187.2, // thresholds: { start: -124.8, end: 249.6 }, // visibleCells: 3, // phase: 'idle', // } ``` The signed span of `axisArrow` is the assertion worth making. It is the one thing that tells a reverse reel from a forward one, and a bounding box cannot see it. #### Console notices Separate from the debug tooling above, the library talks to you through one channel, for things a developer should act on: a call that will not do what you meant, a hook of yours that threw, a value that had to be clamped. It never reports per-frame state, and nothing in it runs in the hot path. Every notice carries a stable code, so you can grep for it, search for it in these docs, or quote it in a bug report. ``` pixi-reels quicken-cascade requestSkip({ mode: 'quicken' }) has nothing to quicken in cascade mode: a tumble reel lands by placing its symbols... ``` ##### Levels One knob, four settings. Each level includes the ones before it. | Level | Prints | Use it when | |---|---|---| | `'info'` | everything | The default. Advisory notices (the mask-strategy auto-pick, warp/unmask caveats) plus every problem. | | `'warn'` | errors + warnings | You have read the advisories and want them out of the way, but still want to hear about problems. | | `'error'` | errors only | Something the library could not do, and recovered from. Nothing else. | | `'silent'` | nothing | Production, once you have read the warnings at least once. | ```ts import { setLogLevel, getLogLevel } from 'pixi-reels'; setLogLevel('silent'); getLogLevel(); // 'silent' ``` The default is `'info'` rather than something quieter because several notices, the mask-strategy auto-pick in particular, used to print unconditionally. A quieter default would have removed advice the engine had always given, without telling anyone. ##### What it looks like where In a browser a notice renders as a styled badge: a `pixi-reels` pill, then the code, then the message. Everywhere else (Node, a test runner, CI) `%c` styling does not exist and the console would print the style directives literally, so the notice degrades to a plain line. ``` [pixi-reels] warn(quicken-cascade) requestSkip({ mode: 'quicken' }) has nothing to quicken... ``` Notices go out on `console.warn`, `console.error` and `console.info` rather than through one `console.log`. That keeps devtools level filtering, stack capture and the browser's own warn/error styling working. Any extra detail is passed straight through, so an `Error` argument keeps its stack instead of being stringified. A few notices fire only once per process (`buffer-clamped`, for instance), so a builder constructed in a loop cannot flood the console. The full list of codes lives in the [events reference](/reference/api-events/). #### The DEFAULTS constant `DEFAULTS`, exported from `pixi-reels`, holds five of the engine's defaults: `bufferSymbols`, `symbolGap`, `initialSpeed`, `maxPoolPerKey` and `zIndexStep`. Read it when you want to set a value relative to one of those, for example `builder.bufferSymbols(DEFAULTS.bufferSymbols + 2)`. Other defaults live with the feature that owns them: tumble's in `TumbleConfig`, stacking and pin migration on the builder. ### Getting started URL: https://pixi-reels.schmooky.dev/learn/getting-started/ Install pixi-reels and get a 5x3 reel set spinning in a PixiJS v8 app. pixi-reels is a reel engine for a PixiJS v8 app. You add it to the stage like any other container. #### You need - Node 20 or newer, and pnpm, npm or yarn - A PixiJS v8 app. The engine runs off `app.ticker` - For Spine symbols, `@esotericsoftware/spine-pixi-v8` as well #### Install ```bash pnpm add pixi-reels pixi.js gsap # only if you want Spine symbols pnpm add @esotericsoftware/spine-pixi-v8 ``` #### Boot Pixi, build a ReelSet ```ts import { Application } from 'pixi.js'; import { ReelSetBuilder, SpriteSymbol } from 'pixi-reels'; import { cherryTex, sevenTex, barTex } from './textures'; const app = new Application(); await app.init({ width: 900, height: 540, background: '#0a0d14' }); document.body.appendChild(app.canvas); const reelSet = new ReelSetBuilder() .reels(5) .visibleCells(3) .symbolSize(140, 140) .symbols((r) => { r.register('cherry', SpriteSymbol, { textures: { cherry: cherryTex } }); r.register('seven', SpriteSymbol, { textures: { seven: sevenTex } }); r.register('bar', SpriteSymbol, { textures: { bar: barTex } }); }) .weights({ cherry: 40, seven: 10, bar: 20 }) .ticker(app.ticker) .build(); app.stage.addChild(reelSet); const result = await reelSet.spin(); console.log(result.symbols); ``` #### Did it work The reels spin, then stop on three rows of random symbols. If nothing happened, it is usually one of these. | You see | Do this | |---|---| | Blank canvas | Set `reelSet.x` and `reelSet.y`. The set sits at (0,0) until you move it. | | `ticker() must be called` | Add `.ticker(app.ticker)` to the builder. | | Symbols invisible | The texture never loaded, or `symbolSize()` does not match your art. The engine calls `resize()` on every symbol swap. | #### Where next - [Your first reelset](/learn/your-first-reelset/) builds a real slot step by step - [Spin lifecycle](/mechanics/skip/#concept) explains the spin API - [Cheats & testing](/learn/cheats-and-testing/) shows how to test a mechanic - [Recipes](/mechanics/) shows what the engine can do ### Recipe previews URL: https://pixi-reels.schmooky.dev/learn/recipe-previews/ How to give a recipe a card thumbnail and inline body images. Drop a file in public/; a missing one falls back to a generated placeholder. Every card on the recipes index and every topic page can carry preview media: a gif, an animated webp, a static screenshot, or a short clip. Nothing is required. Drop a file in the right place and it shows up. Anything missing renders a generated placeholder built from the title, so the index and the pages always look finished. #### Card thumbnails Each card on the [/mechanics/](/mechanics/) grid is one topic page, and it shows a 16:10 thumbnail. The card looks for its media in this order. 1. A hand-drawn cover for the slug, from `components/recipes-index/covers.ts`. Every topic page has one at the moment, so the index shows these. 2. An explicit `image` path from the topic page's frontmatter, if that file exists under `public/`. See [Non-conventional paths](#non-conventional-paths). 3. A file at the conventional path. 4. The generated placeholder. The conventional path is: ``` public/recipes//card. ``` where `` is the topic page's file name under `src/content/recipes/`, which is also its URL. There is no registry to edit. The card picks the file up on the next build. Supported extensions, in priority order: ``` gif webp avif png jpg jpeg mp4 webm ``` Animated formats win over static ones, so if both `card.gif` and `card.png` exist, the gif is used. `mp4` and `webm` render as a muted, looping, autoplaying `