Set brush class itorque?
by Anna Tito · in iTorque 2D · 05/09/2011 (8:10 pm) · 2 replies
Hey guys,
Is there a way to set a class to a brush/tile in iTorque tile map?
I can't seem to set it to send collisions, so I just want to set a default behaviour to the custom collisions on the tiles. Is there a way to do this or do I have to use the custom Data/Tile Script vars to do it.
Cheers
Anna
Is there a way to set a class to a brush/tile in iTorque tile map?
I can't seem to set it to send collisions, so I just want to set a default behaviour to the custom collisions on the tiles. Is there a way to do this or do I have to use the custom Data/Tile Script vars to do it.
Cheers
Anna
About the author
Game Design and Programming Student at RMIT.
#2
In the editor, you select the tile layer then expand the Scripting section under the Edit tab. From there, you can type in the class. For example, you can set a t2dTileLayer's class to "board". From script, you can then expand the class:
There is code to perform collision on a per-tile basis, but it is costly on the CPU.
05/10/2011 (6:22 am)
@Anna - Stock iT2D does not support classes/data on individual tiles. As Pedro demonstrated, an entire t2dTileLayer can have a class. His example builds a tile layer dynamically from script.In the editor, you select the tile layer then expand the Scripting section under the Edit tab. From there, you can type in the class. For example, you can set a t2dTileLayer's class to "board". From script, you can then expand the class:
function Board::onLevelLoaded(%this, %scenegraph)
{
// Perform custom code on tile layer when level is loaded
}There is code to perform collision on a per-tile basis, but it is costly on the CPU.
Torque 3D Owner Pedro Vicente
Space Research Software LLC
I never tried collisions with tile layers, but to set a class to a t2dTileLayer instance in script, it's just the "usual" way to subclass. Here's an example taken from a tutorial
tdn.garagegames.com/wiki/TGB/Tutorials/The_Game_of_Life
function CaTutorialPart4::CreateTileLayers(%this) { %tileCountX = %this.model.get_size_x(); %tileCountY = %this.model.get_size_y(); %tileSizeX = 4; %tileSizeY = 4; %this.WallTileLayer = new t2dTileLayer() { class = "TileLayerCaTutorialPart4"; }; %this.WallTileLayer.setUseMouseEvents( true ); %this.WallTileLayer.createLayer( %tileCountX, %tileCountY, %tileSizeX, %tileSizeY ); %this.WallTileLayer.setSize( %tileCountX * %tileSizeX, %tileCountY * %tileSizeY ); %this.WallTileLayer.setGridActive( 1 ); %this.WallTileLayer.setPosition( 0, 0 ); %this.getGlobalTileMap().addTileLayer( %this.WallTileLayer ); }