Topic: SetActiveTile - active tiles and co-ords in TGB some Q's
by Damian · in Torque Game Builder · 04/11/2006 (7:07 am) · 3 replies
Hi all,
have worked through many tutorials and seen some posts, but I need more help ...
regarding parameters...
//%tileObj = %obj.setActiveTile( 0 0, myActiveTileClass, myActiveTileDatablock )
1) how do I determine the location of a tile do I use pickTile(xy) ? what is the xy .. tiles can cover more than one co-ordinate? or some type of %worldPos call and then associate the object. (actually pickPoint is better)
2) Same xy Q regarding setActive tile ...
3) How do I create a tile class ?
4) So I would like a better (full) script example than the one provided on other posts (if you would be kind enough)
Also I guess what I really want is a mouseover event to show info ... so want to test with active tiles ... and see if I can modify some things.
Sorry might seem easy to some, but am learning fast and have a prototype game working after buying 2 weeks ago ... just want to improve...
Making a turn based / real time game based (make decisions and then it runs until time / action break --> eventually port to 3D engine) on the Pacific war (I know there are some great games out there using this but none which will network or can show 3d action)... and I will eventually hope to post some tutorials of my own for newbies... about what I have learned.
Thanks Damian
have worked through many tutorials and seen some posts, but I need more help ...
regarding parameters...
//%tileObj = %obj.setActiveTile( 0 0, myActiveTileClass, myActiveTileDatablock )
1) how do I determine the location of a tile do I use pickTile(xy) ? what is the xy .. tiles can cover more than one co-ordinate? or some type of %worldPos call and then associate the object. (actually pickPoint is better)
2) Same xy Q regarding setActive tile ...
3) How do I create a tile class ?
4) So I would like a better (full) script example than the one provided on other posts (if you would be kind enough)
Also I guess what I really want is a mouseover event to show info ... so want to test with active tiles ... and see if I can modify some things.
Sorry might seem easy to some, but am learning fast and have a prototype game working after buying 2 weeks ago ... just want to improve...
Making a turn based / real time game based (make decisions and then it runs until time / action break --> eventually port to 3D engine) on the Pacific war (I know there are some great games out there using this but none which will network or can show 3d action)... and I will eventually hope to post some tutorials of my own for newbies... about what I have learned.
Thanks Damian
Torque Owner Michael Woerister
// use t2dTileLayers::onMouseDown callback. Even better would be to create some map-class function t2dTileLayer::onMouseDown( %this, %modifier, %worldPosition, %mouseClicks ) { // determine the tile that lies under this world pos %logicalTilePos = %this.pickTile( getWord( %worldPosition,0 ), getWord( %worldPosition, 1 ) ); // create the active tile at this tile position %this.setActiveTile( getWord( %logicalTilePos, 0), getWord( %logicalTilePos,1), $ActiveTileClass, $ActiveTileDatablock ); }Oh, just read this part:
Active tile classes can only be created in C++ but maybe active tiles are more than you need. What kind of info do you need? Maybe the tiles custom data is sufficient. That would then look about like this:
function t2dTileLayer::onMouseMove( %this, %modifier, %worldPosition, %mouseClicks ) { // determine the tile that lies under this world pos %logicalTilePos = %this.pickTile( getWord( %worldPosition,0 ), getWord( %worldPosition, 1 ) ); // create the active tile at this tile position %customDataString = %this.getTileCustomData( getWord( %logicalTilePos, 0), getWord( %logicalTilePos,1) ); // do something with it showInfo( %customDataString ); }Be sure to enable mouse events for your tile-layer with setUseMouseEvents(true);
-Michael