Chipmunk Physics Plugin

This plugin brings rigid bodied physics into Kiwi thanks to Chipmunk2D.

Chipmunk2D is a 2D rigid body physics library originally made in C but thanks to Joseph and contributors a JavaScript port was made, which this plugin uses. You can find the ChipmunkJS repo here.

You can download our Chipmunk plugin on github.

Break-apart Kiwi: Example

  • Toggle the debug overlay with the button in the top left corner.
  • Click and drag a shape to move it.
  • Click on empty space in the center of the game to apply gravity.

Debugging

Working with physics can be tough. So included in the ChipmunkPhysics repo is a ChipmunkPhysicsDebug plugin, which can be optionally added to your games.

You can view an example of the debug plugin in the example above.

When the debug plugin is added to a game and enabled, the debug canvas (included in the core of Kiwi) will appear on top of your game. All shapes and constraints on the defaultSpace will be rendered to the debug canvas, along with arrows indicating any velocity applied to bodies.

Further Documentation

The Chipmunk website is best place to look when wanting to learn the core concepts of Chipmunk. Be aware that the code won’t be in JavaScript or resemble this plugin’s format, as the core library is developed in C. Their forum is also a very useful resource.

The README contains the essential information about working with the Plugin. Examples can be found in the examples folder and API docs are located in the docs folder.

Share the joy
Comments 2

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">