Game Development Community

Changing map tiles

by Drew -Gaiiden- Sikora · in Torque Game Builder · 02/28/2005 (2:21 pm) · 3 replies

Is there any way you can change a given map tile in the game? I can't find anything in the fxTileMap2D reference section that looks like it returns the object of a particular tile for modification.

#1
02/28/2005 (2:46 pm)
@Drew: Look at the function "getTileLayer(%n);".

As a rough guide, you use the fxTileMap2D to get access to the layers. It's here that you add, remove and generally manipulate layers. It's here you can ask for a layer object using the above function.

With the layer (fxTileLayer2D) object you can then set tiles, collisions, all sorts of stuff.

Assuming you've got a tilemap with a single layer, you'd use something like the following to get the layer and set the tile (0,0) to a static image:-

%myLayer = myTileMap.getTileLayer( 0 );
%myLayer.setStaticTile( "0 0", myImageMap, myFrame );

Look-up the fxTileLayer2D object to see what you can do with it in the reference document.

Expect more documents in the near future for stuff like this.

Hope this helps,

- Melv.
#2
02/28/2005 (2:52 pm)
Thx Melv, I actually just found it myself, sry to trouble ya! :) I was looking for a function that gave you direct access to the individual tile, sorta like how fxTileMap2D gives you access to fxTileLayer2D, so I didn't look to closely at setStaticTile. My bad! Must read docs more carefully! :P
#3
03/01/2005 (12:56 am)
@Drew: No problem, it's here for all to learn now. :)

- Melv.