// the user needs to move the mouse for at least this many pixels
// to consider it dragging
var minDragDistance = 20;
global g_IsDragging = false;
var origPos;
////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
// initiate the dragging
g_IsDragging = true;
}
////////////////////////////////////////////////////////////////////////////////
on "LeftRelease"
{
if (!g_IsDragging) return;
g_IsDragging = false;
// check if we moved the mouse enough to consider it dragging
{
HandleEndDrag();
}
else
{
HandleLeftCLick();
}
}
////////////////////////////////////////////////////////////////////////////////
function HandleLeftClick()
{
// the user just clicked
// this function would contain the same code which the on "LeftClick" handler contains
// in the standard game.script
// ...
}
////////////////////////////////////////////////////////////////////////////////
function HandleEndDrag()
{
// this is called if the user dragged the mouse for at least
// 'minDragDistance' pixels
// get the actual selection rectangle
var left, right, top, bottom;
{
}
else
{
}
{
}
else
{
}
// now you can check if the actor is within the rectangle...somehow
// we'll just test its position for now
if (actor.
X >= left && actor.
X <= right && actor.
Y >= top && actor.
Y <= bottom
) {
// select the actor (change the color to red)
}
else
{
// deselect the actor (change the color back to normal)
}
}