mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 04:33:31 +00:00
Debug drawing now happens after collision solver.
This commit is contained in:
parent
48db06febd
commit
fd45182bde
2 changed files with 44 additions and 28 deletions
|
@ -89,7 +89,7 @@ var Body = new Class({
|
|||
this.collides = COLLIDES.NEVER;
|
||||
},
|
||||
|
||||
update: function (delta, drawDebug)
|
||||
update: function (delta)
|
||||
{
|
||||
var pos = this.pos;
|
||||
|
||||
|
@ -119,32 +119,37 @@ var Body = new Class({
|
|||
go.y = (pos.y - this.offset.y) + go.displayOriginY * go.scaleY;
|
||||
}
|
||||
|
||||
if (drawDebug)
|
||||
{
|
||||
var graphic = this.world.debugGraphic;
|
||||
|
||||
if (this.debugShowBody)
|
||||
{
|
||||
graphic.lineStyle(1, this.debugBodyColor, 1);
|
||||
graphic.strokeRect(pos.x, pos.y, this.size.x, this.size.y);
|
||||
}
|
||||
|
||||
if (this.debugShowVelocity)
|
||||
{
|
||||
var x = pos.x + this.size.x / 2;
|
||||
var y = pos.y + this.size.y / 2;
|
||||
|
||||
graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1);
|
||||
graphic.lineBetween(x, y, x + this.vel.x, y + this.vel.y);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.updateCallback)
|
||||
{
|
||||
this.updateCallback(this);
|
||||
}
|
||||
},
|
||||
|
||||
drawDebug: function (graphic)
|
||||
{
|
||||
var pos = this.pos;
|
||||
|
||||
if (this.debugShowBody)
|
||||
{
|
||||
graphic.lineStyle(1, this.debugBodyColor, 1);
|
||||
graphic.strokeRect(pos.x, pos.y, this.size.x, this.size.y);
|
||||
}
|
||||
|
||||
if (this.debugShowVelocity)
|
||||
{
|
||||
var x = pos.x + this.size.x / 2;
|
||||
var y = pos.y + this.size.y / 2;
|
||||
|
||||
graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1);
|
||||
graphic.lineBetween(x, y, x + this.vel.x, y + this.vel.y);
|
||||
}
|
||||
},
|
||||
|
||||
willDrawDebug: function ()
|
||||
{
|
||||
return (this.debugShowBody || this.debugShowVelocity);
|
||||
},
|
||||
|
||||
skipHash: function ()
|
||||
{
|
||||
return (!this.enabled || (this.type === 0 && this.checkAgainst === 0 && this.collides === 0));
|
||||
|
|
|
@ -226,12 +226,6 @@ var World = new Class({
|
|||
var len = bodies.length;
|
||||
var hash = {};
|
||||
var size = this.cellSize;
|
||||
var debug = this.drawDebug;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
this.debugGraphic.clear();
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
|
@ -239,7 +233,7 @@ var World = new Class({
|
|||
|
||||
if (body.enabled)
|
||||
{
|
||||
body.update(this.delta, debug);
|
||||
body.update(this.delta);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,6 +248,23 @@ var World = new Class({
|
|||
this.checkHash(body, hash, size);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.drawDebug)
|
||||
{
|
||||
var graphics = this.debugGraphic;
|
||||
|
||||
graphics.clear();
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
body = bodies[i];
|
||||
|
||||
if (body.willDrawDebug())
|
||||
{
|
||||
body.drawDebug(graphics);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Check the body against the spatial hash
|
||||
|
|
Loading…
Reference in a new issue