Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Mon 02/02/2004 14:41:58

Title: Displaying Hotspot Names [Solved]
Post by: on Mon 02/02/2004 14:41:58
I'm sorry if this has been answered hundreds of times, but I couldn't find it on the search feature...maybe I'm looking in the wrong section.
Basically, I have written a function to display the name of hotspots and objects in a text window on the Gui bar at the top, but how to I get the name to appear by the cursor like on most other games - I think it looks much better.
I tried text overlays, but I kept loosing my overlay ID somewhere between the global and room scripts...I've only been doing this a few days.
Thanks.
Title: Re:Displaying Hotspot Names
Post by: Darth Mandarb on Mon 02/02/2004 16:49:58
I do this:

I have a GUI created specially for this.  (GUI 6)

I have a text lable in that GUI (object 0)

When a HOTSPOT is clicked on I run script;
SetGUIPosition(6,mouse.x,(mouse.y-10)); // places GUI(6) 10 pixels above mouse position
SetLabelText(6,0,"HOTSPOT DESCRIPTION");
GUIOn(6);


Works like a charm (unless the hotspot sits too close the screen edge in which case I do something like this:
SetGUIPosition(6,(mouse.x-100),(mouse.y-10));
SetLabelText(6,0,"HOTSPOT DESCRIPTION");
GUIOn(6);


This offsets it on the x axis so the whole description is on the screen.  Depending on the length of the description the offset would change.  100 is just a number I entered ... you'll have to tweek it to get the number you need!

Hope that's what you're looking for!

Also,  I surround ALL hotspots with 1 ecompassing hotspot (save at least 1) which shuts the GUI off.  This way, when your mouse is no longer over the specific hotspot the label goes away.
Title: Re:Displaying Hotspot Names
Post by: strazer on Mon 02/02/2004 16:59:19
I suggest creating a transparent GUI (background color 0), put a label on it and set the label text to "@OVERHOTSPOT@" (without quotes).
Then in the "repeatedly_execute" function of the global script, put

SetGUIPosition(YOURGUINUMBERHERE,mouse.x,mouse.y);

Move the label on the gui until it's as far away from the cursor as you like. That's it.

While the encompassing hotspot is a good workaround, I think this is better. It's what I use anyway.
Title: Re:Displaying Hotspot Names
Post by: Dorcan on Mon 02/02/2004 17:05:01
Good idea, but maybe not as easy it could be.

A simpler way would be to create as Darth said, a transparent GUI  with a label text inside.
Change the text to "@OVERHOTSPOT@".

The description GUI will be placed at the bottom right corner of the cursor position (which is smaller than 20x20 pix in this exemple)

So, in the global script, inside the repeatedly_execute() function, past the following code :

int x = mouse.x+20;
int y = mouse.y+20;
if (x - GUIWIDTH > 320) x = 320-GUIWIDTH;
if (y - GUIHEIGHT > 200) y = 200-GUIHEIGHT;

SetGUIPosition (GUIDESCRIPTION, x, y)


With this code, the description GUI will never get out of the screen bounds

I hope this code will work, I haven't tested it yet.
Title: Re:Displaying Hotspot Names [Solved]
Post by: on Tue 03/02/2004 10:02:01
Thanks!
That worked really well, and much simpler than my other coding!

Title: Re:Displaying Hotspot Names [Solved]
Post by: BOYD1981 on Fri 27/02/2004 01:17:31
not adding anything to this post, just suggesting that it gets moved to the Technical Archive forum, somebody just asked this question in #ags and i had to go through 6 pages before i found it, seems to be quite a common question too...
Title: Re:Displaying Hotspot Names [Solved]
Post by: Gilbert on Fri 27/02/2004 02:54:42
Quote from: BOYD1981 on Fri 27/02/2004 01:17:31
not adding anything to this post, just suggesting that it gets moved to the Technical Archive forum, somebody just asked this question in #ags and i had to go through 6 pages before i found it, seems to be quite a common question too...
I don't think so, maybe add to this (http://www.agsforums.com/yabb/index.php?board=6;action=display;threadid=11497) post.