Game Development Community

Get Tile Position on Collision?

by Kiyaku · in Torque Game Builder · 06/27/2007 (6:38 am) · 2 replies

Hi, im planing to do a breakout clon game.

So when i collide with a tile on a tilelayer, is it possible to get it's position back so i can delete this tile?

#1
06/27/2007 (6:24 pm)
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);
}
#2
06/28/2007 (5:08 am)
Thanks a lot, works perfect :)