miaoda-game-match3-phaser
v0.3.2
Published
Phaser 4 controller and pointer input for miaoda-game-match3-core.
Readme
miaoda-game-match3-phaser
Use this Phaser 4 adapter for match-3 board actions and pointer selection. Resolution returns plain clear/fall/spawn data for Phaser Tweens; your Scene owns sprites and animations.
Install
pnpm add miaoda-game-match3-phaser miaoda-game-match3-corePhaser >=4 <5 is required.
Minimal controller
const board = new Match3Board({
width: 8,
height: 8,
symbolCount: 6,
requireLegalSwap: true,
});
const input = new Match3Input(
scene.input,
{ cols: 8, rows: 8, cell: 64 },
{ x: 400, y: 240 },
).onSwap(({ a, b }) => {
if (!board.trySwap(a, b)) return;
for (let step = board.resolveOnce(); step; step = board.resolveOnce()) {
animate(step.cleared, step.collapse);
}
});Keep pointer input disabled while swap/cascade animations are active. trySwap has already reverted invalid no-match swaps in the model; animate the reverse motion when needed so sprites follow the data. Use tapClear for connected-blob gameplay.
An injected RNG must return a finite value in [0, 1).
Call Match3Input.destroy() during Scene shutdown. Destruction is idempotent and terminal: captured pointer callbacks and later listener setters cannot revive input delivery.
After a cascade, call hasLegalSwap() to detect a dead board or
findLegalSwaps() to drive a hint system. These queries never mutate the board
and require all current matches to be resolved first. Reshuffling remains a
game rule because its animation, RNG policy, and symbol-preservation policy vary.
Public API
Match3Board, Match3Input, core match-3 types, and the layout/pointer helpers are exported. The adapter does not render tiles, resolve scoring, or run a cascade timer.
