Jump to content

"overlap" on p2 tilemap


jmp909
 Share

Recommended Posts

I have a tilemap and i want the tiles on one layer to be collectible. converting it all to sprites causes too much slowdown

 

I manage to get p2 collisions but the problem with the (unoptimized) tilemap conversion is there's no link between the physics body and the tile it represents

var collectibles = this.game.physics.p2.convertTilemap(map, this.layer1,true,false)

just returns p2 bodies and no relevant tile data

 

Is there a way to get the tile related to a p2 body? 

 

i ended up cheating and doing this. but it's not perfect....

overlap=8this.map.removeTileWorldXY(this.player.position.x, this.player.position.y,32,32,this.layer1)this.map.removeTileWorldXY(this.player.position.x-overlap, this.player.position.y-overlap,32,32,this.layer1)this.map.removeTileWorldXY(this.player.position.x+overlap, this.player.position.y-overlap,32,32,this.layer1)this.map.removeTileWorldXY(this.player.position.x-overlap, this.player.position.y+overlap,32,32,this.layer1)this.map.removeTileWorldXY(this.player.position.x+overlap, this.player.position.y+overlap,32,32,this.layer1)

thanks for any suggestions

J

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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