Cursor change to Look At over Hotspots

Started by stamatefilip, Sat 16/06/2012 06:41:43

Previous topic - Next topic

stamatefilip

Hi,

I want the cursor to change its graphic to Look At when its over any hotspot.
I put this in the global script in repeatedly_execute:

Code: AGS
if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) != hotspot[0])
    {
    mouse.SaveCursorUntilItLeaves();
    mouse.UseModeGraphic(eModeLookat);
    }


This works fine, however, if I interact or look at a hotspot I make the character walk to it first (with eblock on) but I don't get the wait cursor while the character moves. It just keeps the Walk graphic (or the Look At graphic it it's over the hotspot).
How can I fix that?
And is there another better global way to get the cursor to change over hotspots?

Edit: Oh, and just to be clear. I have set the left mouse button to process "eModeLookAt" if the cursor is over a hotspot and to "eModeWalkto" otherwise. The right mouse button is set to "eModeInteract". So, right now when I have the cursor over a hotspot, the graphic changes to Look At. If I left-click or right-click the appropriate even happens except I don't get the Wait cursor while the character is moving with Character.walk

monkey0506

#1
Well, here I'd typed this entire response, only to realize I'd read the question wrong. I'm guessing that you're actually handling hotspot clicks in on_mouse_click so they're always processed as eModeLookat? Because just to be clear, your current code is only changing the cursor graphic, not the actual cursor mode. I'll assume this is the intended behavior.

Try doing something like this:

Code: ags
function repeatedly_execute()
{
  Hotspot *hat = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  if ((!IsInterfaceEnabled()) || (hat == hotspot[0])) // user interface is disabled, a blocking event is running, OR mouse not over hotspot
  {
    mouse.UseDefaultGraphic();
  }
  else if (hat != hotspot[0])
  {
    //mouse.SaveCursorUntilItLeaves(); // this is used if you're actually changing the mouse.Mode, not just the graphic
    mouse.UseModeGraphic(eModeLookat);
  }
}

stamatefilip

Thanks, but I get almost the same result with your code.
I uploaded the game here (http://www.mediafire.com/download.php?96trhkmb51c4gbh) if you want to give it a look. Try right clicking or left clicking on the note on the wall. You'll see that the Look At graphic remains on while the character is moving, even though eblock is on so the Wait graphic should be displayed.

And yes, the mouse clicks are handled in on_mouse_click. I only mentioned those so it was clear what happens when you click on a hotspot.

Thank you!

monkey0506

Sorry, I meant to change that to repeatedly_execute_always. The normal repeatedly_execute function isn't run during blocking events at all. Sorry I can't get around to testing it just now myself, but I think it should work if you switch to repeatedly_execute_always.

stamatefilip

Hmm, does not work in repeatedly_execute_always either. Same result. And anyway, if I put it like that then if I have a GUI open over the hotspots the cursor will change to Look At when I move it in that location. Even if it's a GUI that pauses the game. I guess that can be fixed with another condition, though, but still no Wait cursor.
Seems like that code is overriding it somehow, because if I remove it I get the Wait cursor.

SMF spam blocked by CleanTalk