Jump to content

Tilemap (layer) offset


jd.joshuadavison
 Share

Recommended Posts

Hello,

I've built a tilemap using Tiled. The only thing is, I want to offset the tilemap (or preferably, individual tilemap layers) dynamically in the game (i.e. by a variable/calculated number of pixels).

Tiled does have a 'Horizontal Offset' property for the layer. Obviously that would be a fixed value, but I thought it would map to a property of the tilemap layer object which I would then be able to dynamically modify, but as far as I can tell Phaser doesn't do anything with the 'Horizontal Offset' property.

So I tried setting the tilemap layer's x position. This did offset the layer, but it doesn't just offset where the tilemap starts it offsets where the tilemap exists. By which I mean, that the tiles are culled as the move further left than it's x position, so my tiles disappear/appear at the left edge of the tilemap layer instead of the game viewport.

I'm a bit stuck... I'm fairly sure that the Horizontal Offset is what I want, but as I said, it doesn't seem to be used by Phaser. Am I missing something? Is there another way to do what I want?

Thanks,
Josh

Link to comment
Share on other sites

Okay so, Horizontal Offset is definitely what I want and is definitely not supported - I will raise a feature request on GitHub shortly. In the meantime I've had no luck with a work around.

It seems that in phaser 2, tilemap layers had a property called `cameraOffsetX`, which might have done the job, although, equally, that might have done exactly the same thing as phaser 3's `x` property. But I can't find anything like that in Phaser 3.

Any suggestions?

Link to comment
Share on other sites

  • 2 weeks later...

Hi Samme,

Thanks for taking the time to respond - and I'm sorry for my slow reply. I've been taking a break from my game for the last couple of weeks, but I'm back on it now.

Do you think the tiles being culled whilst they are still within the cameras viewport is a bug then?

Also, my layer is definitely not receiving the x and y values from from my JSON. But I can set them myself in the code with no problems. Is this also a bug?

Should I report them on GitHub?

I'm going to move onto working out a workaround now. I'm thinking that I can probably take this layer out of the tilemap altogether and dynamically place them as images at the correct coordinates. There are only 25 "tiles". Do you have any other suggestions for me to look into?

Josh

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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