pixi-reels
All mechanics

Mechanics

Sideways and upward reels

Reels that run sideways or upward, for banners and portrait layouts. The art stays upright.

Demos

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.

Loading recipe…

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.

Loading recipe…

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.

Loading recipe…

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.

Loading recipe…

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 ReelSets in one container. The engine spins and lands both. The recipe evaluates the ways and spotlights the cells, because pixi-reels never computes wins.

Loading recipe…

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.

Loading recipe…

Concept

Orientation & direction
How a reel's travel axis works, why buffers are named by screen side, and what stays in screen space.

A reel can travel down, up, or sideways. Two builder settings control that, and they do not affect each other:

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 rightsymbols 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.

// 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:

.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#

.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:

.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#

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.

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 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:

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.

Recipes#

API

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

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

  • Reelclass

    One vertical column of a slot board.

  • ReelSetclass

    The whole slot board as one object.

  • The configurator you call before every reel set.

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

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

  • Registry that maps symbolIds to their constructors and options.

  • debugOverlayfunction

    A layered visual debug overlay for a ReelSet, drawn with pixi-silk: mask, cell, buffer, axis, symbol-bounds, big-symbol-block and pin geometry, a per-reel…

  • stepfunction

    Build a PhaseStep.

  • CellBoundsinterface

    Axis-aligned bounding box of a single grid cell in ReelSet-local coordinates. Returned by reelSet.getCellBounds(reel, cell).

  • ColumnTargetinterface

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

  • Which screen axis a reel's strip travels along. 'vertical' runs the strip on Y with reels marched along X; 'horizontal' runs the strip on X with reels marched…

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

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

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

Questions

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

How do I spin one reel up and another down (mixed directions)?open

.directionPerReel(['forward', 'reverse', 'forward', ...]) on the builder, one entry per reel (length must equal .reels(n)). Reels you omit fall back to .direction(). A big symbol spanning reels (size.reels > 1) throws at build() when the directions it straddles are mixed.

Question page
How do I make reels horizontal instead of vertical?open

.orientation('horizontal') on the builder runs the strip along X, with reels marched along Y. Everything else is orientation-neutral, pyramids, MultiWays, big symbols and cascades all work on either axis. symbolSize(width, height) stays screen-space, so a horizontal set takes its travel pitch from width.

Question page
How do I zoom and scale the board into a big-win banner?open

Scale reelSet (a Container) with a GSAP tween for the zoom, and build the banner in your UI layer.

Question page
How do I add a top horizontal reel (extra strip above the board)?open

Build it as a second ReelSet with .orientation('horizontal'), one reel (.reels(1)) whose .visibleCells(n) is the number of symbols in the strip, and add it to the stage above your main set. It is a normal reel set, so it spins, lands and cascades with the same API. There is no single-call "banner" helper; the two sets stay independent and you position them yourself.

Question page
How do I reflow the HUD when the orientation changes?open

Reposition your HUD in your resize handler; the engine exposes the board's size, the layout is yours.

Question page
How do I build the horizontal reel above the reels that shows which symbols pay this round?open

It is a normal ReelSetBuilder with .orientation('horizontal'). There is no separate builder in v2. HorizontalReelBuilder and HorizontalReel were removed, because a sideways banner is just a reel set whose strip travels along X. Use .reels(1) with .visibleCells(n) for the n symbols in the banner, register symbols and pass a ticker exactly as usual. The spin contract is unchanged: spin() returns a promise, setResult([{ visible: ids }]) takes ColumnTarget[] (one entry, since the banner is a single reel) and triggers the stop, and the promise resolves with a SpinResult. Add the built set to the stage above your main one.

Question page
Can the horizontal banner reel cascade like the main reels when a symbol was part of a win?open

Yes. The banner is a plain ReelSet, so it uses the same cascade API as the main board. Build it with .orientation('horizontal') plus .tumble({ fall, dropIn }), then await reelSet.refill({ winners, grid }) with the winning Cells ({ reel, cell }) and the next ColumnTarget[], or await reelSet.runCascade({ detectWinners, nextGrid }) for the whole destroy-refill-check loop. Progress is observable through cascade:fall:*, cascade:dropIn:* and cascade:chain:end.

Question page