mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 14:08:28 +00:00
Now renders the body velocity to the debug graphic
This commit is contained in:
parent
2b7c12cd75
commit
43d470ede7
3 changed files with 51 additions and 20 deletions
|
@ -55,8 +55,9 @@ var Body = new Class({
|
|||
this.checkAgainst = TYPE.NONE;
|
||||
this.collides = COLLIDES.NEVER;
|
||||
|
||||
this.debugShow = true;
|
||||
this.debugColor = 0x00ff00;
|
||||
this.debugShowBody = true;
|
||||
this.debugShowVelocity = true;
|
||||
this.debugBodyColor = world.debugColors.body;
|
||||
|
||||
// min 44 deg, max 136 deg
|
||||
this.slopeStanding = { min: 0.767944870877505, max: 2.3736477827122884 };
|
||||
|
@ -115,10 +116,24 @@ var Body = new Class({
|
|||
go.setPosition((pos.x - this.offset.x) + go.displayOriginX, (pos.y - this.offset.y) + go.displayOriginY);
|
||||
}
|
||||
|
||||
if (drawDebug && this.debugShow)
|
||||
if (drawDebug)
|
||||
{
|
||||
this.world.debugGraphic.lineStyle(1, this.debugColor, 1);
|
||||
this.world.debugGraphic.strokeRect(pos.x, pos.y, this.size.x, this.size.y);
|
||||
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.debugColors.velocity, 1);
|
||||
graphic.lineBetween(x, y, x + this.vel.x, y + this.vel.y);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -44,6 +44,11 @@ var World = new Class({
|
|||
|
||||
this.debugGraphic;
|
||||
|
||||
this.debugColors = {
|
||||
body: 0xff00ff,
|
||||
velocity: 0x00ff00
|
||||
};
|
||||
|
||||
this._lastId = 0;
|
||||
|
||||
if (showDebug)
|
||||
|
|
|
@ -1,48 +1,59 @@
|
|||
var Debug = {
|
||||
|
||||
setDebug: function (value, color)
|
||||
setDebug: function (showBody, showVelocity, bodyColor)
|
||||
{
|
||||
this.body.debugShow = value;
|
||||
|
||||
if (value && color !== undefined)
|
||||
{
|
||||
this.body.debugColor = color;
|
||||
}
|
||||
this.debugShowBody = showBody;
|
||||
this.debugShowVelocity = showVelocity;
|
||||
this.debugBodyColor = bodyColor;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
setDebugColor: function (value)
|
||||
setDebugBodyColor: function (value)
|
||||
{
|
||||
this.body.debugColor = value;
|
||||
this.body.debugBodyColor = value;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
debugShow: {
|
||||
debugShowBody: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.body.debugShow;
|
||||
return this.body.debugShowBody;
|
||||
},
|
||||
|
||||
set: function (value)
|
||||
{
|
||||
this.body.debugShow = value;
|
||||
this.body.debugShowBody = value;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
debugColor: {
|
||||
debugShowVelocity: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.body.debugColor;
|
||||
return this.body.debugShowVelocity;
|
||||
},
|
||||
|
||||
set: function (value)
|
||||
{
|
||||
this.body.debugColor = value;
|
||||
this.body.debugShowVelocity = value;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
debugBodyColor: {
|
||||
|
||||
get: function ()
|
||||
{
|
||||
return this.body.debugBodyColor;
|
||||
},
|
||||
|
||||
set: function (value)
|
||||
{
|
||||
this.body.debugBodyColor = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue