Jump to content

Box2d debug.body settings (ex centerOfMass)


sheik266
 Share

Recommended Posts

//in the render function
this.game.debug.body(mySprite);
this.physics.box2d.debugDraw.centerOfMass = true;

 

The above code only shows the mySprite's physics body, it does not draw the Center of Mass.

Note: I am able to render the center of mass with the below code, but it renders it for every physics object.

//in the render function
this.game.debug.box2dWorld();
this.physics.box2d.debugDraw.centerOfMass = true;

 

Link to comment
Share on other sites

I think this will not be possible. Phaser box2D plugin is intermediate layer between Phaser and box2D. As far as I remember box2D is only calling: "ok, now I will draw all joints one by one" and it is up to implementation to provide drawing method (which is what Phaser box2D plugin does in DefaultDebugDraw.js) - thanks to this user can provide drawing methods specific to platform they are running box2D on. There is no option to draw joints (or other properties) only on single object.

I believe, that Phaser debug features related to physics will draw properties common for all supported physics engines - like body, but not engine specific ones. Phaser approach allows you to do this on per object basis as you wrote in your original post.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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