TGB 1.1 B2: setTileCollisionActive doesnt seem to work right
by Jason Cahill · in Torque Game Builder · 03/29/2006 (1:13 am) · 3 replies
Problem:
.setTileCollisionActive doesn't work consistently. When I create 7 tiles, only three result in having collision rectangles.
Scenario:
I'm creating a tile layer with a bunch of tiles. I want each and every tile to process collisions, so I create a tile, set its collision active, and scale the collision box to fit my imagery.
Here's the setup code:
Here's the picture of the result:

Notice that only 3 of the 7 tiles have collision rectangles. Am I doing something wrong?
.setTileCollisionActive doesn't work consistently. When I create 7 tiles, only three result in having collision rectangles.
Scenario:
I'm creating a tile layer with a bunch of tiles. I want each and every tile to process collisions, so I create a tile, set its collision active, and scale the collision box to fit my imagery.
Here's the setup code:
function setLevelTile(%tileLayer, %x, %y)
{
%tileLayer.setStaticTile(%x, %y, imdbTile);
%tileLayer.setTileCollisionActive(%x, %y, true);
%tileLayer.setTileCollisionScale(%x, %y, "0.5 0.5");
}
function createMap()
{
$tmLevel = new t2dTileMap()
{
sceneGraph = t2dScene;
};
$tmLevel.setPosition("0 0");
$tmLevel.setLayer(1);
$tmLevel.setGraphGroup(2);
$tmLevel.setCollisionMasks(BIT(5), BIT(1));
$tmLevel.setCollisionCallback(true);
$tl = $tmLevel.createTileLayer(5, 5, 4, 4);
$tl.setSize((5 * 4) SPC (5 * 4));
$tl.setCollisionActive(false, true);
$tl.setCollisionCallback(true);
$tl.setLayer(1);
$tl.setGraphGroup(2);
$tl.setPosition("0 0");
setLevelTile($tl, 0, 0);
setLevelTile($tl, 1, 1);
setLevelTile($tl, 2, 1);
setLevelTile($tl, 2, 2);
setLevelTile($tl, 3, 0);
setLevelTile($tl, 4, 0);
setLevelTile($tl, 1, 2);
}Here's the picture of the result:

Notice that only 3 of the 7 tiles have collision rectangles. Am I doing something wrong?
About the author
Torque Owner Michael Woerister
// (tileX, tileY, receive) else if ((elementCount == 1) && (argc > 3)) { tileX = dAtoi(argv[2]); tileY = dAtoi(argv[2]); [b]// <-- This should be argv[3][/b] receive = dAtob(argv[4]); }-Michael