Game Development Community

Item Highlight

by GCBeany · in Torque Game Builder · 04/17/2006 (9:39 am) · 4 replies

I'm trying to get an object to highlight when the mouse hovers over it. Here's what my script looks like (Butchered from Tutorials):

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

//store the mouse position
$mouseObj::pos = %worldPos;
//reset stopped to false so it checks
$mouseObj::stopped = false;

//get a list of all the objects at the mouse point in the t2dScene
%objList = t2dScene.pickPoint(%worldPos);
%obj = getWord(%objList, 0);

if (%obj.objectName $= "Blue Button")

$bluebuttonHighlight.setVisible( true );
else
$bluebuttonHighlight.setVisible( false );

}


Everything works great, except that the highlight flickers a lot and is randomly on or off when I don't move the mouse. Is there a better way to get an accurate Object Name? I appreciate any help with this.

About the author

Recent Threads

  • Deployment
  • Help with mouse

  • #1
    04/17/2006 (1:13 pm)
    For the purposes of what you're trying to do, you could just do

    %obj.setVisible(true);
    and
    %obj.setVisible(false);

    assuming bluebuttonHighlight is the same thing as obj. I'm working on a simple puzzle game and set a field in the tiles called chosen. Then I just did %obj.chosen = true and ran a loop later on for any field items labeled true.

    also, you would probably need to do something about toggling the on and off; as the code above stands, it will never actually turn off the blue button. It will turn on if it's blue button and off if it's anything else.

    hope that makes sense.
    #2
    04/19/2006 (7:04 pm)
    Thanks fo the reply.

    Nope. They're different.

    The blue button is an image and the highlight is a circle that goes around the button. So I just need to turn the highlight on and off.

    I haven't solved this problem yet.
    #3
    04/20/2006 (3:43 pm)
    It looks like that if you show the highlight, it is above the blue button. Try this:

    %obj1 = getWord(%objList, 0);
    %obj2 = getWord(%objList, 1);

    if ((%obj1.objectName $= "Blue Button") || (%obj2.objectName $= "Blue Button"))
    #4
    04/20/2006 (5:52 pm)
    That did the trick Pavel! Thanks!