Something like the Game.GetLocationName function for a buttons and GUI elements

Started by Feijotikus, Wed 08/08/2012 19:09:18

Previous topic - Next topic

Feijotikus

I hope that there is not an obvious answer to that but if there is, I will ask for a tutorial for finding things at the tutorial :D

Well, my character has some different superpowers, and I made a GUI for select them. I use the Game.GetLocationName function to Overlay at the bottom of the screen the name of the objects and hospots where the mouse is, and I would like to Overlay the name of the superpower buttons too. Accordind the manual:

http://www.adventuregamestudio.co.uk/wiki/?title=Game_/_Global_functions#Game.GetLocationName

"If the co-ordinates are on a GUI, a blank string is returned" and nothing is overlayed when the mouse is in the buttons.

At the beggining I searched the coordinates of the buttons manually, but now, for better aesthetics I made that the GUI apears at different places depending of the position of the character, so now, calculate the position of the buttons is quite more harder. It's possible, knowing the actual position of the GUI, the height and the width..., but it's harder so first I prefer to ask if there is any other obvious way that I coudn't see :S

Crimson Wizard

If I understand correctly what you want to do, you may use GUI.GetAtScreenXY and GUIControl.GetAtScreenXY like:
Code: ags

GUI *found_gui = GUI.GetAtScreenXY(mouse.x,mouse.y);
if (found_gui != null)
{
   // hey, there's a gui under mouse!
}



Quote from: FeijotikusI hope that there is not an obvious answer to that but if there is, I will ask for a tutorial for finding things at the tutorial
Well, rule number one, don't look into tutorial, but rather in the manual. :)
If you meant "manual", since you are looking to work with GUIs, seek for GUI and GUIControl items in the manual's index (also GUIButton, GUILabel etc).

Feijotikus

I ment the manual, but I used "tutorial" for could make the stupid joke "a tutorial of the tutorial"

By the way, it have worked very well, thanks!

SMF spam blocked by CleanTalk