Mouse pos
by Gavin Beard · in Torque Game Builder · 03/10/2005 (11:43 pm) · 14 replies
Hiya, i'm trying to return the tile below the mouse pointer when i click.
i'm using
function sceneWindow2D::onMouseDown( %This, %Modifier, %WorldPosition, %MouseClicks )
{
echo($baseMap.getTile(%WorldPosition));
}
which returns nothing, lookin in the console its the %worldPosition returning nothing, my mouse is enabled if if a echo something else when i click its ok, is there summin i'm missing?
cheers
i'm using
function sceneWindow2D::onMouseDown( %This, %Modifier, %WorldPosition, %MouseClicks )
{
echo($baseMap.getTile(%WorldPosition));
}
which returns nothing, lookin in the console its the %worldPosition returning nothing, my mouse is enabled if if a echo something else when i click its ok, is there summin i'm missing?
cheers
#2
and if i just echo %WorldPostion its blank :(
03/11/2005 (12:21 am)
But my main prob is that %WorldPositon doesnt seem to contain n e thing. i get error - unable to find object '' calling function 'pickTile'and if i just echo %WorldPostion its blank :(
#3
Your error-message is saying that it doesn't know what "$baseMap" is. "unable to find object calling function 'pickTile'"
Also, be careful, "pickTile()" is a function of a layer, not a map.
- Melv.
03/11/2005 (12:36 am)
Gavin,Your error-message is saying that it doesn't know what "$baseMap" is. "unable to find object calling function 'pickTile'"
Also, be careful, "pickTile()" is a function of a layer, not a map.
- Melv.
#4
03/11/2005 (12:47 am)
%baseMap is layer 0 of a map containing two layers, n e idea why it may be giving this error?
#5
Does the following code echo "VALID!"? (assuming you're using $baseMap).
- Melv.
03/11/2005 (2:05 am)
Is it "%baseMap" or "$baseMap"?Does the following code echo "VALID!"? (assuming you're using $baseMap).
if ( isObject($baseMap) ) echo("VALID!");- Melv.
#6
i'll try that echo when i get near my home puter
03/11/2005 (7:53 am)
Sorry its %baseMap, should it be % or $??i'll try that echo when i get near my home puter
#7
If you're accessing it outside of a specific function then it should be global "$" as "%" means local.
Is this what you meant?
- Melv.
03/11/2005 (9:35 am)
Gavin,If you're accessing it outside of a specific function then it should be global "$" as "%" means local.
Is this what you meant?
- Melv.
#8
03/11/2005 (10:53 am)
Yeah thats right, i am using the rigt type, i'll try the other thing suggested when i get home :)
#9
and i run the if ( isObject($baseMap) ) echo("VALID!"); and get VALID!
if i change it back to echo($baseMap.pickTile(%WorldPosition); i get a return of
unknown command PickTile.
object t2dSceneGraph(1232) fxSceneGraph2D -> simObject
03/12/2005 (12:11 am)
Ok, so i changed all the % and $'s around so they were correct (which strangely makes my map appear in a differnt place but hey)and i run the if ( isObject($baseMap) ) echo("VALID!"); and get VALID!
if i change it back to echo($baseMap.pickTile(%WorldPosition); i get a return of
unknown command PickTile.
object t2dSceneGraph(1232) fxSceneGraph2D -> simObject
#11
i'll try that when i get home monday. wish i'd brought my laptop now :'(
what kinda output does that give then?
03/12/2005 (2:04 am)
No i havent :) i'll try that when i get home monday. wish i'd brought my laptop now :'(
what kinda output does that give then?
#12
in a file i have called functions.cs i just have this procedure
function loadMap(%level)
{
$tMap = new fxTileMap2D() { scenegraph = t2dSceneGraph; };
$tMap.loadTileMap("~/client/maps/" @ %level);
$baseMap = %tMap.getTileLayer( 0 );
$baseMap.setPosition( "-8 -1.5");
$baseMap.setTileSize( "4.17 4.17");
$secMap = %tMap.getTileLayer( 1 );
$secMap.setPosition( "-8 -1.5" );
%secMap.setTileSize( "4.17 4.17" );
}
then call the function in client.cs, if i do the dump there are lots of functions but no picktile
03/14/2005 (8:32 am)
Ok so now i'm home i've done the $baseMap.dump(); and the pickTile() function is not listed :'(in a file i have called functions.cs i just have this procedure
function loadMap(%level)
{
$tMap = new fxTileMap2D() { scenegraph = t2dSceneGraph; };
$tMap.loadTileMap("~/client/maps/" @ %level);
$baseMap = %tMap.getTileLayer( 0 );
$baseMap.setPosition( "-8 -1.5");
$baseMap.setTileSize( "4.17 4.17");
$secMap = %tMap.getTileLayer( 1 );
$secMap.setPosition( "-8 -1.5" );
%secMap.setTileSize( "4.17 4.17" );
}
then call the function in client.cs, if i do the dump there are lots of functions but no picktile
#13
Are you getting any errors in the console?
- Melv.
03/14/2005 (10:04 am)
You seem to not have changed all the "%" for "$" in your example above.Are you getting any errors in the console?
- Melv.
#14
03/14/2005 (10:13 am)
Hehe, seems u r right, its coz i didnt change %tMap.getTileLayer( 0 ); to $tMap.getTileLayer( 0 ); but i thought as it was only used within that function it didnt need to be global but it does. no it seems to return a grid refernce, i dont suppose there is a way of grabbing what cell from the image i use for tiles is actually used at that location :D
Torque Owner Matt Harpold