/**
* @author Chris Campbell
* @author Richard Davey
* @copyright 2015 Photon Storm Ltd.
* @license {@link http://choosealicense.com/licenses/no-license/|No License}
*
* @description This example requires the Phaser Box2D Plugin to run.
* For more details please see http://phaser.io/shop/plugins/box2d
*/var game =newPhaser.Game(800,600, Phaser.CANVAS,'phaser-example',{ preload: preload, create: create, render: render });functionpreload(){
game.load.image('block','assets/sprites/block.png');}functioncreate(){
game.stage.backgroundColor ='#124184';// Enable Box2D physics
game.physics.startSystem(Phaser.Physics.BOX2D);
game.physics.box2d.gravity.y =500;
game.physics.box2d.setBoundsToWorld();
game.physics.box2d.restitution =0.5;//Method 1: Create a rectangle body from an existing sprite automatically//Create a sprite and enable box2d physics. enabling Box2D physics on a sprite creates a matching rectangular Box2D body by defaultvar block = game.add.sprite(400, game.world.centerY,'block');
game.physics.box2d.enable(block);//Method 2: Create a rectangle body manually, this will create a body that isn't attached to any sprite.//Create a Box2D body. Manually set the shape of the body to be a rectanglevar rectangle =newPhaser.Physics.Box2D.Body(this.game,null,345, game.world.centerY -150,0.5);
rectangle.setRectangle(90,50,0,0,0);}functionrender(){
game.debug.box2dWorld();}