Moving off of Hot spots

Started by Alaskaban, Tue 16/07/2013 03:06:43

Previous topic - Next topic

Alaskaban

Hello, I was wondering if there was any command to do something when the mouse moves off a hotspot.

ThreeOhFour

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

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;
}

Kitai

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.

Khris

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.

SMF spam blocked by CleanTalk