npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

miaoda-game-kinematic2d-phaser

v0.3.3

Published

Phaser 4 Scene controller and plugin for miaoda-game-kinematic2d-core.

Downloads

1,216

Readme

miaoda-game-kinematic2d-phaser

Use this Phaser 4 controller to connect miaoda-game-kinematic2d-core to a Game Object. Core coordinates use +Y up; Phaser objects normally use +Y down, so configure the coordinate origin once and let the adapter convert positions.

Install

pnpm add miaoda-game-kinematic2d-phaser miaoda-game-kinematic2d-core

Phaser >=4 <5 is required.

Minimal controller

const coordinates = { yDown: true, origin: { x: 0, y: level.height } };
const controller = new KinematicController(
  scene.events, player, levelWorld,
  { shape: { halfWidth: 12, halfHeight: 20 }, snapDistance: 3 },
  coordinates,
).setVelocityProvider(() => ({ x: inputX * 220, y: verticalVelocity }));

Phaser update deltas are milliseconds. The controller converts them to seconds for core stepping and writes the converted position exactly once. Existing autoUpdate: false plus step(deltaMs, velocity) integrations remain supported.

For a new game-owned fixed-tick loop, prefer the explicit seconds boundary:

const controller = new KinematicController(
  scene.events,
  player,
  levelWorld,
  { shape: { halfWidth: 12, halfHeight: 20 } },
  { tickSource: 'manual', origin: { x: 0, y: level.height } },
);

fixedStepper.advance(frameSeconds, (dt) => {
  const result = controller.stepSimulation(dt, requestedVelocity);
  // Read result or controller.core.snapshot after this committed tick.
});

The default tickSource: 'host' preserves Scene-driven behavior. autoUpdate is a legacy alias; when both fields are supplied they must agree. Manual controllers do not register Scene update but retain shutdown cleanup. Calling stepSimulation in host mode fails before providers, collision, core state, or Game Object position can change. setTicking is a separate local pause.

Configure collision bounds and authored platforms in core coordinates, or use the exported coordinate helpers to convert Phaser rectangles. Camera bounds only affect scrolling and do not replace movement bounds. For screen-authored levels, PhaserKinematicWorld requires all four edge policies (solid, open, or exit) and reports fully escaped configured exit edges. Use placeAtPhaserCenter or placeFeetAtPhaser for validated atomic placement instead of hand-written origin and half-height arithmetic.

For a platformer that also uses platformer-core, prefer miaoda-game-platformer-kinematic-phaser; it owns the ordered two-core tick, contact feedback, world exits, and duplicate-physics diagnostics.

Do not also enable Arcade or Matter movement on the same object: the kinematic controller must remain the position authority. Construction detects an enabled object.body and throws DUPLICATE_PHYSICS_AUTHORITY before listener registration. allowEngineBody: true is an advanced escape hatch only for a body whose integration an external coordinator has disabled.

Public API

KinematicController, Kinematic2dPlugin, PhaserKinematicWorld, placement helpers, coordinate helpers, KinematicTickSource, KinematicAuthorityError, and core collision types are exported. The preset fixed-step path is tickSource: 'manual' plus stepSimulation(dtSeconds, velocity). Use update or legacy step(deltaMs, velocity) only for lower-level or compatibility integrations.