Game Development Community

default TileMap [Solved]

by Max Kielland · in Torque Game Builder · 01/10/2013 (11:59 pm) · 6 replies

Hi,

When I start a blank project I have noticed that I get one t2dSceneGraph and one t2dTileMap (under the project tab). I selected the t2dTileMap and gave it a name 'tilemap'.

In my game.cs function startGame I added
%LayerCount = tilemap.getTileLayerCount();

...but when I execute the project and inspect the variable in Torsion I first of all get an error:
"Unable to find object: 'tilemap' attempting to call function 'getTileLayerCount'"

How do I access the default t2dTileMap?

#1
01/11/2013 (6:30 am)
Try this:

%tileMap = $LastLoadedScene.getGlobalTileMap();
%layerCount = %tilemap.getTileLayerCount();

Though the default tile map is added by the scene loading code and is just a new object with default parameters set. It would be better (and generally more useful) to add a tilemap in the editor and set it up there.
#2
01/14/2013 (6:14 am)
In that project my tile map will be populated with a seed algorithm. My thought was to use what was already there. I don't see why there is an empty tile map added in the first place?!?
#3
01/14/2013 (11:44 am)
Got me - I just work here....
#4
01/15/2013 (12:52 am)
I can't delete it in the Game Builder.
So what you say is that It should be safe to delete it from a script?
#5
01/15/2013 (6:13 am)
I'd rather say that you could try removing the attempt by levelManagement.cs to add it. Or you can use <yourscenename>.getGlobalTileMap() to access and use the one that it adds automatically.

Or you could ignore it - it's harmless.
#6
01/15/2013 (10:44 am)
Well, as you say, it's no harm... just annoying :)
Thank you for your help.