Adding multidimensional table (Tile Array) to display group?

Hey all - Thanks for looking!

I’ve made a tile grid:

TileGrid = { }
TileGrid[x] = { }

…within an x and y loop - and it populates the grid with lots of display.newImage();

This works fine, and I can access all the tiles on the screen. I can even add each Tile Object separately to a display group:

tileGroup:insert(TileGrid[0][0])

…I can now see the tiles.

However, because I’ve added the tile objects to the group individually, when I remove them from the tile array they stay displayed on the screen. (Because they are inserted into the display group seperate!)

Does anyone know a good way so that when I remove the tiles from the grid, the image gets removed as well? I cannot simply add the tileGrid table into a display group, it won’t let me! [import]uid: 79864 topic_id: 34417 reply_id: 334417[/import]

how are you removing them? Can you post some code?
[import]uid: 199310 topic_id: 34417 reply_id: 136851[/import]

Thanks for the reply!

OK, so here I am adding the tile to my multidimensional table and also adding the individual tile into a display group called tileGroup.

 -- insert the Tile into the group  
 TileGrid[x][y] = TileObject  
 tileGroup:insert(TileGrid[x][y])  

Upon further investigation, I can access the tiles properties that I set up in the tile class:

 myTile.Collision = true  
 myTile.Color = 'null'  

Like this:

 collision = TileGrid[0][6].Collision  

However, when I try to move the image, or remove the image by using something like this:

TileGrid[0][6].x = 200  
TileGrid[0][6]:removeSelf()  

The tile gets removed (from the array, but the image is still on the screen! It’s like the image part of the tile is seperate from it’s properties??

Thank you for your assistance, it must be something to do with how I’m adding it to the groups…? [import]uid: 79864 topic_id: 34417 reply_id: 136884[/import]

SOLVED!

Thank you for looking Rob Miracle, I’ve managed to figure it out finally, I’ve created a function within my tile class that handles the destruction of it :slight_smile: [import]uid: 79864 topic_id: 34417 reply_id: 136888[/import]

how are you removing them? Can you post some code?
[import]uid: 199310 topic_id: 34417 reply_id: 136851[/import]

Thanks for the reply!

OK, so here I am adding the tile to my multidimensional table and also adding the individual tile into a display group called tileGroup.

 -- insert the Tile into the group  
 TileGrid[x][y] = TileObject  
 tileGroup:insert(TileGrid[x][y])  

Upon further investigation, I can access the tiles properties that I set up in the tile class:

 myTile.Collision = true  
 myTile.Color = 'null'  

Like this:

 collision = TileGrid[0][6].Collision  

However, when I try to move the image, or remove the image by using something like this:

TileGrid[0][6].x = 200  
TileGrid[0][6]:removeSelf()  

The tile gets removed (from the array, but the image is still on the screen! It’s like the image part of the tile is seperate from it’s properties??

Thank you for your assistance, it must be something to do with how I’m adding it to the groups…? [import]uid: 79864 topic_id: 34417 reply_id: 136884[/import]

SOLVED!

Thank you for looking Rob Miracle, I’ve managed to figure it out finally, I’ve created a function within my tile class that handles the destruction of it :slight_smile: [import]uid: 79864 topic_id: 34417 reply_id: 136888[/import]