Show a TEXT in the screen when the CURSOR is over an element [disSOLVED]

Started by I<3Pindorama!, Sat 27/12/2014 10:38:42

Previous topic - Next topic

I<3Pindorama!

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



... 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!

;)


Slasher

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...



monkey0506

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

I<3Pindorama!

My friend Slasher and my friend Monkey_05_06...
Very - very - very...


The game is walking!

monkey0506

Well as particularly terrifying as that all looks (especially as an animated GIF), I'm glad that you got it sorted out. ;)

SMF spam blocked by CleanTalk