A new plugin to help with grid / tile based movement and physics, with loads of cool features.

Article by Richard Davey. Posted on 16th Feb 2017.   @photonstorm


nkholski has released his Grid Physics Plugin for Phaser. This adds support for grid / tile based movement and physics. It's still in early stages, but the feature list is impressive and the source is on GitHub:

Current features

  • Any grid size (not necessarily squares, i.e. 8x16 is possible, and not restricted to sprite or tile sizes).
  • Turn-based or real-time.
  • Visual debugging
  • Tile dimensions may differ from grid dimensions (but needs to be multiple of the grid dimensions, like 16x16 tiles on an 8x8 grid).
  • Collision detection against tile layers
  • Tile collisions on specified directions only
  • Body size is not restricted to grid-size, and different body sizes may co-exist (but must be equal or a multiple of grid dimensions. The sprite graphics may differ from body size.)
  • Path finding (easystar.js dependency)
  • Moveable objects (can be chained, i.e. the player push one crate against another crate that will also move).
  • Mass (and strength that limit total mass that can be pushed by the power of one sprite)
  • Velocity, ("struggle" property that can slow down a body based on mass pushed)
  • Populated properties like isMoving.x (boolean) or isBlocked.top (boolean).

Read More