Strategy tut & single selections
by John Coyne · in Torque Game Builder · 02/06/2006 (5:49 am) · 5 replies
While i've put the problems i'm having with the tutorial on the back burner I had a stab at impoving the selection code such that you dont have to drag anymore, a single click will work if you only want to pick one thing.
At the top of getSelections in mouse.cs add
%posX = getWord(%pos, 0);
%posY = getWord(%pos, 1);
%posA = getWord($selectionBox::corner, 0);
%posB = getWord($selectionBox::corner, 1);
if(%posX == %posA)
{
%posX++;
}
if(%posY == %posB)
{
%posY++;
}
and change this line
%objList = $strategyScene.pickRect($selectionBox::corner, %pos);
to
%objList = $strategyScene.pickRect(%posA, %posB, %posX, %posY);
Now you can select a single thing by clicking it instead of dragging all the time. Dont blame me if it falls apart though :)
At the top of getSelections in mouse.cs add
%posX = getWord(%pos, 0);
%posY = getWord(%pos, 1);
%posA = getWord($selectionBox::corner, 0);
%posB = getWord($selectionBox::corner, 1);
if(%posX == %posA)
{
%posX++;
}
if(%posY == %posB)
{
%posY++;
}
and change this line
%objList = $strategyScene.pickRect($selectionBox::corner, %pos);
to
%objList = $strategyScene.pickRect(%posA, %posB, %posX, %posY);
Now you can select a single thing by clicking it instead of dragging all the time. Dont blame me if it falls apart though :)
About the author
#2
Btw thx for posting this John, I did consider adding the funcitonality to do both the rect pick and a pickPoint so you can single click select as well but I just ran out of time (spent a good couple weeks on this tutorial, wanted to make it good :) though this solution seems to work as well, thanks for sharing it with everyone.
02/16/2006 (10:34 am)
He is talking about the Strategy Genre Tutorial :) Btw thx for posting this John, I did consider adding the funcitonality to do both the rect pick and a pickPoint so you can single click select as well but I just ran out of time (spent a good couple weeks on this tutorial, wanted to make it good :) though this solution seems to work as well, thanks for sharing it with everyone.
#3
02/16/2006 (10:35 am)
Is this getting added to the TDN article?
#4
02/16/2006 (11:42 am)
Thats the beauty of TDN being a wiki, anyone can modify and add to it :) Just be certain you've tested what you add to prevent future problems.
#5
02/16/2006 (4:13 pm)
Neat, i'll look into adding this early/mid next week. Do I just put a side note at the relevant position?
Torque Owner Chris Labombard
Premium Preferred
The 3 mouse selection tutorials I've seen didn't involve having to drag the mouse to select.