-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Labels
Description
Version
- Phaser Version: 3.55.2
- Operating system: macOS
- Browser:
Description
I'm having an issue with setting up collisions with a staggered isometric tilemap created in Tiled. I ran across this discussion outlining the same issue, and I can confirm it's still a problem in 3.55.2. Basically, convertTilemapLayer
does not set the collision bodies for tiles correctly on isometric maps, neither the default rectangle nor the shape specified in the collision layer.
As suggested in the thread, the issue comes from getBounds()
on the Tile
class. Specifically, this.getLeft()
always returns undefined
for any of the tiles.
getBounds: function (camera, output)
{
if (output === undefined) { output = new Rectangle(); }
output.x = this.getLeft();
output.y = this.getTop();
output.width = this.getRight() - output.x;
output.height = this.getBottom() - output.y;
return output;
}
Example Test Code
const map = this.make.tilemap({ key: 'map' })
const tileset = map.addTilesetImage('tileset', 'tiles')
const ground = map.createLayer('Floor', tileset)
// property "collides" is set on certain tiles within Tiled
ground.setCollisionByProperty({ collides: true })
this.matter.world.convertTilemapLayer(ground)
Additional Information
I'm happy to give solving this a shot myself if you could provide some guidance. 🙂
grrowl, mauricerenck, SirLink and KimMinJeong05