Game Development Community

Problem loading my own tiles

by Darren Stuart · in Torque Game Builder · 04/26/2005 (2:16 am) · 11 replies

Hi Guys,

I am having a problem loading images into the tile editor.

my tiles do not show up in the image list and I can't find any reference to loading images in. I have my images in the images folder. my background image has replaced the gg one but the tiles are not loading. all the files are png format.

please help ;)

#1
04/26/2005 (2:22 am)
Ah its ok I was being dumb didn't realise you needed to load them in.

I need a tutorial on using this thing.
#2
04/26/2005 (2:38 am)
The space shooter tut goes over this a little bit. Also, the other set of links that I put on the other thread cover some stuff like this too
#3
04/26/2005 (3:05 am)
Cool I'll take a lok.

I have the problem now of the map not loading in.

I ripped what I thought was the map loading code from the space shooter but its not working.

can someone tell me where I have gone wrong? when I load the map editor its not in there either and I thought it would have been. the map to the file is correct.


// --------------------------------------------------------------------
// Setup T2D Scene.
// --------------------------------------------------------------------
function setupT2DScene()
{
// Create fxSceneGraph2D.
new fxSceneGraph2D(t2dSceneGraph);

// Associate Scenegraph with Window.
sceneWindow2D.setSceneGraph( t2dSceneGraph );

// Set Camera Position to be centered on (0,0) with
// view width/height of (100/80).
sceneWindow2D.setCurrentCameraPosition( "0 0 100 75" );


// ************************************************************************
//
// Add your custom code here...
//
// ************************************************************************



// *******************************************************
// Create Tile-Map Scroller.
// *******************************************************
%scrollerMap = new fxTileMap2D() { scenegraph = t2dSceneGraph; };


}

// Load Tile-Map.

%scrollerMap.loadTileMap("~/client/maps/test.map");

// Reference Layers.
%skyLayer = %scrollerMap.getTileLayer( 0 );


// *******************************************************
// Generate Scrolling Sky
// *******************************************************
%skyLayer.setPosition( "0 -10" );
%skyLayer.setSize( "140 60" );
%skyLayer.setLayer( 31 );
%skyLayer.setWrap( true, false );
%skyLayer.setAutoPan( "20 0" );
#4
04/26/2005 (3:15 am)
Do you get any erros in your console.log file?
#5
04/26/2005 (3:18 am)
Did you take the .map file from the spaceshooter/map folder and put in your project/client/map folder. Which doesn't exist until you create it.


Another thing to mention. When using the map editor, it will save the map to the map gui folder. And if you want to open a map file, you need to copy whatever .map file you have to the map gui folder.

Then, when you want to load the map in your game, you need to copy it back to your t2d/client/map folder.

I don't know if they fixed this in 1_0_2 or not though.
#6
04/26/2005 (3:21 am)
In that link that I gave you, there is a datablock creator. use that tool and it will create a .cs file that will contain all of your datablocks.

Then in the client.cs file find the last exec() command and bellow it ad

Exec(./whateverthenameofyournewimagedatablockcsfile.cs); to load all the blocks into memory.

Or make sure you are copying all of the imagemap datablocks from the spaceshooter to your client.cs
#7
04/26/2005 (3:28 am)
Check that closing curly brace just above Load-Tilemap, shouldn't it be at the end of your code below setAutoPan?

btw when posting code snippets, if you use the [ code ] and [ /code ] blocks (but without the spaces) it will keep the formatting of your code.
#8
04/26/2005 (3:30 am)
Yeah your code is a bit garbled. it should probably look like this:

// --------------------------------------------------------------------
// Setup T2D Scene.
// --------------------------------------------------------------------
function setupT2DScene()
{
// Create fxSceneGraph2D.
new fxSceneGraph2D(t2dSceneGraph);

// Associate Scenegraph with Window.
sceneWindow2D.setSceneGraph( t2dSceneGraph );

// Set Camera Position to be centered on (0,0) with
// view width/height of (100/80).
sceneWindow2D.setCurrentCameraPosition( "0 0 100 75" );


// ************************************************************************
//
// Add your custom code here...
//
// ************************************************************************



// *******************************************************
// Create Tile-Map Scroller.
// *******************************************************
%scrollerMap = new fxTileMap2D() { scenegraph = t2dSceneGraph; };


// Load Tile-Map.

%scrollerMap.loadTileMap("~/client/maps/test.map");

// Reference Layers.
%skyLayer = %scrollerMap.getTileLayer( 0 );


// *******************************************************
// Generate Scrolling Sky
// *******************************************************
%skyLayer.setPosition( "0 -10" ); 
%skyLayer.setSize( "140 60" );
%skyLayer.setLayer( 31 );
%skyLayer.setWrap( true, false );
%skyLayer.setAutoPan( "20 0" );
}

With the } right after %scrollerMap = new fxTileMap2D() { scenegraph = t2dSceneGraph; }; being removed
#9
04/26/2005 (3:37 am)
www.garagegames.com/mg/forums/result.thread.php?qt=28302 That is where you can find the datablock tool
#10
04/26/2005 (3:43 am)
Thanks guys. its still not loading in.

the map was created using the tile editor and then saved and moved to my maps folder.(its fixed so you can save it where you want now).

I have tried the code posted and thats not playing ball either.

I have sorted loading the images maps in so they will work with the tile editor so I shouldn't have to load them again should I?

thanks for the tip for posting code :D

P.S what link m8?
#11
04/26/2005 (3:44 am)
Aha we posted at the same time.