pixi-reels
All mechanics

Mechanics

Symbol classes

Pick or write the class that draws a symbol, from sprites to Spine, and animate it when it wins.

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. The blurred copies a reel shows while it spins are on 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.

Loading recipe…

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.

Loading recipe…

Assets provided by Thunderkick

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.

Loading recipe…

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.

Loading recipe…

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.

Loading recipe…

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.

Loading recipe…

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.

Loading recipe…

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.

Loading recipe…

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.

Loading recipe…

Concept

Symbols
How to register a symbol class, write your own, and weight the random fill.

A symbol is what fills one cell. Three classes ship with the library, and the abstract base class is there for your own.

ClassUse it for
SpriteSymbolStatic images. One texture per id.
AnimatedSpriteSymbolSprite-sheet animation loops.
SpineSymbolSkeletal 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.

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.

import { ReelSymbol } from 'pixi-reels';
import { Graphics } from 'pixi.js';

export class BlockSymbol extends ReelSymbol {
  private _g = new Graphics();

  constructor(opts: { colors: Record<string, number> }) {
    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<void> {
    // 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.

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:

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 has the layering rules.

Headless testing#

HeadlessSymbol draws nothing and needs no textures or canvas. Use it in tests.

import { HeadlessSymbol } from 'pixi-reels/testing';

builder.symbols((r) => {
  r.register('a', HeadlessSymbol, {});
  r.register('b', HeadlessSymbol, {});
});

Cheats & testing has the full setup.

API

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

  • Symbol implementation using PixiJS AnimatedSprite. Swaps frame arrays on activate. Win animation plays the full sequence.

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

  • A ReelSymbol that renders nothing and never animates.

  • A ReelSymbol implementation that does no rendering at all.

  • The PhaseCardSymbol class in the pixi-reels API.

  • Reelclass

    One vertical column of a slot board.

  • The configurator you call before every reel set.

  • Single bounding-box mask covering every reel. Use this when symbols need to overlap across reel boundaries. typical for slots with big symbols that span…

  • ReelSymbol implementation using Spine 2D skeletons.

  • Symbol implementation using Spine 2D skeletal animation.

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

  • Symbol implementation using a simple PixiJS Sprite. Swaps texture on activate. Win animation is a scale pulse via GSAP.

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

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

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

  • ColumnTargetinterface

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

  • Wininterface

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

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

  • Fill per phase for PhaseCardSymbol. Keys are the names phases register under ('start', 'spin', 'anticipation', 'stop', the cascade and MultiWays keys, and any…

  • 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 set the pixel size of a single symbol cell?open

.symbolSize(width, height) on the builder sets the pixel box of one cell; pair it with .symbolGap(x, y) for spacing.

Question page
How do I put specific symbols on the board at startup?open

Seed the opening grid with .initialFrame(grid) on the builder, passing one ColumnTarget per reel, e.g. { visible: ['A', 'B', 'C'] }.

Question page
How do I register the list of symbol ids my game uses?open

Inside .symbols((r) => ...), call r.register(id, SymbolClass, options) once per symbol id your game uses.

Question page
How do I change the symbols after the board is already built?open

Use reelSet.setResult(grid) (animated, through a spin) or reelSet.setSymbolAt(col, row, id) for an instant in-place swap while the reels are idle.

Question page
How do I add a brand-new symbol type to the game?open

Subclass ReelSymbol and implement all five abstract members, onActivate, onDeactivate, resize, playWin, stopAnimation, then register it with r.register(id, MySymbol, opts). resize() runs on every symbol swap, so anything positional belongs there rather than in the constructor.

Question page
How do I make a symbol from a single texture/sprite?open

Use the built-in SpriteSymbol: r.register(id, SpriteSymbol, { textures }) maps each id to a Texture.

Question page
How do I render nothing for an empty cell?open

Register the EmptySymbol class against an id like empty. It renders nothing but still occupies the slot.

Question page
How do I set how often each symbol appears (weights)?open

Pass relative weights to .weights({ id: n }): a higher number lands more often. A weight of 0 means the symbol never comes from random fill, so it can only be placed by the server / setResult.

Question page
How do I make one symbol much rarer than the rest?open

Give it a small number in .weights({ rare: 1, common: 20 }), or 0 so it never comes from random fill (server-placed only).

Question page
How do I anchor a symbol at the cell center vs the top-left?open

Pass anchor in the symbol options (e.g. SpriteSymbol's { anchor: { x: 0.5, y: 0.5 } }); SpriteSymbol defaults to top-left, Spine centers in resize().

Question page
How do I resize a symbol whenever the cell size changes?open

Implement resize(width, height) on your ReelSymbol and put all positioning there. It is called on every symbol swap, so the constructor is the wrong place.

Question page
How do I read which symbol is currently shown in a given cell?open

reelSet.getVisibleGrid() returns the whole string[][], or read the live instance with reelSet.getReel(col).getSymbolAt(row).

Question page
How do I let a symbol's art overflow its cell without clipping?open

Mark the id { unmask: true } via .symbolData(...) so the engine reparents its view to the viewport's unmasked container, above the reel mask (server-placed ids only).

Question page
How do I give two different ids the same artwork?open

Register both ids with the same class and point them at the same texture / skeleton in the options map.

Question page
How do I tint or recolor a symbol per spin (e.g. a charged state)?open

Tint the symbol's view (a PixiJS Container) in onActivate, e.g. set this.view.tint for a charged state.

Question page
How do I block a new spin until all animations finish?open

Gate the spin button on the spin() promise (and any post-land animation promises) before calling spin() again.

Question page
How do I guarantee at least one specific symbol lands this spin?open

Place it explicitly in the ColumnTarget you pass to setResult, or use the example CheatEngine's forceScatters / forceCell (copy it from the private @pixi-reels/cheats package).

Question page
How do I make symbols rise up from below (roll-up)?open

.direction('reverse') on the builder makes the strip travel toward the smaller coordinate, a roll-up on a vertical set, with new symbols feeding in from the opposite edge. Use .directionPerReel([...]) to set it per reel.

Question page
A symbol gets destroyed by an object. How do I play its destroy animation?open

Override playDestroy(opts) on your ReelSymbol. The default is a ~200 ms scale-and-fade implode: a ~60 ms anticipation pop, then a ~140 ms collapse to scale: 0 / alpha: 0, with no rotation. For Spine, play a disintegration or shatter track. Honour opts.signal so a slam can abort it mid-tween.

Question page
How do I morph one symbol into a different (higher) one mid-round?open

Swap to the higher id in place with setSymbolAt, playing a transition tween in the old symbol's view first.

Question page
How do I charge a symbol up over several wins before it activates?open

Track a per-symbol charge count in your state, advance its animation each win, and activate when it hits the threshold.

Question page
How do I show a paytable screen for the registered symbols?open

Build a paytable screen from your registered symbol ids and pays. It is UI, not an engine feature.

Question page
How do I recycle symbols instead of recreating them every spin?open

The engine already pools symbols via ObjectPool, recycling instances instead of recreating them each spin.

Question page
How do I cap how many instances of a symbol are pooled?open

.poolCapacity(maxPerSymbol) caps how many of each symbol the pool keeps.

Question page
How do I dispose everything without leaking textures or tickers?open

reelSet.destroy() disposes the reels, pools, masks and ticker refs, every subsystem implements Disposable.

Question page
How do I print an ASCII grid of the visible symbols?open

__PIXI_REELS_DEBUG.grid() RETURNS an ASCII table of the visible symbols as a string (debugGrid(reelSet) is the direct import). Use __PIXI_REELS_DEBUG.log() if you want it printed.

Question page
How do I add a cheat panel (force a symbol, force a hit)?open

Wire the example CheatEngine (forceGrid / forceScatters / forceCell / holdAndWinProgress, from the private @pixi-reels/cheats package) to UI toggles.

Question page
How do I map a server symbol-id scheme onto my registered ids?open

Translate the server's symbol scheme to your registered ids when building the ColumnTarget[].

Question page
How do I handle a desync between the animation and the server state?open

Reconcile to the server state on each response and re-setResult / setSymbolAt if the display drifted.

Question page