If I were to use a grid (tiled) map, what would be the most efficient implementation?
So far I've been experimenting with the array object. It is robust enough, within each element I can store specific tile data even on Z layer (sky/ground/underground). Fine and dandy.
Now, the problem arises when I try to populate the layout with those tiles or their graphical counterparts. If I create an instance of tile graphic for each given tile, the number of instances quickly rises into hundreds! Soon you have thousand objects on the layout. I highly doubt this is the correct approach.
For example, on 640x480 layout with 32x32 tile size there would be 20x15 tiles, which amounts to 300 instances. Now imagine I add flavors, such as transparent objects, terrain features, NPCs on top of all that.
Surely there has to be a more elegant way? I intend to build a game map of 100x100 tiles, smooth scrollable and all that. Now that is a scary amount of instances...