Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Sam. on Sun 21/12/2003 19:13:38

Title: moving hover text
Post by: Sam. on Sun 21/12/2003 19:13:38
okay.. i just downloaded a GUI called Space GUI just  to see what it was and if i liked any elements. there was one bit i really liked. i know how to use the
@gameoverhotspot@ tool so that a text label shows the name of a hotspot. what i want is that it follows the mouse around so like, the text "hovers" over the cursor. anybody help? :-\
Title: Re:moving hover text
Post by: Pumaman on Sun 21/12/2003 19:34:41
Basically, you need to create a transparent GUI with a label on it set to @overhotspot@

Then, in repeatedly_execute, you just move the GUI around by doing something like this:

SetGUIPosition(HOVERTEXT, mouse.x + 10, mouse.y + 10);
Title: Re:moving hover text
Post by: Sam. on Mon 22/12/2003 11:23:15
thats great. it all works fine until i move my mouse to the bottom of the screen and then i get the error message:
error: SetGUIPosition: co-ordinates must lie in range (0,0) - (RMWID,RMHIT)
i was just wondering what it meant and if there was anything i could do about it. my game closes and it is a bit nnoying. is it something i've done?
Title: Re:moving hover text
Post by: Alynn on Mon 22/12/2003 16:33:00
Before you move the GUI check if its X or Y coord is greater than the room with or room with or height if it is then place it  elsewhere:

PsudoCode:
int guiposx = mouse.x+10;
int guiposy = mouse.y+10;
if (guiposx > RoomHeight) {
 if (guiposy > RoomWidth) {
   guiposx = mouse.x-10;
   guiposy = mouse.y-10;
 }
 else {
   guiposx = mouse.x-10;
 }
else if (guiposy > RoomWidth) {
 guiposy = mouse.y-10;
}
SetGUIPosition(HOVERTEXT, guiposx, guiposy);

See how that works for you. You only need to check if its greater than if you are using the example someone showed you earlier because it will never be less than 0, 0 because you are doing a +10 to both