Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: I<3Pindorama! on Sat 27/12/2014 10:38:42

Title: Show a TEXT in the screen when the CURSOR is over an element [disSOLVED]
Post by: I<3Pindorama! on Sat 27/12/2014 10:38:42
I've been looking for a way to put a description appearing on the screen
when the mouse cursor is over an element (hotspot / object)...

(http://i.imgur.com/A6Gkzak.png)

... but it seems that some things have changed over the versions
I ended up somewhat confusing that or maybe i have not been
able to understand their construction..

Could someone explain me or indicate a "step by step" of how to do it?

I created a new Gui and put a label on it ... but I am lost as to what to do now.

Thanks for your help!

;)

Title: Re: Show a TEXT in the screen when the CURSOR is over an element
Post by: Slasher on Sat 27/12/2014 11:05:47
Hi

You could check out the FloatingHotspot module which positions a description of the item mouse is over.

Else you could set your gui to appear approx  x, y of each object  / hotspot mouse is over.

Or you could set this when over  each object  / hotspot mouse is over:

gYOURGUI.SetPosition(mouse.x, mouse.y);
set gYOURGUI to visible.

Of course you will need to make sure you make it invisible when off object / hotspot.

Something like that...


Title: Re: Show a TEXT in the screen when the CURSOR is over an element
Post by: monkey0506 on Sat 27/12/2014 11:45:22
If the text should just stay in one spot and show what the mouse is over, the simplest way of doing it is to create a GUI (Visibility: Normal, initially on) and put a GUI Label control on it. Then set the label text to @OVERHOTSPOT@. If you need something more complex (adding verbs, etc.) then it will be a bit more complicated, but it's still pretty simple:

Code (ags) Select
// GlobalScript.asc

function repeatedly_execute() // should already exist, add it if not
{
  // executes commands repeatedly, once per game loop, only during non-blocking events
  String location = Game.GetLocationName(mouse.x, mouse.y);
  if (location == null) location = "";
  String verb = "";
  if (mouse.Mode == eModeWalkto) verb = "Walk to";
  else if (mouse.Mode == eModeLookat) verb = "Look at";
  // ...
  else if (mouse.Mode == eModeInteract) verb = "Use";
  lblLocation.Text = String.Format("%s %s", verb, location);
}
Title: Re: Show a TEXT in the screen when the CURSOR is over an element
Post by: I<3Pindorama! on Sat 27/12/2014 13:44:40
My friend Slasher and my friend Monkey_05_06...
Very - very - very...
(http://i.imgur.com/hxKJpWW.gif)

The game is walking!
Title: Re: Show a TEXT in the screen when the CURSOR is over an element
Post by: monkey0506 on Sat 27/12/2014 14:19:45
Well as particularly terrifying as that all looks (especially as an animated GIF), I'm glad that you got it sorted out. ;)