AddToLevel Conflicts with Tile Maps
by Seth Willits · in Torque Game Builder · 05/08/2008 (6:54 pm) · 3 replies
When I call sceneWindow2D.addToLevel, the tile maps in the level I'm adding don't get loaded. Any idea what's going on there? There are no errors or anything.
About the author
http://www.sethwillits.com/
#2
It's too late for me to try it tonight, but I see t2dSceneGraph.getGlobalTileMap(); I assume that's what I have to add the tile layers too? I'll give it a go tomorrow after I get back from my morning mountain bike ride. :)
Thanks
05/09/2008 (12:51 am)
Sliver_TGB in the IRC room thought something along those lines too. Which is a bit odd to me, because I didn't know there was one tile *map* for the scenegraph, and then you add tile *layers* to that tile map, but the layers can be independently positioned and have different tile sizes. It seems contrary to conventional thought.It's too late for me to try it tonight, but I see t2dSceneGraph.getGlobalTileMap(); I assume that's what I have to add the tile layers too? I'll give it a go tomorrow after I get back from my morning mountain bike ride. :)
Thanks
#3
05/09/2008 (3:13 am)
Here is the code you want:%tileMap = sceneWindow2D.getSceneGraph().getGlobalTileMap();
%tileLayer = %tilemap.createTileLayer(1, 1, 1, 1);
// Important!!! Must load a *template* layer
// The layer can be found in your <TGB DIR>\tgb\tools\levelEditor\scripts\forms\objectLibrary folder
%tileLayer.loadTileLayer(expandFileName("~/data/tilemaps/newLayer.lyr"));
// You can now do whatever you want to the layer
...
%fileName = expandFileName("~/data/tilemaps/testLayer.lyr");
%tileLayer.saveTileLayer(%fileName);
Associate Phillip O'Shea
Violent Tulip
Also, remember to set the size of the layer, it is something I forget to do all the time. All the time.