miaoda-game-path-phaser
v0.3.3
Published
Phaser 4 Game Object path follower for miaoda-game-path-core.
Readme
miaoda-game-path-phaser
Use this Phaser 4 adapter to bind a Game Object to a baked miaoda-game-path-core route. It converts Scene delta milliseconds to seconds, optionally rotates to the tangent, and cleans up on Scene shutdown.
Install and use
pnpm add miaoda-game-path-core miaoda-game-path-phaserRegister PathPlugin, then create a mover:
const mover = this.paths.create(enemy, bakedPath, {
speed: 260,
mode: 'clamp',
rotationOffset: -90,
sway: { amplitude: 18, frequency: 1.2 },
onArrive: () => beginCombat(enemy),
});Direct new PathMover(...) construction is available when your code owns lifecycle cleanup. Non-finite options or frame deltas are ignored without changing the object transform or firing arrival callbacks. destroy() and Scene shutdown are terminal: later ticking, speed, seek, or update calls are inert and cannot write the Game Object.
For strict fixed-step ownership, select manual time and advance the follower in seconds:
const mover = this.paths.create(enemy, bakedPath, {
speed: 260,
tickSource: 'manual',
onArrive: () => beginCombat(enemy),
});
fixedStepper.advance(frameDeltaSeconds, (dtSeconds) => {
const sample = mover.stepSimulation(dtSeconds);
});Each manual step advances core distance, writes the resulting transform, and fires onArrive at that same gameplay boundary. Host/manual conflicts, malformed seconds, and terminal destruction fail before follower or object state changes. Legacy { autoUpdate: false } plus update(deltaMs) remains supported; the old method still expects Phaser milliseconds.
The adapter owns Scene timing and Game Object transforms only. Path geometry, distance sampling, and follower state remain in core; collision and behavior handoff remain game-owned.
