Game Development Community

How does one define a 'Tile Script'?

by Dave Calabrese · in Torque Game Builder · 03/02/2008 (5:37 pm) · 2 replies

I am making a level in TGB using the tile editor, and I need to be able to define when my player is touching the ground (as compared to the walls / ceiling of the level). I see there is a drop-down box to give a tile a 'Tile Script', and I see that the documentation mentions being able to define a callback script to occur when the tile is collided upon by the player. However, I cannot seem to figure out how any of this works. It seems to me like I should be able to define a list of scripts that tiles can have defined to them, and would be displayed in the drop down, but I don't see where to do this.

So - could someone please direct me in how to set a collision script on a specific tile?

Thanks!

-Dave C.
21-6 Productions

#1
03/14/2008 (10:20 am)
Bump! Any chance of getting an answer on this before the weekend?
#2
03/30/2008 (1:28 pm)
For collision handling, you can find your answer in the following post: http://www.garagegames.com/mg/forums/result.thread.php?qt=63959

Quoting Adam Larson's (Employee) answer:
--------------------------
The onCollision callback from tile layers will give you the x and y tile indices of the tile that was hit. It's the 3rd or 4th parameter (depending on if the tile layer is the collider or collidee), labeled as %srcref and %dstref in the docs.

So, you could do something like this:

function t2dTileLayer::onCollision(%srcObject, %dstObject, %srcRef, %dstRef, %time, %normal, %contacts, %points)
{
%srcObject.clearTile(%srcRef);
}