BoardGrid
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
| Parameter | Type |
|---|---|
opts | BoardGridOptions |
Returns
BoardGrid
Properties
Accessors
isDestroyed
Get Signature
get isDestroyed(): boolean;
Defined in: board/BoardGrid.ts:252
Returns
boolean
Implementation of
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
| Parameter | Type |
|---|---|
cell | BoardCell |
Returns
{
height: number;
width: number;
x: number;
y: number;
}
| Name | Type | Defined in |
|---|---|---|
height | number | board/BoardGrid.ts:171 |
width | number | board/BoardGrid.ts:171 |
x | number | board/BoardGrid.ts:171 |
y | number | board/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
| Parameter | Type |
|---|---|
cell | BoardCell |
Returns
{
x: number;
y: number;
}
| Name | Type | Defined in |
|---|---|---|
x | number | board/BoardGrid.ts:177 |
y | number | board/BoardGrid.ts:177 |
cells()
cells(): BoardCell[];
Defined in: board/BoardGrid.ts:166
Every cell coordinate, row-major.
Returns
destroy()
destroy(): void;
Defined in: board/BoardGrid.ts:256
Returns
void
Implementation of
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
| Parameter | Type |
|---|---|
cell | BoardCell |
id | string |
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
| Parameter | Type |
|---|---|
cell | BoardCell |
Returns
setProfile()
setProfile(cell: BoardCell, name: string): void;
Defined in: board/BoardGrid.ts:193
Select a registered speed profile by name for one cell.
Parameters
| Parameter | Type |
|---|---|
cell | BoardCell |
name | string |
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
| Parameter | Type |
|---|---|
targets | BoardSpinTarget[] |
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
| Parameter | Type |
|---|---|
cell | BoardCell |