Skip to content

Commit c49f4ab

Browse files
committed
fix bounds drawing with latest version of melonJS
1 parent 45df604 commit c49f4ab

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/debugPanel.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ class DebugPanel extends Renderable {
198198

199199
if (typeof this.ancestor !== "undefined") {
200200
renderer.save();
201-
// if this object of this renderable parent is not the root container
202-
if (!this.root && !this.ancestor.root && this.ancestor.isFloating) {
201+
if (!this.floating) {
203202
var absolutePosition = this.ancestor.getAbsolutePosition();
204203
renderer.translate(
205204
-absolutePosition.x,
@@ -208,8 +207,10 @@ class DebugPanel extends Renderable {
208207
}
209208
}
210209

210+
var bounds = this.getBounds();
211+
211212
renderer.setColor("green");
212-
renderer.stroke(this.getBounds());
213+
renderer.stroke(bounds);
213214

214215
// the sprite mask if defined
215216
if (typeof this.mask !== "undefined") {
@@ -218,7 +219,6 @@ class DebugPanel extends Renderable {
218219
}
219220

220221
if (typeof this.body !== "undefined") {
221-
var bounds = this.getBounds();
222222
renderer.translate(bounds.x, bounds.y);
223223

224224
renderer.setColor("orange");
@@ -310,7 +310,7 @@ class DebugPanel extends Renderable {
310310

311311
if (typeof this.ancestor !== "undefined") {
312312
// if this object of this renderable parent is not the root container
313-
if (!this.root && !this.ancestor.root && this.ancestor.isFloating) {
313+
if (!this.floating) {
314314
var absolutePosition = this.ancestor.getAbsolutePosition();
315315
renderer.translate(
316316
-absolutePosition.x,
@@ -320,8 +320,14 @@ class DebugPanel extends Renderable {
320320
}
321321

322322
if (this.renderable instanceof Renderable) {
323+
var rbounds = this.renderable.getBounds();
324+
var rx = -rbounds.x - this.anchorPoint.x * rbounds.width,
325+
ry = -rbounds.y - this.anchorPoint.y * rbounds.height;
326+
323327
renderer.setColor("green");
324-
renderer.stroke(this.renderable.getBounds());
328+
renderer.translate(rx, ry);
329+
renderer.stroke(rbounds);
330+
renderer.translate(-rx, -ry);
325331
}
326332

327333
renderer.translate(

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class DebugPanelPlugin extends plugin.Base {
3333
super();
3434

3535
// minimum melonJS version expected
36-
this.version = "14.5.0";
36+
this.version = "15.1.5";
3737

3838
this.panel = new DebugPanel(debugToggle);
3939

0 commit comments

Comments
 (0)