Jump to content

Multiple Tilemaps


Recommended Posts

I've been having this same problem! I've maxed out tilemaps around 4000x1000, but I need to work with a much larger world, and splitting it into many, smaller tilemaps seems to be the way to go, but I don't know how to do this - if something needs to be patched/tweaked for this to work, I'd love to contribute back to phaser. Thanks!

Link to comment
Share on other sites

This is harder to achieve than it sounds, so I'm open to suggestions on how to do it. Say you've got 4 tilemaps each 5000px wide. The way the camera and moving around the tilemap works now is that they are mapped to world coordinates, so when you're at x: 4500 in the world, you're at 4500px in the tilemap too. To support chaining one map onto another I would need to add a 'world offset' to the map, so that instead of being 0 to 5000, map 2 would start at 5000 and go to 10,000.


Otherwise any sprites that you spawn say based on map coordinates would be in the wrong place.


I'm not sure if this is a great solution though.


The need for an infinite terrain means needing the ability to modify the contents of the map data directly (which you've already got), but in such a way that the camera never thinks it has reached the end of the map / world. I'm open to suggestions on how best to achieve this.

Link to comment
Share on other sites

Is it possible to load in 2 tilemaps? The idea I have is to load the main one and then the next one with an x offset but I haven't been able to get it to work (nothing happens or the second one isn't visible).


I tried:

layer = game.add.tilemapLayer(0, 0, winW, winH, tileset, map, 0);layer2 = game.add.tilemapLayer(80, 0, winW, winH, tileset, map, 0);

Because the test map is 80 blocks wide, but the second layer doesn't show up.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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