Jump to content

Recommended Posts

Hi there!

 

I'm trying to create an indefinite 1-way sidescroller game with a randomly generated World.

 

For this conveniently to work I have prefactored blueprint-Tilemaps with the Tiled-Editor,

which I want to glue together whenever the player moves into an unloaded area.

 

I've already achieved to create a big level before it starts by appending layers (layers[0].data-array) together, but this is performance-heavy and does not work well on slow devices.

 

In this context I've decided start with a small pregenerated map, which gets changed while the player is running through the level from left to right.

I want to unload chunks of the map when the players leaves them and stick a new blueprint in front before the player reaches the right side, so you think the level is Indefinite.

 

Phase 1:

  • Create a tilemap from a few blueprints stitched together (works)

 

Phase 2:

  • Start the level: the player runs on the map from left right until the level end is near. (works)

 

Phase 3: 

  • Randomly pick a prefactored blueprint and stick it on the right side of the map and update the size of it (does not work for me dynamically)

 

Phase 4:

  • Unload/remove left part of the map, which the player has left (have not tried yet)

 

 

So my question for you:

How can I update a tilemap after changing its size so it gets rendered/loaded correctly?

Especially changing the world size/borders, as I cannot find a Phaser example for this use case.

 

 

What I have tried so far:

A )

Using the same method from Phase 1:

I'm combining Tilemap.layers[0].data from the different blueprints and update layers[0].width and layers[0].height)

 

B )

Adding Layers to the Tilemap.layers Array and offsetting layers[1].x by layers[0].width.

 

A and B do not render the updated tilemap, sadly, even when using .resizeWorld() after the change.

 

Thank you for reading this far and maybe leaving a helpful reply. =)

Link to comment
Share on other sites

  • 2 weeks later...

I've tried this for about 60 hours to work, it seems impossible without changing Phasers' code. 

 

Finally dropped the Idea using Tilemaps and implemented the same functionality in few hours only with Sprites... ;-)

 

Thank you for your replies, should have listened long before.

Link to comment
Share on other sites

  • 2 years later...

Same story here (except that I'm building an infinite tower game and want to copy/paste new chunks of tower above the others).

I found how to store the chunks easily and copy/paste them from a "storing" invisible layer to another without messing around with private properties. (map.copy && map.paste) 

Any news about changing the size of a tilemap ? any other idea how to implement it without resizing it ?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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