miaoda-game-pinball-phaser
v0.3.0
Published
Phaser lifecycle and physics-object bridge for miaoda-game-pinball-core.
Maintainers
Readme
miaoda-game-pinball-phaser
Use this Phaser 4 adapter to combine pinball session, score, objectives, modes, rules, and flow tracking while your Scene/Arcade/Matter objects own physics and effects.
Install
pnpm add miaoda-game-pinball-phaser miaoda-game-pinball-corePhaser >=4 <5 is required.
Minimal table controller
const table = scene.pinball.create({
context: gameState,
session: { ballsPerGame: 3, ballSaveDuration: 8 },
combo: { window: 1.5, step: 0.25 },
rules: [{ switchId: 'ramp', score: 500, event: 'ramp-hit' }],
resolveRegion: (id, ball) => regionFor(ball.x, ball.y),
});
table.registerBall('ball-1', ballObject);
table.handleSwitch({
switchId: 'ramp', ballId: 'ball-1', kind: 'hit',
speed: 500, impulse: 1, timestamp: elapsedSeconds,
});Register PinballPlugin as a Scene Plugin to use scene.pinball.create(), or construct new PinballTableController(scene.events, setup) directly. Phaser update milliseconds are converted to seconds for session, score, objectives, modes, and flow. Use autoUpdate: false and call update(deltaMs) from a fixed-step coordinator when needed.
Call unregisterBall when a ball leaves the scene and session.drain(id) through your drain sensor. setTicking(false) pauses time-based systems. Scene shutdown destroys plugin-owned controllers.
Public API
PinballTableController, PinballPlugin, PinballTableSetup, registerBall, unregisterBall, and handleSwitch are exported along with core types. The adapter does not create physics bodies, flippers, bumpers, or tile effects.
