Creating a body

In this lesson, we learn to create a physics object.

We're using the P2 Physics library

Starting the physics system
Before you do anything, you need to enable the P2 Physics system:

By default, the gravity is 0, so everything will just float. To set the gravity, do:

Adding an object
Now that our physics system is ready, we can create a physics object by doing:

Block can be any sprite we created with our usual game.add.sprite method. And that's it! You should see your object falling to the ground now.

By default, objects will collide with the world's bounds. You can disable this per object by doing:

block.body.collideWorldBounds = false;

Challenges

 * Can you make a physics object spawn with a mouse click?