Jump to content

Scrolling tilemap with random tile generation


Acid
 Share

Recommended Posts

Hi,

 

I built a small top down game using a static tilemap, and i would now like to go further and make the level infinite by scrolling vertically and generating bits of my map on the fly.

I checked some of the threads here but did not come up with a solution to my problem, and i am now quite confused: Is it possible to achieve this the way i want to? Should i generate tilemap layers as the map scrolls and destroy them once they cross the screen limits? Was the whole tilemap thing a mistake and should i generate sprites instead?

 

If anyone here has experience on the matter or some solutions to guide me towards my goal i would gladly listen to them :)

 

Link to comment
Share on other sites

You can use your tilemap as background.

To make it scroll use:

yourSprite.tilePosition.y += yourValue; // adapt this as needed

The other bits of the map you can use sprites.

Groups will probably be simpler, you create a group with all your objects and then kill and revive them as needed.

Link to comment
Share on other sites

You can also change your TileMap sprites on the fly.. there are 2 examples here

 

http://phaser.io/examples/v2/tilemaps/replace-tiles

http://phaser.io/examples/v2/tilemaps/swap-tiles

 

potentially you could use this for what you need but depends what you're trying to do..

 

As Acid asks though, does anybody know how Tilemaps works compared to eg drawing a screen full of sprites and pooling then at the edges of the screen?

 

I had assumed that's what Tilemaps did, but I don't know. If not have there been any performance results posted anywhere that show the performance and size limits of a TileMap?

 

thanks

J

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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