Skip to content

Commit 4f3a524

Browse files
committed
Update World.js
1 parent b7343f3 commit 4f3a524

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

src/physics/matter-js/World.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,15 @@ var World = new Class({
12451245
var parts = body.parts;
12461246
var partsLength = parts.length;
12471247

1248+
if (!body.isStatic)
1249+
{
1250+
var w = body.bounds.max.x - body.bounds.min.x;
1251+
var h = body.bounds.max.y - body.bounds.min.y;
1252+
1253+
graphics.fillStyle(0x6d6d6d, 0.3);
1254+
graphics.fillRect(body.bounds.min.x, body.bounds.min.y, w, h);
1255+
}
1256+
12481257
for (var k = (partsLength > 1) ? 1 : 0; k < partsLength; k++)
12491258
{
12501259
var part = parts[k];
@@ -1319,17 +1328,19 @@ var World = new Class({
13191328

13201329
if (!body.isStatic)
13211330
{
1322-
var w = body.bounds.max.x - body.bounds.min.x;
1323-
var h = body.bounds.max.y - body.bounds.min.y;
1324-
1325-
graphics.fillStyle(0x00ffff, 0.5);
1326-
graphics.fillRect(body.bounds.min.x, body.bounds.min.y, w, h);
1327-
13281331
graphics.fillStyle(0xff0000, 1);
13291332
graphics.fillRect(body.position.x - 3, body.position.y - 3, 6, 6);
13301333

1334+
var bx = body.bounds.min.x + body.centerOfMass.x / 2;
1335+
var by = body.bounds.min.y + body.centerOfMass.y / 2;
1336+
13311337
graphics.fillStyle(0xffff00, 1);
1332-
graphics.fillRect(body.centerOfMass.x - 2, body.centerOfMass.y - 2, 4, 4);
1338+
1339+
// graphics.fillRect(body.centerOfMass.x - 2, body.centerOfMass.y - 2, 4, 4);
1340+
1341+
graphics.fillRect(bx, by, 4, 4);
1342+
1343+
// graphics.fillRect(body.origin.x, body.origin.y, 4, 4);
13331344
}
13341345

13351346
return this;

0 commit comments

Comments
 (0)