Game Development Community

ObjectSelectionTut1

by Eric Schwegler · in Torque Game Builder · 08/08/2006 (10:03 am) · 2 replies

This isn't working for me... what am I doing wrong?

I made a Tile with a Name attached to in the LevelBuilder

I named the SceneGraph t2dScene

I added the following code to simpleMouse.cs and let it be executed in game.cs :


function sceneWindow2D::onMouseMove( %this, %mod, %worldPos, %mouseClicks )
{
// if($debugMsg::mouse::callBacks)
echo("Mouse Moving");

%this.mousePos = %worldPos;
}

function sceneWindow2D::onMouseDragged( %this, %mod, %worldPos, %mouseClicks )
{
// if($debugMsg::mouse::callBacks)
echo("Mouse Dragging");

%this.mousePos = %worldPos;
}

function sceneWindow2D::onMouseDown( %this, %mod, %worldPos, %mouseClicks )
{
// if($debugMsg::mouse::callBacks)
echo("Mouse Down");

%objList = t2dScene.pickPoint(%worldPos);
%objCount = getWordCount(%objList);

for(%i=0;%i<%objCount;%i++)
{
%obj = getWord(%objList, %i);

if(%obj.isSelectable)
{
%selected = true;
%i = %objCount;
}
}

if(%selected)
{
%this.selectedObj = %obj;

if($debugMsg::mouse::selection)
echo("You have selected:" SPC %obj SPC "with the name:" SPC %obj.objectName);
}
}


function sceneWindow2D::onMouseUp( %this, %mod, %worldPos, %mouseClicks )
{
// if($debugMsg::mouse::callBacks)
echo("Mouse Up");
}

function sceneWindow2D::onMouseEnter( %this, %mod, %worldPos, %mouseClicks )
{
// if($debugMsg::mouse::callBacks)
echo("Mouse Entered... Knew it would come crawling back");
}

function sceneWindow2D::onMouseLeave( %this, %mod, %worldPos, %mouseClicks )
{
// if($debugMsg::mouse::callBacks)
echo("Mouse Left... Go Get It!");
}

Everything works exept for the pickPoint part... mouse down gets echoed, but it gives me nothing else when i press the Mousebutton... I also have the same problem when I tried to implement pickLine in some other code... What am I missing?

Thx

#1
08/08/2006 (4:12 pm)
Try changing

%objList = t2dScene.pickPoint(%worldPos);

to

%objList = SceneWindow2D.getSceneGraph().pickPoint(%worldPos);

The tutorial was created back when a default scenegraph was called "t2dScene" now you can simply get it by grabbing it off of the Scene Window :)
#2
08/09/2006 (10:23 am)
-----