Introducing Phaser + Box2D

A couple of months ago – three to tell the truth – Photon Storm guys released a Box2D plugin for Phaser.

It’s time to publish some tutorials about it, and we start with the most basic tutorial, that is a “click to create, click to remove” script.

This is what I mean:

Click anywhere, you will create a crate if you click on an empty spot, or destroy a crate if you click on it.

The code is very easy to understand, as unlike the original Box2D and its AS3 porting, where it’s up to you to add sprites and synchronize them with physics world bodies, Phaser works in the opposite way: you add the sprites and assign a body to them.

Way more intuitive, and you won’t need the debug draw tool that much.

Here is the code:

This plugin is really awesome, so expect more tutorials and some games during next weeks. Mwanwhile, you can download the source code.

  • Do you think is viable to use phaser+box2d in mobile?

    I ran two examples in mobile, Phonegap and CocoonJS, but both examples were very slow.

    • Sabha

      Did you find a way to resolve this , just curious to know (Beginner Phaser developer).

  • Tamas

    Hy! How can i replace the box (crate object and crate.png) change a circle / ball (not only the png)?