Converting Tilemap Tiles to Display Objects (is it possible?)

I am trying to figure out a way to layer tiles throughout my project (bringing tiles to the front, sending them to the back). When I try to use AddChild, it throws an error stating that it needs to be a display object. Is there a way to convert a tile (or an array of tiles) to display objects?

Yes although is not a nice one.

You make one tilemap per tile. A tilemap can contain tiles and is a displayObject in itself.

1 Like

I am doing that within a function, but have been creating it locally (due to the infinite about of maps I would need). I guess I was wondering if elements of the Array itself could be changed into display objects. (Perhaps I could make an array of tile maps? Never thought of that!) Thank you.

To create a new array of processed elements from an array you can use the .map() function of an array

The “Array of TileMaps” totally worked (and will for an infinite amount of maps/objects). That was friggin’ brilliant. Thank you!

Well, you have already everything you need in Tilemap to swap order of Tiles.

But I guess you need to layer with display objects right?

Yes for both. I had no idea you could just swap tiles tho. This will be useful. Also, I cannot find a command for finding the length (or amount) of objects on the display list. So that one could cycle through this list and find objects that have been moved to the front or back. Something like “getIndextLength” or something?




could be useful to you.

1 Like