MouseOverHotspot question

Started by oskargunn, Mon 15/09/2014 19:58:36

Previous topic - Next topic

oskargunn

Hi,

I'm trying to find a way to see when a mouse cursor is no longer over a hotspot.
I'm using "Mouse moves over hotspot". Is there such a thing as "Mouse is no longer over hotspot ID 1".... ?

Khris

You can use GetLocationType(mouse.x, mouse.y) inside repeatedly_execute.

It would be helpful to know what you're trying to do though. If you want text showing what's under the mouse, do not use that event; stuff like that is always best implemented in a global way. The easiest method is to add a GUI and put a label on it with the text set to "@OVERHOTSPOT@".
AGS will fill in the name of the Hotspot/Object/Character under the mouse.

There are tons of existing threads about this already.

oskargunn

Thanks for the quick reply :)
Someone mentions to use  COLOR_TRANSPARENT in script, since it doesn't seem to be possible to set the transparent color in GUI toolbar. Which property would that be in the script?

Khris

Just set both Background Color and Border Color to 0, that'll make them transparent.

oskargunn

#4
Ah that did the trick :)

I have now a transparent GUI object, with a label. The label updates with the text wherever I go with the mouse over a hotspot/object/character. However the game crashes whenever I move the mouse to the upper edge (icon bar).    Is there perhaps anything specific I need to be careful about?

// This works
function room_RepExec()
{
}


// This crashed the game
function room_RepExec()
{
  GUI* gh = gMouseOverText;
  gh.SetPosition(mouse.x,  mouse.y);   
}

Khris

You're positioning the GUI in the room script but again, you should do it globally; find the repeatedly_execute function in GlobalScript.asc and position the GUI in there.
No need for a pointer you'll only use once btw; you can simply do gMouseOverText.SetPosition(...);

What error message do you get when it crashes?
And again, there are existing threads about this, we're just reinventing the wheel for the twentieth time here. Those threads should contain code where the coordinates are already adjusted to avoid crashes and parts of the text being off-screen.

oskargunn


SMF spam blocked by CleanTalk