Game Development Community


#1
03/26/2005 (2:47 pm)
Later I think I will write up a tutorial on a couple ways for moving things with the mouse ( if I get the energy/time I'll do it tonight) , but with mouse selection I use this

function sceneWindow2D::onMouseDown( %this, %mod, %worldPos, %mouseClicks )
{
	echo("mouse Down");
	if($mouseObj::follow $= "true")
	{
		%objList = t2dSceneGraph.pickPoint(%worldPos);
		//%objToSel = (getWordCount(%objList) - 1);
		%objToSel = 0;
		%obj = getWord(%objList, %objToSelect);
		if(isObject(%obj))
		{	
			if(%obj != $mouseObj::object)
			{
				if($debugMsg)	
					echo("echo attempting to mount:" SPC %obj SPC " to mouse obj:" SPC $mouseObj::object);
				%obj.mount($mouseObj::object, $mouseObj::mount::offset, $mouseObj::mount::force, $mouseObj::mount::trackRotation);
				$mouseObj::isObjMounted = "true";
				$mouseObj::objMounted = %obj;
			} else
			{
				if($debugMsg)
					echo("object is the mouse obj");
			}
		}
	}
}


minus the mounting and extra junk that would be this...

function sceneWindow2D::onMouseDown( %this, %mod, %worldPos, %mouseClicks )
{
	echo("mouse Down");
	%objList = t2dSceneGraph.pickPoint(%worldPos);
	//the next line makes it select the last object on the list
	//%objToSel = (getWordCount(%objList) - 1); 
	//this next line makes it select the first object on the list
	%objToSel = 0;
	%obj = getWord(%objList, %objToSelect);
	if(isObject(%obj))
	{	
		//If its an object then do this...
	}
}