Tutorials
by Dave D · in Torque Game Builder · 11/16/2005 (2:25 pm) · 3 replies
I tried the tutorials over at TDN and I know they're for the next version, but could some please explain to me how to load a map with 3 layers. Sky, ground, and dirt( underneath the ground.) Maybe I am just making the map wrong? I will be bald at the end of the day if I keep going the way I am.
Torque 3D Owner Tom Ogburn
Starlit Sky Games
$backgroundGroup = 0; $platformGroup = 1; $playerGroup = 2; $backgroundLayer = 6; $platformLayer = 5; $playerLayer = 2; function createLevel() { //Create a tile map and load our map into it %tileMap = new fxTileMap2D() { scenegraph = t2dSceneGraph; }; %tileMap.loadTileMap("./maps/platformer.map"); //Load the first layer (Background and completely solid surfaces) %layerBackground = %tileMap.getTileLayer(0); %layerBackground.setImmovable(); %layerBackground.setCollisionActive(false, true); %layerBackground.setGroup($backgroundGroup); %layerBackground.setLayer($backgroundLayer); %layerBackground.setCollisionMasks(BIT($playerGroup), BIT($playerLayer)); %layerBackground.setPosition("0 0"); //Load the second layer (Platforms, in a separate layer so we can make them one way passable) %layerPlatform = %tileMap.getTileLayer(1); %layerPlatform.setImmovable(); %layerPlatform.setCollisionActive(false, true); %layerPlatform.setGroup($platformGroup); %layerPlatform.setLayer($platformLayer); %layerPlatform.setCollisionMasks(BIT($playerGroup), BIT($playerLayer)); %layerPlatform.setPosition("0 0"); // layer.getArea() not available in 1.0.2, use long way until 1.1 released // $camera.setLimits(%layerBackground.getArea(), true); %tileCount = %layerBackground.getTileCount(); %tileSize = %layerBackground.getTileSize(); %SizeX = getWord(%tileCount,0) * getWord(%tileSize,0); %SizeY = getWord(%tileCount,1) * getWord(%tileSize,1); $camera.setLimits( "-" @%SizeX/2 SPC "-" @ %SizeY/2 SPC %SizeX/2 SPC %SizeY/2, true); }