Map Loading?
by ARGuy · in Torque Game Builder · 01/05/2006 (7:24 pm) · 4 replies
I'm trying to follow the platformer tutorial and the map I created is not loading. I have created a function named createLevel() as below:
function createLevel()
{
$gravity = 700;
$spawnPoint = "-20 -30";
%tileMap = new t2dTileMap()
{
scenegraph = t2dscene;
};
%tileMap.loadTileMap("~/client/maps/platformer.tile");
%layer = %tileMap.getTileLayer(0);
%layer.setCollisionActive(false, true);
%layer.setGroup($platformGroup);
%layer.setLayer($platformLayer);
%layer.setPosition("0 0");
resetPlayer($spawnPoint);
}
My map is named platformer.tile and is in the correct folder. I get no message in the log file about anything failing but the map does not show up, I just get the normal logo. I just purchased t2d and have been having quite a few problems getting things to work as outlined in the tutorials. Any help is appreciated.
function createLevel()
{
$gravity = 700;
$spawnPoint = "-20 -30";
%tileMap = new t2dTileMap()
{
scenegraph = t2dscene;
};
%tileMap.loadTileMap("~/client/maps/platformer.tile");
%layer = %tileMap.getTileLayer(0);
%layer.setCollisionActive(false, true);
%layer.setGroup($platformGroup);
%layer.setLayer($platformLayer);
%layer.setPosition("0 0");
resetPlayer($spawnPoint);
}
My map is named platformer.tile and is in the correct folder. I get no message in the log file about anything failing but the map does not show up, I just get the normal logo. I just purchased t2d and have been having quite a few problems getting things to work as outlined in the tutorials. Any help is appreciated.
#2
I've got a couple of differences from the tutorial, i've got a different tilemap name as i made a mario based one.
I've added %layer.setTileSize("4 4"); and %layer.setSize("200 44"); as i was having similar problems to you.
I'll explain where i got them numbers from.
I created a tile map of 50 tiles wide and 11 tiles high. each tile was 4x4. It told me this when i initially loaded my map back into the tile editor Layer #0 - Quantity: 50 11 / Size: 4.0000 4.0000
So i just did the math and set the entire layer size to be 200 wide by 44 high. i got this number by
50 tiles * 4 = 200
11 tiles * 4 = 44
thats where i got %layer.setSize("200 44"); from, as for the TileSize take a peek in the tile editor and see what that's set to.
I'm sure the way i've done it is not the most elegant way, i'm still learning myself.
If there's a more experienced head out there could you please chip in and give us a pointer or two :P
cheers.
01/05/2006 (8:07 pm)
I've just recently bought T2D also and the last couple of nights i was running though this same tutorial. here is the code i have for that specific bit.function createLevel()
{
$gravity = 200;
$spawnPoint = "-20 -30";
%tileMap = new t2dTileMap() { scenegraph = t2dscene; };
%tileMap.loadTileMap("./maps/mario.tile");
%layer = %tileMap.getTileLayer(0);
%layer.setCollisionActive(false, true);
%layer.setGroup($platformGroup);
%layer.setLayer($platformLayer);
%layer.setPosition("0 0");
%layer.setTileSize("4 4");
%layer.setSize("200 44");
resetPlayer($spawnPoint);
}I've got a couple of differences from the tutorial, i've got a different tilemap name as i made a mario based one.
I've added %layer.setTileSize("4 4"); and %layer.setSize("200 44"); as i was having similar problems to you.
I'll explain where i got them numbers from.
I created a tile map of 50 tiles wide and 11 tiles high. each tile was 4x4. It told me this when i initially loaded my map back into the tile editor Layer #0 - Quantity: 50 11 / Size: 4.0000 4.0000
So i just did the math and set the entire layer size to be 200 wide by 44 high. i got this number by
50 tiles * 4 = 200
11 tiles * 4 = 44
thats where i got %layer.setSize("200 44"); from, as for the TileSize take a peek in the tile editor and see what that's set to.
I'm sure the way i've done it is not the most elegant way, i'm still learning myself.
If there's a more experienced head out there could you please chip in and give us a pointer or two :P
cheers.
#3
01/05/2006 (9:58 pm)
This helps quite a bit. Thanks for the info.
#4
02/20/2006 (11:26 am)
The map is probably positioned off the screen. If you made your map in the north left corner of the tile editor, try setting the player spawn point to -80 -80 instead and see if u end up at the right spot.. :)
Torque Owner ARGuy