OnMouseEnter() Issue
by David Taylor · in Torque Game Builder · 12/30/2006 (2:37 am) · 2 replies
I have a grid, (a tilemap), of 100 squares, ten rows of ten. I'd like to have code that detects when the mouse cursor enters each grid space. I set up 100 triggers, and gave them the class name boardGrid.
The getName() is called 100 times, but the onMouseEnter doesn't get called. What am I missing here? Are triggers the right way to do this?
function BoardGrid::onLevelLoaded(%this, %scenegraph)
{
echo(%this.getName());
}
function BoardGrid::onMouseEnter(%this, %modifier, %worldPosition, %clicks)
{
echo("Mouse has entered!");
}The getName() is called 100 times, but the onMouseEnter doesn't get called. What am I missing here? Are triggers the right way to do this?
About the author
#2
Now both echo lines are being echoed. Cheers. =)
12/30/2006 (5:03 am)
I'm using 1.1.3. I've had a play around, and it works on sprites, but not triggers. The object that the mouse is entering has to be a t2dSceneObject, which seems to explain why the triggers weren't working.function BoardGrid::onLevelLoaded(%this, %scenegraph)
{
echo(%this.getName());
%this.setUseMouseEvents(true);
}
function BoardGrid::onMouseEnter(%this, %modifier, %worldPosition, %clicks)
{
echo("Mouse has entered!");
}Now both echo lines are being echoed. Cheers. =)
Torque Owner Very Interactive Person
This wasn't working for me either... so I did something like this:
sceneWindow2D.setUseObjectMouseEvents( true ); function sceneWindow2D::onMouseMove(%this, %modifier, %worldPosition, %mouseClicks){ [start pseudo code] use world position to check which sprites have the mouse over them if that sprite has mouseOverflag set to true, do nothing, else call mouseEnter and set a mouseOver flag to true check all other sprites, if the mouseOver flag is true, set it to false, and call mouseLeave function of that sprite, else do nothing [/end pseudo code] }Sorry, don't have time to write the actual code, and my own code has too much other stuff in it, so I just described what i'm doing.
I know its not a nice way to do it... I just did it that way becuase with the version I use onMouseEnter doesn't work on sprites. But like I said, i heard that's fixedd/added in the latest version