Game Development Community

t2dTileLayer collisions

by Samuel Cartwright · in Torque Game Builder · 01/15/2009 (5:25 pm) · 4 replies

*newbie post*

I'm trying to learn the TGB by making my own Tetris game. I want the tiles (static sprites) to drop down from the top screen and when they reach the bottom the tiles will attach themselves to the t2dTileLayer.

I've got the basic movement of the static sprites working - and collisions between other tiles work fine - but I can't get collisions between the tiles and the tile layer working.

I want the tile to send a collision event to the tile layer whenever the tile hits an edge of the tile layer. So far I can't receive the collision event and I don't know where I'm going wrong (or even if this is the wrong way to do this).

I've read in the documents that the %srcRef and %dstRef parameters in the onCollision are only used by the t2dTileLayer, but I read a post saying that layers can't receive collision events. So I don't even know if what I'm trying to do is even possible.

I'm not to keen on the idea of using world limits instead, since I want the tiles to be able to shoot off the screen or move around when they are 'destroyed'.

Can anyone give me some advice or some pointers? If I'm going about making a Tetris game the wrong way, how should I be approaching this? (I was going off the Checkers tutorial)

Regards,
Sam.

#1
01/16/2009 (10:04 am)
I'm a noob to TGB also but i was just doing the tile map tutorial last night and i think i did what you are trying to do. you may have done this already so not sure if this will help you out

when you are editing your tile layer there is a collision check box that needs to be checked.. then i believe you just set up how you want the tile layer collision to act under the collision section
#2
01/16/2009 (8:50 pm)
Ahh, I see my mistake now.
You can intercept collisions for the tiles in the tile layer, but not the tile layer itself.
Thanks.
#3
01/16/2009 (9:06 pm)
Phil,

I just found the Tetris tutorial: http://tdn.garagegames.com/wiki/Torque_2D/Getting_Started/T2DTetrisTutorial

They build the tile map borders using tiles that detect collisions.

This looks much simpler than what I was trying to do.

Thanks once again.
#4
01/17/2009 (5:56 am)
looks like a good tutorial.. I'll have to give that one a shot.. Thank!