Game Development Community

Change tilelayer?

by Dan Rubenfield · in Torque X 2D · 06/19/2007 (6:04 am) · 3 replies

How do I create a tile layer, and then monkey around with individual tiles after it's instantiated?


EX: Change the art, height, etc of a tile?

#1
06/20/2007 (2:38 am)
There's an Edit Tile Layer (not sure of the exact name off-hand) button in the Edit tab. You can also click the rightmost button over the object in it's "quick access" toolbar.

Edit: The tile layer must be selected to get relevant editing options in the Edit tab.
#2
06/20/2007 (4:35 am)
Actually, I meant in code.
#3
06/26/2007 (1:54 pm)
Sorry it took me a little while to get back to this.

Tiles attributes are defined by TileType (similar to how datablocks work in TGB/TGE). If you change a tile's type, all other tiles with that same type will change. You could, however, create a new tile type for a tile and modify that.

To do this efficiently there are some shortcuts you could take. Specifically, if there is a limited number of different tile types you could define them beforehand and then just swap them out when you want to change them.

Here's an example of getting a specific tile on a tile layer and switching it's tile type:
myTilelayer.GetTileByGridCoords(x, y).TileType = someOtherTileType;

You'll want to add all the tile types you'll be using to the tile layer before you assign them to a tile.

Here's an example of that:
myTilelayer.TileTypes.Add(someOtherTileType);

Hope this helps.