Building a Map

Hi dyson,

After position lots of different obects on a map as sprites, I want to build a map that shows the positions of all these objects.

Is it possible to loop through a map by tile and return whether or not a sprite is on top of that tile? (rather than looping through the sprites)
 

Thanks, Greg

** Ok that was a really bad idea, looping by tile… unless your waiting for the snow to melt!

I’ll work from this:

function buildChart()
    asprite={}
    asprite = mte.getSprites()
    for i = 1,#asprite do
        print ("Sprite: "… asprite[i].id, asprite[i].locX, asprite[i].locY)
    end    
end  

The getSprites() function loops through all of the sprites and compares their properties to the parameters you set (if any), so you’ll want to call getSprites() as few times as possible. I’m guessing you tried looping through the map locations and calling getSprites() for each location; I can certainly imagine how slow that would be!

Out of curiosity, what are the dimensions of your map, and how many sprites are you adding to it?

Hi dyson,

getSprites() worked great compared to looping through the map by tiles.   My map isn’t too big, it’s 128x128 with about 200 sprites on it.

Thanks, Greg

The getSprites() function loops through all of the sprites and compares their properties to the parameters you set (if any), so you’ll want to call getSprites() as few times as possible. I’m guessing you tried looping through the map locations and calling getSprites() for each location; I can certainly imagine how slow that would be!

Out of curiosity, what are the dimensions of your map, and how many sprites are you adding to it?

Hi dyson,

getSprites() worked great compared to looping through the map by tiles.   My map isn’t too big, it’s 128x128 with about 200 sprites on it.

Thanks, Greg