Skip to content

Commit

Permalink
Merged @georgiee p2 BodyDebug and reformatted for jshint pass. Looks …
Browse files Browse the repository at this point in the history
…awesome :) phaserjs#536
  • Loading branch information
photonstorm committed Mar 10, 2014
1 parent 751af10 commit 13ff898
Show file tree
Hide file tree
Showing 6 changed files with 431 additions and 238 deletions.
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ module.exports = function (grunt) {
'src/physics/p2/PointProxy.js',
'src/physics/p2/InversePointProxy.js',
'src/physics/p2/Body.js',
'src/physics/p2/BodyDebug.js',
'src/physics/p2/Spring.js',
'src/physics/p2/Material.js',
'src/physics/p2/ContactMaterial.js',
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ New features:
* Group.reverse() reverses the display order of all children in the Group.
* Tweens are now bound to their own TweenManager, not always the global game one. So you can create your own managers now (for you clark :)
* ScaleManager.fullScreenTarget allows you to change the DOM element that the fullscreen API is called on (feature request #526)
* Merged Georges p2 BodyDebug and reformatted for jshint pass. Looks awesome :)


Updates:
Expand Down
1 change: 1 addition & 0 deletions build/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
<script src="$path/src/physics/p2/PointProxy.js"></script>
<script src="$path/src/physics/p2/InversePointProxy.js"></script>
<script src="$path/src/physics/p2/Body.js"></script>
<script src="$path/src/physics/p2/BodyDebug.js"></script>
<script src="$path/src/physics/p2/Spring.js"></script>
<script src="$path/src/physics/p2/Material.js"></script>
<script src="$path/src/physics/p2/ContactMaterial.js"></script>
Expand Down
7 changes: 5 additions & 2 deletions examples/wip/loadPolygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ var start = false;

function create() {

// Enable p2 physics
game.physics.startSystem(Phaser.Physics.P2);

contra = game.add.sprite(400, 300, 'contra2');
contra.physicsEnabled = true;
game.physics.enable(contra, Phaser.Physics.P2, true);
contra.body.clearShapes();
contra.body.loadPolygon('physicsData', 'contra2');

Expand All @@ -39,6 +42,6 @@ function update() {

function render() {

game.debug.physicsBody(contra.body, '#00ffff');
// game.debug.physicsBody(contra.body, '#00ffff');

}
16 changes: 12 additions & 4 deletions src/physics/p2/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,10 +998,18 @@ Phaser.Physics.P2.Body.prototype = {

},

shapeChanged: function(){
console.log('shapeChanged', this.debugBody)
//shape has changed, so try to redraw if debug is available
if(this.debugBody) this.debugBody.draw()
/**
* Updates the debug draw if any body shapes change.
*
* @method Phaser.Physics.P2.Body#shapeChanged
*/
shapeChanged: function() {

if (this.debugBody)
{
this.debugBody.draw();
}

},

/**
Expand Down
Loading

0 comments on commit 13ff898

Please sign in to comment.