moving hover text

Started by Sam., Sun 21/12/2003 19:13:38

Previous topic - Next topic

Sam.

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? :-\
Bye bye thankyou I love you.

Pumaman

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);

Sam.

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?
Bye bye thankyou I love you.

Alynn

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

SMF spam blocked by CleanTalk