change button pic while mouse is over hotspot

Started by kaputtnik, Sat 18/03/2006 16:12:10

Previous topic - Next topic

kaputtnik

Hey there.

I've scripted my way through quite successfully up to now but right now I've found myself in a bit of trouble.

I've been trying to establish a constantly visible GUI which includes a button, whose image should change according to the hotspot the mouse is over.
Like the simple @OVERHOTSPOT@, just that I need a button pic to be changed.

I added properties leading to the very pic for every hotspot and tried to script it, but I'm kind of stuck now. Can somebody tell me an effective way to do it? I surely could mess around with mouse.x and y and script my way around it, but I feel there's gotta be an easier possibility.

-
I, object.

Khris

In the rep_ex, use something like this:

Code: ags
int lt=GetLocationType(mouse.x, mouse.y);

if (lt == eLocationHotspot)
Ã,  Button.NormalGraphic=123;
else if (lt == eLocationObject)
Ã,  Button.NormalGraphic=456;
...

Ashen

Or, if you want a different response for individual hotspots:
AFAIK, there's no easier way to do this than to "mess around with mouse.x and y and script my way around it".

However it's not actually that difficult, using the Hotspot.GetAtScreenXY(..) function, and repeatedly_execute:
Code: ags

if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hotspot[1]) {
  //Change button graphic for Hotspot 1
}
else if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hotspot[2]) {
  //Change button graphic for Hotspot 2
}
//Etc for other hotspots
else {
  //Set default graphic for No Hotspot
}


Just keep in mind that this'd need to go in the ROOM rep_ex, and not the Global one (especially if you want to use Script-O-Names instead of hotspot[num]).

(I've used Hotspots specifically here, but the same applies for Object.GetAtScreenXY(mouse.x, mouse.y) and Character.getAtScreenXY(mouse.x, mouse.y).)
I know what you're thinking ... Don't think that.

kaputtnik

Sorry for my uncouth description of the bodacious art of scripting 
- but all I do is mess around  ;)

It works like I desired it to work now, thanks a bunch for the rapid answer.
I, object.

SMF spam blocked by CleanTalk