pixi-reels

Start here

Getting started

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#

pnpm add pixi-reels pixi.js gsap
# only if you want Spine symbols
pnpm add @esotericsoftware/spine-pixi-v8

Boot Pixi, build a ReelSet#

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 seeDo this
Blank canvasSet reelSet.x and reelSet.y. The set sits at (0,0) until you move it.
ticker() must be calledAdd .ticker(app.ticker) to the builder.
Symbols invisibleThe texture never loaded, or symbolSize() does not match your art. The engine calls resize() on every symbol swap.

Where next#