Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Alaskaban on Tue 16/07/2013 03:06:43

Title: Moving off of Hot spots
Post by: Alaskaban on Tue 16/07/2013 03:06:43
Hello, I was wondering if there was any command to do something when the mouse moves off a hotspot.
Title: Re: Moving off of Hot spots
Post by: ThreeOhFour on Tue 16/07/2013 08:46:57
This should do it (in GlobalScript.asc - if you've more than one room you'll have to do it in the room script).

Code (AGS) Select

int onHotspot = 0;

function repeatedly_execute()
{
  Hotspot *mouseHotspot = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  if (onHotspot != mouseHotspot.ID)
  {
    if (onHotspot == 4) //the number of the hotspot you want to use
    Display("Do thing here");
  }
  onHotspot = mouseHotspot.ID;
}
Title: Re: Moving off of Hot spots
Post by: Kitai on Tue 16/07/2013 09:42:16
Given hotpost[0] mean no hotspot, your code might fire an event when the user moves the mouse over any hotspot from a hotspot-free area. To prevent this, you could add a condition on onHotspot being greater that 0.
Title: Re: Moving off of Hot spots
Post by: Khris on Tue 16/07/2013 09:55:18
If this is about moving off a specific hotspot, Ben's code will do just fine.
If it is about moving the mouse outside any active area, there are other ways to achieve the desired result, even without code.
Mouse cursors can be set to animate only over hotspots, for instance.

Alaskaban: If you give us some more friggin' information here, we can show you how to do it best.