Jump to content

game.debug.body issues.


jdeagle
 Share

Recommended Posts

I'm using game.debug.body in my update() to debug the bounding box for sprites in my game. It draws the bounding box but doesn't clear the previous drawn box so I am left with a trail of boxes across the screen. This seems to effect all sprites.

game.debug.body(this.masterSprite, 'rgba(255, 255, 0, 0.1)');

I looked into the source and apparently there is a preUpdate function that is supposed to get called but it seems to only get called when game.debug.dirty === false yet only clears the canvas if dirty === true.

preUpdate: function () {        if (this.dirty && this.sprite)        {            this.context.clearRect(0, 0, this.game.width, this.game.height);            this.dirty = false;        }    }, 

Is this a known issue? Is there something I need to do to force clearing the canvas for the debug?

 

 

Update:

 

Looks like manually clearing the canvas does the trick. I did the following:

game.debug.context.clearRect(0, 0, this.game.width, this.game.height);game.debug.body(this.masterSprite, 'rgba(0, 255, 255, 0.5)');

Having to do this manually works but phaser should do this by default. What good is it to NOT clear the previous debug graphics?

Link to comment
Share on other sites

Debug calls need to be in the render function, not update, so they can be drawn over the top of all the scene items and cleared correctly.

 

Seems I'm wrong (you can use debug calls anywhere, though they should really be in render) and this may be a bug in certain situations on 2.0.7.

 

Seems I was wrong about being wrong!

Edited by lewster32
Link to comment
Share on other sites

They only work outside of it in WebGL mode. In Canvas mode it won't work at all.

 

And it should still never be done because it nearly always renders incorrect information, because the update loop hasn't finished at the time it's called so there is still every chance for the debug data to have changed between the point of calling it and the point of rendering.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...