pixi-reels

BoardGrid

pixi-reels


pixi-reels / index / BoardGrid

Class: BoardGrid

Defined in: board/BoardGrid.ts:90

A grid of cells that each spin independently — the generic “board of reels” primitive. Every cell is its own 1×1 ReelSet, so it inherits the engine’s phases, speed modes and pooling rather than a parallel lighter reel.

Deliberately mechanism-only: it knows nothing about coins, locks, respins, value or any game rule. It lays the grid out, hands back per-cell geometry and live symbol instances, places symbols instantly, and spins a caller-chosen set of cells to caller-chosen results. Build your own feature on top by owning the rules in your own code; HoldAndWinBoard is one such opinionated layer, built entirely on this public surface.

const grid = new BoardGrid({
  cols: 3, rows: 3, cellSize: 80,
  symbols: (r) => r.register('prize', PrizeSymbol, {}),
  weights: { prize: 1, empty: 4 },
  ticker: app.ticker,
});
app.stage.addChild(grid.container);

await grid.spinCells(
  grid.cells().map((cell) => ({ cell, id: pick() })),  // you decide each result
  (cell, id) => console.log('landed', cell, id),       // react as each settles
);

Implements

Constructors

Constructor

new BoardGrid(opts: BoardGridOptions): BoardGrid;

Defined in: board/BoardGrid.ts:102

Parameters

ParameterType
optsBoardGridOptions

Returns

BoardGrid

Properties

PropertyModifierTypeDefined in
cellSizereadonlynumberboard/BoardGrid.ts:94
colsreadonlynumberboard/BoardGrid.ts:92
containerreadonlyContainerboard/BoardGrid.ts:91
emptyIdreadonlystringboard/BoardGrid.ts:96
gapreadonlynumberboard/BoardGrid.ts:95
rowsreadonlynumberboard/BoardGrid.ts:93

Accessors

isDestroyed

Get Signature

get isDestroyed(): boolean;

Defined in: board/BoardGrid.ts:252

Returns

boolean

Implementation of

Disposable.isDestroyed

Methods

cellBounds()

cellBounds(cell: BoardCell): {
  height: number;
  width: number;
  x: number;
  y: number;
};

Defined in: board/BoardGrid.ts:171

Board-local bounds of a cell. container.toGlobal for stage space.

Parameters

ParameterType
cellBoardCell

Returns

{
  height: number;
  width: number;
  x: number;
  y: number;
}
NameTypeDefined in
heightnumberboard/BoardGrid.ts:171
widthnumberboard/BoardGrid.ts:171
xnumberboard/BoardGrid.ts:171
ynumberboard/BoardGrid.ts:171

cellCenter()

cellCenter(cell: BoardCell): {
  x: number;
  y: number;
};

Defined in: board/BoardGrid.ts:177

Board-local center of a cell — flight / trail start and end points.

Parameters

ParameterType
cellBoardCell

Returns

{
  x: number;
  y: number;
}
NameTypeDefined in
xnumberboard/BoardGrid.ts:177
ynumberboard/BoardGrid.ts:177

cells()

cells(): BoardCell[];

Defined in: board/BoardGrid.ts:166

Every cell coordinate, row-major.

Returns

BoardCell[]


destroy()

destroy(): void;

Defined in: board/BoardGrid.ts:256

Returns

void

Implementation of

Disposable.destroy


place()

place(cell: BoardCell, id: string): void;

Defined in: board/BoardGrid.ts:198

Place a symbol instantly (no spin), with blank off-window buffers.

Parameters

ParameterType
cellBoardCell
idstring

Returns

void


reelAt()

reelAt(cell: BoardCell): ReelSet;

Defined in: board/BoardGrid.ts:188

The cell’s underlying 1×1 ReelSet, for driving one cell directly.

Parameters

ParameterType
cellBoardCell

Returns

ReelSet


setProfile()

setProfile(cell: BoardCell, name: string): void;

Defined in: board/BoardGrid.ts:193

Select a registered speed profile by name for one cell.

Parameters

ParameterType
cellBoardCell
namestring

Returns

void


skipSpinning()

skipSpinning(): number;

Defined in: board/BoardGrid.ts:237

Slam every in-flight cell to its landed position. Returns the count.

Returns

number


spinCells()

spinCells(targets: BoardSpinTarget[], onLanded?: (cell: BoardCell, id: string) => void | Promise<void>): Promise<void>;

Defined in: board/BoardGrid.ts:218

Spin each target cell and stop it showing its id; onLanded fires per cell as it settles, in stagger order. The caller selects which cells spin and to what — this layer applies no lock/free policy of its own. Set profiles via setProfile first.

onLanded may be async: if it returns a promise, that cell’s task awaits it, so the returned promise resolves only once every cell has landed and its after-land work has finished. Cells still run concurrently, so an early cell’s reveal overlaps with later cells still spinning.

Parameters

ParameterType
targetsBoardSpinTarget[]
onLanded(cell: BoardCell, id: string) => void | Promise<void>

Returns

Promise<void>


symbolAt()

symbolAt(cell: BoardCell): ReelSymbol;

Defined in: board/BoardGrid.ts:183

Live symbol instance currently shown in a cell.

Parameters

ParameterType
cellBoardCell

Returns

ReelSymbol