Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: CTxCB on Tue 10/05/2011 13:46:18

Title: Hotspots and buttons
Post by: CTxCB on Tue 10/05/2011 13:46:18
I'd like to know how do I make it so when the mouse goes over my button on a GUI it changes the pointer to a different one, so when it is not on the button, it is a boned hand shaking to say "no" and if you are on the button, it has an eyeball, much like 7th guest and 11th hour...
Title: Re: Hotspots and buttons
Post by: Khris on Tue 10/05/2011 15:04:27
You can check for GUI elements under the mouse using GUIControl.GetAtScreenXY(int x, int y) (http://www.adventuregamestudio.co.uk/manual/GUIControl.GetAtScreenXY.htm):

// inside repeatedly_execute

  GUIControl*gc =  GUIControl.GetAtScreenXY(mouse.x, mouse.y);
  Button*b = gc.AsButton;  // if gc is a button, b points to it, otherwise b is null
  GUI*g = GUI.GetAtScreenXY(mouse.x, mouse.y);  // over which GUI is the mouse?

  if (g == gMyGUI) {  // mouse over gMyGUI
    if (b == null && mouse.Mode != eModeNo) mouse.Mode = eModeNo;
    else if (b != null && mouse.Mode != eModeEyeball) mouse.Mode = eModeEyeball;
  }
  else {    // mouse not over gMyGUI
   
    ...
  }


All that's left to do is setup the mouse cursors with their respective views i.e. a view whose first loop contains the cursor animation.