GetHotspotName in textoverlay

Started by proximity, Tue 10/05/2005 16:25:34

Previous topic - Next topic

proximity

i want to get hotspot name at mouse.x and mouse.y.So i did this:
Hotspot-->Mouse moves over hotspot

int over1;
CreateTextoverlay(............);
Wait(1);
RemoveOverlay(1),

The problem is; i don't want textoverlay lost. i just want it appeared when mouse over hotspot and not disappeared.
When i don't use RemoveOverlay command, the game crashes because of exceeding max.number of overlays in screen.Where am i doing wrong?
are there any other ways to show hotspot name at mouse.x,mouse.y?
Proximity Entertainment

Ashen

I think the problem is, you're creating the 'over1' int, but not actually using it to check if the Overlay has been created.
Declare 'over1' at the top of the room script, outside of any other function - if you put it in the 'Mouse over hotspot' interaction it'll be constantly reset, which'll mess up the check.

Then, put this in the 'Mouse over hotspot' interaction:
Code: ags

if (IsOverlayValid (over1) == 0) { // Overlay hasn't been created
  string name;
  GetHotspotName (1, name); // or whatever hotspot number
  over1 = CreateTextOverlay (mouse.x, mouse.y, _, _, _, name); // fill in the blanks
}
else { // optional bit, so overlay follow mouse while it's over the hotspot
  MoveOverlay (over1, mouse.x, mouse.y);
}


You'll probably also want a check in rep_ex, to turn the overlay off when the mouse is no longer at the cursor, something like:
Code: ags

if (IsOverlayValid (over1) && GetHotspotAt (mouse.x, mouse.y) == 0) {
  RemoveOverlay (over1);
}


Another way would be to have a GUI follow the cursor, with a label set to @OVERHOTSPOT@. This has the possible advantage of also working for objects and characters, without any extra scripting.
I know what you're thinking ... Don't think that.

proximity

i think you're right.in my way, i can only highlight hotspot,not objects and characters.@OVERHOTSPOT@ is better but i will mention an old game again:)

in 7 days sceptic, how could he succed to highlight all characters,objects and hotspots in mouse.x,mouse.y? i couldn't solve yatcheez's(creator of game) secret.
Proximity Entertainment

DoorKnobHandle

Wait, where in 7 Days A Skeptic does Yahtzee hightlight any characters, hotspots and objects?

Must've missed that...

Ashen

On mouse over. On just about everything. The cursor changes, and a label pops to with the name of the person/thing.

And I'm fairly certain that's done with a GUI following the mouse, as I said. There are a few threads & tutorials around explaining how to do it, but basicaly you set up the GUI as I said, and put something in repeatedly_execute to move the GUI to follow the mouse (e.g. SetGUIPosition (GUI, mouse.x, mouse.y)). You'll probably also need some checks to make sure the GUI doesn't disappear off the screen - at best, it's annoying and hard to read, at worst it crashes the game.
I know what you're thinking ... Don't think that.

DoorKnobHandle

Oh. I see what you mean. Sorry for that...

Your explanation is correct, Ashen, I once scripted a gui like this.

proximity

i understand that GuiFollow mouse.x,mouse.y is difficult and making problems with system.Ok. i will just do it with script you typed.Thanks Ashen. You again solved my problem:) You and Scorpiorus are life jacket here :)
Proximity Entertainment

SMF spam blocked by CleanTalk