Game Development Community

Tilemaps and torqueX

by Bruno · in Torque X 2D · 08/17/2007 (9:50 am) · 6 replies

Hi.,

I created a TileMap in TGX, and i gave it the name myBoard .
Now, inside Visual C# i want to access this tilemap, and i can like this :

T2DSceneObject myBoard = TorqueObjectDatabase.Instance.FindObject("myBoard");


However, i cannot access individual cells in this tilemap like i can in TGB.
In the documentation, it shows :

public bool SetTileByGridCoords(
int x,
int y,
T2DTileObject tile
)

However, this method is not exposed., is this not yet implemented or am i missing something ?
thanks,
Bruno

#1
08/17/2007 (9:56 am)
@Bruno - Since you're defining myBoard as a T2DSceneObject the C# compiler doesn't know that it's a tile layer object. Try making your myBoard variable into a T2DTileLayer type.
#2
08/17/2007 (10:09 am)
Thanks Dan, that was the problem ;)

One last question, how can i change the tile on the fly ?
The documentation states that :

public bool SetTileByGridCoords(
int x,
int y,
T2DTileObject tile
)

So, i enter a tileobject in the tilemap, instead of a T2DstaticSprite.
But, if i create a T2DTileObject :

T2DTileObject test;

i have no way to assign a texture to this tile, T2DTileObject has no method to assign a texture to it.
How do i do this ? Either adding a texture or deleting.

thanks again,
Bruno
#3
08/17/2007 (10:48 am)
@Bruno - You can set the Material property of a T2DTileType object. Try something like this:
T2DTileLayer myBoard = TorqueObjectDatabase.Instance.FindObject<T2DTileLayer>("myboard");
T2DTileType myType = new T2DTileType();
myType.Material = TorqueObjectDatabase.Instance.FindObject<GarageGames.Torque.Materials.RenderMaterial>("whateverMaterial") as GarageGames.Torque.Materials.RenderMaterial;
myBoard.GetTileByGridCoords(0, 0).TileType = myType;
#4
08/17/2007 (11:17 am)
Wow.., that's complicated, ehh, and it's working now

Thanks Dan.. :)
#5
08/17/2007 (1:01 pm)
The interface for modifying tile layers has been simplified quite a bit since 1.0. Sorry for the complicated mess. :(
#6
08/17/2007 (3:53 pm)
Not a problem Thomas , if it's simpler, the better :)