onTileScript not being called
by Samuel Cartwright · in Torque Game Builder · 01/17/2009 (12:02 am) · 3 replies
I've added a Tile Map to my level, and placed tiles in the Tile Layer using the "Edit Tile Layer" screen.
For some tiles I've put some text in the "Tile Script" filed so that the onTileScript callback will be called for these tiles. However in my game scripts, this callback function is never called.
Is there something I'm missing here?
For some tiles I've put some text in the "Tile Script" filed so that the onTileScript callback will be called for these tiles. However in my game scripts, this callback function is never called.
Is there something I'm missing here?
#2
When you add a tile map to your level using the level editor, and set the Class name, you are actually setting the name of the layer (which you can confirm in the Object Tree under the Project tab).
That is why you need to add the callback function to your script like this: t2dTileMap::onTileScript.
So what happens if you need to add 2 tile maps to your level? I guess you could use the %this parameter to determine which tile map the event occurred on.
Is there a way I could set the class of my tile map so that I could have something like this:
PlayerGameBoardTileMap::onTileScript, and
OpponentGameBoardTileMap::onTileScript
01/24/2009 (12:05 am)
OK, I think I understand everything now.When you add a tile map to your level using the level editor, and set the Class name, you are actually setting the name of the layer (which you can confirm in the Object Tree under the Project tab).
That is why you need to add the callback function to your script like this: t2dTileMap::onTileScript.
So what happens if you need to add 2 tile maps to your level? I guess you could use the %this parameter to determine which tile map the event occurred on.
Is there a way I could set the class of my tile map so that I could have something like this:
PlayerGameBoardTileMap::onTileScript, and
OpponentGameBoardTileMap::onTileScript
#3
Oh, THAT explains it. Seems that the onTileScript callback should fire on the tileLayer not the tileMap. I think that would fix things.
I've racked my brains a few times to understand the reason there are tilemaps and tilelayers. I've given up. :P But I'm sure some game types somewhere need it. I just don't have enough experience to see this as "obvious."
07/17/2011 (12:08 pm)
Quote:When you add a tile map to your level using the level editor, and set the Class name, you are actually setting the name of the layer (which you can confirm in the Object Tree under the Project tab).
That is why you need to add the callback function to your script like this: t2dTileMap::onTileScript.
Oh, THAT explains it. Seems that the onTileScript callback should fire on the tileLayer not the tileMap. I think that would fix things.
I've racked my brains a few times to understand the reason there are tilemaps and tilelayers. I've given up. :P But I'm sure some game types somewhere need it. I just don't have enough experience to see this as "obvious."
Torque Owner Samuel Cartwright
Samuel Cartwright
I was setting the Class of my tile map to GameBoard, so I assumed I had to script the onTileScript function like this:
But that wasn't working. It turns out I actually needed to do this:
So my question is, why does that work? Even when I set the Super Class to t2dTileMap, the onTileScript function wasn't being called for the GameBoard class.
Is that just some oddness with the engine, or am I doing something wrong?