Game Development Community

Tiles with Actions to call

by Colin Richardson · in Torque Game Builder · 11/14/2006 (11:41 am) · 2 replies

Hi,

I'm probably being very stupid here so i apologise in advance.

I've been messing around with the Platform Tutorial and have got on well with it despite some questions that folks here have been great in answering.

What i want to know is thus:

I have written the camera routines so that i can Zoom in/out when i need to all i need to do is to call the various function.

I would like when i collide (by walking/jumping) on a set tile that it calls one function and then when i have a collision with another tile it calls another function.

I've looked at the Tile Map Editor but when i set a class to that, it sets it to every tile in my map.

So it's calling the collision routine (as below) for every single tile (i need them to collide so the player doesn't fall through them).

function t2dTileMap::onCollision(%srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts)
{
      echo("Hello i've been collided with");
}

Therefore my quesiton is how do i apply either a specific class to the various tiles OR do i have to use the X & Y postion and then calculate it if it's my tiles that have been collided with.

Thanks in advance.

Colin

#1
11/16/2006 (7:37 pm)
There may be a better solution to this, and if there is, hopefully someone replies. However, there are a couple of ways I can think of to 'cheat' the effect. These are untested, so they may not work.
1) You could set triggers on the tiles that should zoom the camera in/out
2) You could set the specific tiles to be on a seperate layer and detect collision with that layer as opposed to the individual tile itself.
3) I haven't used these commands, so they may be in the wrong context, but from what I can make out, you could use SetTileCustomData and GetTileCustomData. For the specific tiles, you could set the data to say "ZoomIn", and if there's collision with the tile, check it's custom data using the latter command and if it's equal to "ZoomIn", execute the function.

As I say, these are untested, but hopefully they help or may give you some ideas :)
#2
11/17/2006 (5:30 am)
Hi Apurva,

Thanks for your reply. I have looked into Triggers as it means if the player jumps into the area and doesn't touch a tile then i can catch it and operator the ZoomIn etc.

So i think i'll be going that route for the moment but not had time since i posted this to do anything more as my dev machine seems to want to not work at the moment and i'm doing everything to stop the need for an XP install.

However i've also looked into the setTileCustomData/getTileCustomData and i think i'll be using these to set up tiles that may crumble or fall away etc.

Thanks for your response, i'll let you know how i get on with this.

Cheers
Colin