Skip to content

Commit 13ff898

Browse files
committed
Merged @georgiee p2 BodyDebug and reformatted for jshint pass. Looks awesome :) phaserjs#536
1 parent 751af10 commit 13ff898

6 files changed

Lines changed: 431 additions & 238 deletions

File tree

Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ module.exports = function (grunt) {
203203
'src/physics/p2/PointProxy.js',
204204
'src/physics/p2/InversePointProxy.js',
205205
'src/physics/p2/Body.js',
206+
'src/physics/p2/BodyDebug.js',
206207
'src/physics/p2/Spring.js',
207208
'src/physics/p2/Material.js',
208209
'src/physics/p2/ContactMaterial.js',

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ New features:
147147
* Group.reverse() reverses the display order of all children in the Group.
148148
* 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 :)
149149
* ScaleManager.fullScreenTarget allows you to change the DOM element that the fullscreen API is called on (feature request #526)
150+
* Merged Georges p2 BodyDebug and reformatted for jshint pass. Looks awesome :)
150151

151152

152153
Updates:

build/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
<script src="$path/src/physics/p2/PointProxy.js"></script>
152152
<script src="$path/src/physics/p2/InversePointProxy.js"></script>
153153
<script src="$path/src/physics/p2/Body.js"></script>
154+
<script src="$path/src/physics/p2/BodyDebug.js"></script>
154155
<script src="$path/src/physics/p2/Spring.js"></script>
155156
<script src="$path/src/physics/p2/Material.js"></script>
156157
<script src="$path/src/physics/p2/ContactMaterial.js"></script>

examples/wip/loadPolygon.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ var start = false;
1919

2020
function create() {
2121

22+
// Enable p2 physics
23+
game.physics.startSystem(Phaser.Physics.P2);
24+
2225
contra = game.add.sprite(400, 300, 'contra2');
23-
contra.physicsEnabled = true;
26+
game.physics.enable(contra, Phaser.Physics.P2, true);
2427
contra.body.clearShapes();
2528
contra.body.loadPolygon('physicsData', 'contra2');
2629

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

4043
function render() {
4144

42-
game.debug.physicsBody(contra.body, '#00ffff');
45+
// game.debug.physicsBody(contra.body, '#00ffff');
4346

4447
}

src/physics/p2/Body.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -998,10 +998,18 @@ Phaser.Physics.P2.Body.prototype = {
998998

999999
},
10001000

1001-
shapeChanged: function(){
1002-
console.log('shapeChanged', this.debugBody)
1003-
//shape has changed, so try to redraw if debug is available
1004-
if(this.debugBody) this.debugBody.draw()
1001+
/**
1002+
* Updates the debug draw if any body shapes change.
1003+
*
1004+
* @method Phaser.Physics.P2.Body#shapeChanged
1005+
*/
1006+
shapeChanged: function() {
1007+
1008+
if (this.debugBody)
1009+
{
1010+
this.debugBody.draw();
1011+
}
1012+
10051013
},
10061014

10071015
/**

0 commit comments

Comments
 (0)