TomLGD Posted December 11, 2015 Share Posted December 11, 2015 Hi there, I'am working on a small tile based game.I use the tool "Tiled" for creating my tilemap and import it with phaser. The map ist build of a 8x8 pixel grid in size.BUT my tiles are actually 16x16 pixels in size. I do this to habe some kind of "half position" for chests or wooden boxes and so on. If I load it in Phaser it looks all right but the collision ist wrong.Cause the grit is 8x8 pixels, the bounding boxes of the tiles are 8x8 pixels too... How can I tell Phaser that it should use a bounding box with the double of width and height? And I don't want to slize my 16x16 tiles in 4 8x8 tiles caue that would cause in four times higher collsion checkts^^ thanks in advance Tom Link to comment Share on other sites More sharing options...
Skeptron Posted December 11, 2015 Share Posted December 11, 2015 I'm not 100% percent sure but I think Phaser does some optimisation regarding layers, that is, it builds up the collision rectangles regarding the collision tiles. So if 4 tiles are next to each other, Phaser might create a single rectangle collision hitbox for all 4. I'm not sure it's actually how it works but when you debug a layer that's what's displayed. Maybe it's just for the display ^^ Anyway I would go with splitting your rocks into 4 sub-tiles, it's the easiest and cleanest solution. Impact on performance won't probably even be noticeable. Or you could have 16x16 tiles and have the chests and other 8x8 things be sprites in the scene (not be a part of the map). Link to comment Share on other sites More sharing options...
Kobaltic Posted December 11, 2015 Share Posted December 11, 2015 Phaser does combine collisions into the smallest number of collisions possible. You can use object.body.setSize(width, height, x, y) to change the collision http://phaser.io/docs/2.4.4/Phaser.Physics.Arcade.Body.html#setSize Link to comment Share on other sites More sharing options...
TomLGD Posted December 12, 2015 Author Share Posted December 12, 2015 Thanks, so now I'am doing this with a ties of 8x8 instead of 16x16.Its a bit more demanding to work with in Tiled but looks like the best solution^^ Link to comment Share on other sites More sharing options...
Skeptron Posted December 15, 2015 Share Posted December 15, 2015 Remember that you can copy and paste selections in Tiled. So you can create a rock with the 4 tiles, then copy the whole rock, and paste it elsewhere. No need to use the 4 tiles everywhere : just paste the result of their aggregation. TomLGD 1 Link to comment Share on other sites More sharing options...
TomLGD Posted December 15, 2015 Author Share Posted December 15, 2015 Phaser does combine collisions into the smallest number of collisions possible. You can use object.body.setSize(width, height, x, y) to change the collision http://phaser.io/docs/2.4.4/Phaser.Physics.Arcade.Body.html#setSize But I cannot looking for all tile of the same ID and then change the collision body of that tile. cause the tile object don't have such a property Link to comment Share on other sites More sharing options...
Recommended Posts