Physics material

In this lesson, we learn about the different properties and shapes of our physics objects.

Custom shapes
By default, P2 physics will create a rectangle the size of your graphic. You can instead create a circle by running:

This will set the object's shape to a circle, with a radius of 45 pixels.

If you want more complicated shapes, you can load in a json file, as shown in the example here:

http://phaser.io/examples/v2/p2-physics/body-debug

Debug Draw
If you start using different kinds of shapes, it's helpful to be able to see the raw physic shape to debug. To do this, set the second argument of the enable function to true, like so:

Custom Material
Custom material allows us to edit the properties of contact, such as how bouncy objects are, or how much friction they have, etc.. The process goes as follows: Now this contact material is where we will set all of our settings. First, let's create a material for our blocks, and one for the world bounds:
 * 1) Create your materials.
 * 2) Create a contact material between 2 materials
 * 3) Set your materials to your objects

We name them "block" and "world" respectively. We then set our contact material:

At this point, we just set the restitution, which controls how much things bounce.

Finally, we set the material. To set it on our world bounds, we do:

And on our blocks:

And that's it! Your blocks should now be super bouncy.

This example shows you a full list of the properties you can set:

http://phaser.io/examples/v2/p2-physics/contact-material

Challenges

 * You might have noticed blocks are only really bouncy when they hit the ground. What if you wanted the settings to apply when the blocks hit each other instead?