Game Development Community

Tile Layer not Displaying

by Doug Linley · in Torque Game Builder · 07/04/2006 (7:46 pm) · 1 replies

Hi all. I'm trying to create an 8x8 tile grid and display something on them. I have the following code.

function connexionLevel::onLevelLoaded(%this)
{
   %this.map = %this.getGlobalTileMap();
   %this.tileLayer = %this.map.createTileLayer(8, 8, 64, 64);
   
   echo(%this.tileLayer);
   
   %this.tileLayer.setPosition(gameBoard.getPosition());
   %this.tileLayer.setLayer(0);
   %this.tileLayer.setVisible(1);
      
   for(%x=0; %x<8; %x++)
   {
      for(%y=0; %y<8; %y++)
      {
         %frame = getRandom(7);
         %this.tileLayer.setStaticTile(%x SPC %y, Gem_1ImageMap, %frame);
         echo("Creating static tile.");
         echo(%this.tileLayer.getPosition());
         echo(%this.tileLayer.getTileCount());
         echo(%this.tilelayer.gettiletype(%x SPC %y));
      }
   }
}


There are no errors in the console, and my echo statements confirm that the tile values are being set and the layer is being created, yet the tiles are not displaying. I've checked the position to make sure it's the same as my visible game board, I've checked the tile layers (30 for the background, 0 for the tiles) and I've checked the frame being displayed. Any help would be greatly appreciated. Below are some of the statements returned from the console based on my echo's.

Creating static tile.
126.000000 -29.000000
8 8
static Gem_1ImageMap 7
Creating static tile.
126.000000 -29.000000
8 8
static Gem_1ImageMap 3
Creating static tile.
126.000000 -29.000000
8 8
static Gem_1ImageMap 4

#1
07/05/2006 (1:04 pm)
Rodney (Torqued) helped me out with this. The layer needed to be resized manually. A call to %this.tileLayer.setSize("512 512") did the trick.