Add and remove tiles? Or better to have them all loaded off screen?

by Neal Davis   Last Updated September 13, 2016 08:05 AM

Which method do you expect would have better performance when stressed? It's a 2D tile map where the camera has view of a small portion of the map. As I pan up/down/left/right, should I be adding and removing tiles from the stage as needed? or have them loaded, offstage, and just change their x/y coords as needed?

I'm using AS3 to code this and I have it working fine. And I know it's not wise to try to optimize early, but since I'm very new at this, I thought maybe someone already knows if one is usually better.

Answers 1

In a case like this, you are going to want to Pool your world tiles. The idea is to pre-load a fixed amount of tiles that you will be re-using during the rendering of your world.

When setting a tile into the world, you would typically set certain properties such as its position and texture. The rest of the object is already ready to go in memory.

The idea is to try to retain some tiles on the screen and only return them into your Pool when they are far enough. This way, if you revisit an area that was already set, you probably do not have to process as many tiles.

enter image description here

September 13, 2016 10:39 AM

Related Questions

How to implement 3D tile based rendering in Unity?

Updated February 22, 2016 01:05 AM

What tile storage method is best for tile-based game?

Updated February 26, 2016 03:05 AM

Movement inside 2d tile based map

Updated December 12, 2016 08:05 AM

Make a 2D tile map from isometric tile

Updated February 25, 2017 21:13 PM