Skip to content

Commit 916e59c

Browse files
committed
Uses new debug colors and reset now re-inserts into the static tree.
1 parent ed72a55 commit 916e59c

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

v3/src/physics/arcade/StaticBody.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ var StaticBody = new Class({
1717

1818
this.gameObject = gameObject;
1919

20-
this.debugShowBody = world.defaults.debugShowBody;
21-
this.debugBodyColor = world.defaults.bodyDebugColor;
20+
this.debugShowBody = world.defaults.debugShowStaticBody;
21+
this.debugBodyColor = world.defaults.staticBodyDebugColor;
2222

2323
this.enable = true;
2424

@@ -88,12 +88,6 @@ var StaticBody = new Class({
8888

8989
this.blocked = { none: true, up: false, down: false, left: false, right: false };
9090

91-
// this.tilePadding = new Vector2();
92-
// this.dirty = false;
93-
// this.isMoving = false;
94-
// this.stopVelocityOnCollide = true;
95-
96-
// read-only
9791
this.physicsType = CONST.STATIC_BODY;
9892

9993
this._sx = gameObject.scaleX;
@@ -162,18 +156,25 @@ var StaticBody = new Class({
162156
return this;
163157
},
164158

165-
reset: function (x, y)
159+
updateCenter: function ()
166160
{
167-
this.world.staticTree.remove(this);
161+
this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight);
162+
},
168163

164+
reset: function (x, y)
165+
{
169166
var sprite = this.gameObject;
170167

168+
if (x === undefined) { x = sprite.x; }
169+
if (y === undefined) { y = sprite.y; }
170+
171+
this.world.staticTree.remove(this);
172+
171173
this.position.x = x - sprite.displayOriginX + (sprite.scaleX * this.offset.x);
172174
this.position.y = y - sprite.displayOriginY + (sprite.scaleY * this.offset.y);
173175

174176
this.rotation = this.gameObject.angle;
175177

176-
this.updateBounds();
177178
this.updateCenter();
178179

179180
this.world.staticTree.insert(this);
@@ -269,6 +270,9 @@ var StaticBody = new Class({
269270
set: function (value)
270271
{
271272
this.position.x = value;
273+
274+
this.world.staticTree.remove(this);
275+
this.world.staticTree.insert(this);
272276
}
273277

274278
},
@@ -283,6 +287,9 @@ var StaticBody = new Class({
283287
set: function (value)
284288
{
285289
this.position.y = value;
290+
291+
this.world.staticTree.remove(this);
292+
this.world.staticTree.insert(this);
286293
}
287294

288295
},

0 commit comments

Comments
 (0)