Skip to content

Commit 358e0a6

Browse files
committed
Merge pull request phaserjs#1674 from englercj/dev
Fix debug drawing for p2 physics bodies
2 parents 0868ff6 + 0b3850c commit 358e0a6

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

src/physics/p2/BodyDebug.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Phaser.Physics.P2.BodyDebug = function(game, body, settings) {
5656

5757
this.draw();
5858

59+
this.updateSpriteTransform();
60+
5961
};
6062

6163
Phaser.Physics.P2.BodyDebug.prototype = Object.create(Phaser.Group.prototype);
@@ -109,6 +111,18 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
109111
{
110112
this.drawCircle(sprite, offset[0] * this.ppu, offset[1] * this.ppu, angle, child.radius * this.ppu, color, lw);
111113
}
114+
else if (child instanceof p2.Plane)
115+
{
116+
this.drawPlane(sprite, offset[0] * this.ppu, -offset[1] * this.ppu, color, lineColor, lw * 5, lw * 10, lw * 10, this.ppu * 100, angle);
117+
}
118+
else if (child instanceof p2.Line)
119+
{
120+
this.drawLine(sprite, child.length * this.ppu, lineColor, lw);
121+
}
122+
else if (child instanceof p2.Rectangle)
123+
{
124+
this.drawRectangle(sprite, offset[0] * this.ppu, offset[1] * this.ppu, angle, child.width * this.ppu, child.height * this.ppu, lineColor, color, lw);
125+
}
112126
else if (child instanceof p2.Convex)
113127
{
114128
verts = [];
@@ -123,18 +137,6 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
123137

124138
this.drawConvex(sprite, verts, child.triangles, lineColor, color, lw, this.settings.debugPolygons, [offset[0] * this.ppu, -offset[1] * this.ppu]);
125139
}
126-
else if (child instanceof p2.Plane)
127-
{
128-
this.drawPlane(sprite, offset[0] * this.ppu, -offset[1] * this.ppu, color, lineColor, lw * 5, lw * 10, lw * 10, this.ppu * 100, angle);
129-
}
130-
else if (child instanceof p2.Line)
131-
{
132-
this.drawLine(sprite, child.length * this.ppu, lineColor, lw);
133-
}
134-
else if (child instanceof p2.Rectangle)
135-
{
136-
this.drawRectangle(sprite, offset[0] * this.ppu, -offset[1] * this.ppu, angle, child.width * this.ppu, child.height * this.ppu, lineColor, color, lw);
137-
}
138140

139141
i++;
140142
}
@@ -155,7 +157,6 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
155157
g.lineStyle(lineWidth, color, 1);
156158
g.beginFill(fillColor);
157159
g.drawRect(x - w / 2, y - h / 2, w, h);
158-
159160
},
160161

161162
/**

0 commit comments

Comments
 (0)