Jump to content

debug body behaves differently when upgrading from 2.1.3 to 2.2.2.


kctang
 Share

Recommended Posts

With a tiled map, doing something like this to enable body debug ("maps" is a json export from Tiled editor):

            var tilesBody = game.physics.p2.convertTilemap(maps, 'level-1');            tilesBody.forEach(function (body) {                body.debug = xDebug;            });

It works in both Phaser 2.1.3 and 2.2.2 (without console errors). However:

 

- in 2.1.3 it renders the debug overlay boxes on the tile location within the map. this is what i expected (top part of the attached image).

- in 2.2.2 it seems to render from the top left corner of the game. this is NOT what i expected (bottom part of the attached image).

 

Is this a bug in 2.2.2 or I messed up somewhere? How do I get it to work with like in 2.1.3?

post-10997-0-10332000-1421455720.png

Link to comment
Share on other sites

After some tinkering with the code, I found that to debug tilemap, I should debug the TilemapLayer from createLayer() instead of the bodies returned by convertTilemap().

var layer = maps.createLayer('layer-1');// this will render collision debug info for the layer// i did not do this in 2.1.2layer.debug = true;var layerCg = game.physics.p2.createCollisionGroup();var layerBodies = game.physics.p2.convertTilemap(maps, 'layer-1');layerBodies.forEach(function (body) {    body.setCollisionGroup(layerCg);    // this seems to cause the collision debug info rendered at top left of game screen    // does not seem useful in 2.2.2 but for 2.1.2, it renders where a tile is rendered    // instead of top left of game screen    // setting this to false seems to be the solution.    body.debug = true;}, this);
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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