Hotspots and buttons

Started by CTxCB, Tue 10/05/2011 13:46:18

Previous topic - Next topic

CTxCB

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...

Khris

You can check for GUI elements under the mouse using GUIControl.GetAtScreenXY(int x, int y):

Code: ags
 // 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.

SMF spam blocked by CleanTalk