Problem with Platformer Tutorial
by Kneekick · in Torque Game Builder · 03/05/2006 (12:56 pm) · 6 replies
I've been at this since 10am this morning so sorry if I sound a little frustrated.
I'm at the point where I just finished creating a tilemap in the tile editor and it is supposed to load on screen and the GGLogo is supposed to fall and land on it so I can move forward with the tutorial.
Here is my code in gameData.cs:
$platformGroup = 0;
$playerGroup = 1;
$platformLayer = 5;
$playerLayer = 2;
function createLevel()
{
$gravity = 700;
$spawnPoint = "30 -40";
%tileMap = new t2dTileMap()
{
scenegraph = t2dscene;
};
%layer = %tileMap.loadTileMap("~/data/tilemaps/platformer.tile");
%layer = %tileMap.getTileLayer(0);
%layer.setCollisionActive(false, true);
%layer.setGraphGroup($platformGroup);
%layer.setLayer($platformLayer);
%layer.setPosition("0 0");
resetPlayer($spawnPoint);
}
If I leave "%layer = %tileMap.getTileLayer(0);" which is what the tutorial states I should, the tile map does not show up on screen. The console is clean of errors as well in this scenario. The gglogo falls right through the screen.
If I change that to a 1, "%layer = %tileMap.getTileLayer(1);" the tilemap that I made does show up on screen however the gglogo just falls through it and it doesn't seem to be affected by the setPosition command. I'm assuming that the setLayer & setGraphGroup commands are not taking place either. Here is the console output when I set it to 1:
t2dTileMap::getTileLayer() - Invalid Tile Layer '1'! Currently '1' Layers available.
Platformer/gameScripts/gameData.cs (19): Unable to find object: '-1' attempting to call function 'setCollisionActive'
Platformer/gameScripts/gameData.cs (20): Unable to find object: '-1' attempting to call function 'setGraphGroup'
Platformer/gameScripts/gameData.cs (21): Unable to find object: '-1' attempting to call function 'setLayer'
Platformer/gameScripts/gameData.cs (22): Unable to find object: '-1' attempting to call function 'setPosition'
I simply don't get it and I'm ready to give up. I've gone through the tutorial from front to where I am now 5 times, I've looked through other tutorials to see how they do tilemaps and tried to emulate them to no avail.
Someone please help.
Thanks.
I'm at the point where I just finished creating a tilemap in the tile editor and it is supposed to load on screen and the GGLogo is supposed to fall and land on it so I can move forward with the tutorial.
Here is my code in gameData.cs:
$platformGroup = 0;
$playerGroup = 1;
$platformLayer = 5;
$playerLayer = 2;
function createLevel()
{
$gravity = 700;
$spawnPoint = "30 -40";
%tileMap = new t2dTileMap()
{
scenegraph = t2dscene;
};
%layer = %tileMap.loadTileMap("~/data/tilemaps/platformer.tile");
%layer = %tileMap.getTileLayer(0);
%layer.setCollisionActive(false, true);
%layer.setGraphGroup($platformGroup);
%layer.setLayer($platformLayer);
%layer.setPosition("0 0");
resetPlayer($spawnPoint);
}
If I leave "%layer = %tileMap.getTileLayer(0);" which is what the tutorial states I should, the tile map does not show up on screen. The console is clean of errors as well in this scenario. The gglogo falls right through the screen.
If I change that to a 1, "%layer = %tileMap.getTileLayer(1);" the tilemap that I made does show up on screen however the gglogo just falls through it and it doesn't seem to be affected by the setPosition command. I'm assuming that the setLayer & setGraphGroup commands are not taking place either. Here is the console output when I set it to 1:
t2dTileMap::getTileLayer() - Invalid Tile Layer '1'! Currently '1' Layers available.
Platformer/gameScripts/gameData.cs (19): Unable to find object: '-1' attempting to call function 'setCollisionActive'
Platformer/gameScripts/gameData.cs (20): Unable to find object: '-1' attempting to call function 'setGraphGroup'
Platformer/gameScripts/gameData.cs (21): Unable to find object: '-1' attempting to call function 'setLayer'
Platformer/gameScripts/gameData.cs (22): Unable to find object: '-1' attempting to call function 'setPosition'
I simply don't get it and I'm ready to give up. I've gone through the tutorial from front to where I am now 5 times, I've looked through other tutorials to see how they do tilemaps and tried to emulate them to no avail.
Someone please help.
Thanks.
About the author
#2
$playerGroup = 1;
$platformLayer = 5;
$playerLayer = 2;
function createLevel()
{
$gravity = 700;
$spawnPoint = "30 -40";
%tileMap = new t2dTileMap()
{
scenegraph = t2dscene;
};
%tileMap.loadTileMap("~/data/tilemaps/platformer.tile");
%layer = %tileMap.getTileLayer(0);
%layer.setCollisionActive(false, true);
%layer.setGraphGroup($platformGroup);
%layer.setLayer($platformLayer);
%layer.setPosition("0 0");
resetPlayer($spawnPoint);
}
I had it like that originally, that's what the tutorial states to type.
However the exact same thing happens when it's like this too. I get the same errors in the console as I did before. (I just changed it back per your suggestion just for fun).
If I set it to %layer = %tileMap.getTileLayer(0); I get no errors in the console but the tilemap does not show up. If I set it to 1, I get the same errors in the console as before. It doesn't seem to matter what I do it doesn't work.
03/05/2006 (2:17 pm)
$platformGroup = 0;$playerGroup = 1;
$platformLayer = 5;
$playerLayer = 2;
function createLevel()
{
$gravity = 700;
$spawnPoint = "30 -40";
%tileMap = new t2dTileMap()
{
scenegraph = t2dscene;
};
%tileMap.loadTileMap("~/data/tilemaps/platformer.tile");
%layer = %tileMap.getTileLayer(0);
%layer.setCollisionActive(false, true);
%layer.setGraphGroup($platformGroup);
%layer.setLayer($platformLayer);
%layer.setPosition("0 0");
resetPlayer($spawnPoint);
}
I had it like that originally, that's what the tutorial states to type.
However the exact same thing happens when it's like this too. I get the same errors in the console as I did before. (I just changed it back per your suggestion just for fun).
If I set it to %layer = %tileMap.getTileLayer(0); I get no errors in the console but the tilemap does not show up. If I set it to 1, I get the same errors in the console as before. It doesn't seem to matter what I do it doesn't work.
#3
03/05/2006 (2:39 pm)
Not sure what to say. Here's the code from my most recent foray into tilemaps (Note that I use a script object simply for instructional purposes--it's not required):function setupT2DScene()
{
echo("Starting setupT2DScene()");
// Create our scenegraph
new t2dSceneGraph(t2dScene);
// SRZ: Hopefully this will be done later through the level editor
new ScriptObject(BaseLevel);
BaseLevel.map = new t2DTileMap(Map) {sceneGraph = t2dScene; immovable = true; };
BaseLevel.map.loadTileMap("~/data/tilemaps/testmap.map");
BaseLevel.map.setImmovable();
%layer = BaseLevel.map.getTileLayer(0);
%layer.setCollisionActive(false, true);
%layer.setImmovable();
%layer.setGraphGroup($platformGroup);
%layer.setLayer($platformLayer);
%layer.setPosition(0,0);
%layer.setTileSize("5 10");
echo("TileSize is (" @ %layer.getSize() @ ")");
%layer.setSize(250, 500);
%layer.setDebugOn(5);
// Associate Scenegraph with Window.
sceneWindow2D.setSceneGraph( t2dScene );
// Set the current camera position
sceneWindow2D.setCurrentCameraPosition("25 25 150 150");
sceneWindow2D.setCurrentCameraZoom($defaultCameraZoom);
// t2dScene.setConstantForce("0 175");
t2dScene.setScenePhysicsFPSActive(true);
t2dScene.setScenePhysicsLimitFPS(60);
t2dScene.setScenePhysicsTargetFPS(60);
t2dScene.setScenePhysicsMaxIterations(5);
echo("Exiting setupT2DScene");
}
#4
Set the getTileLayer to 0, get no errors in the console but my tilemap doesn't show up.
Or set the getTileLayer to 1, see my tilemap but get errors in the console.
I really need to go through this tutorial as the game I plan on making has a lot in common with a platformer. I guess I'll figure it somehow.
03/05/2006 (2:55 pm)
Well like I said I don't know what to do next. I've played with the code, reset it back to what the tutorial states and I always end up at the same scenario.Set the getTileLayer to 0, get no errors in the console but my tilemap doesn't show up.
Or set the getTileLayer to 1, see my tilemap but get errors in the console.
I really need to go through this tutorial as the game I plan on making has a lot in common with a platformer. I guess I'll figure it somehow.
#5
03/05/2006 (6:40 pm)
The only thing I can think of that you might want to try is ensure that both the camera and the layer position are set to 0 0 and see if you get anything. The other thing that I will mention is did you save this as a tile map or a tile layer ? Also do you have tiles at the bottom of the map as if your map is 50 x 50 then is might be positioning itself down the bottom ?
#6
03/06/2006 (4:35 am)
Thanks for the thoughts Glenn. I'll double check all of those things.
Torque 3D Owner Stephen Zepp
%layer = %tileMap.loadTileMap("~/data/tilemaps/platformer.tile");is probably not working as expected. Try this:
%tileMap.loadTileMap(("~/data/tilemaps/platformer.tile"); %layer = %tileMap.getTileLayer(0);Since your attempt to setLayer and setPosition on the tilemap is failing, the logo by default won't collide with it (since the tile layer has no collision groups or layers set).