Mouse Release Actions/Hotspot Get Property [Solved]

Started by Pyroman, Thu 06/10/2011 06:53:44

Previous topic - Next topic

Pyroman

Hey guys, just lumped two questions together rather than starting a new post.

First up, I was looking at getting a GUI similar to that of Full Throttle going, whereby the Left mouse button is held for a short period of time, a menu pops up on the cursor, you drag your mouse over a hotspot, and then release to select it. Now I can do everything else, but I can't figure out a way to do an action on a mouse button release over a hotspot.
Right now I just have the menu appear when held and you can click on the option to select, but the mouse drag and release feels way more intuitive, so it'd be nice to get it working.

----------------------------

Second question, hopefully super easy!
Ok so, I found some code in an old thread that was talking about creating location arrows by setting a custom property to something like 'isExit' and then checking that each time. Then if it finds an exit it'll change the cursor and so on.
Now, the code they used was outdated, and looked like this:

Code: ags
GetHotspotProperty (GetHotspotAt(mouse.x,mouse.y), "IsExit"

That itself makes perfect sense to me, however it's not the accepted formatting any more. Instead you're supposed to use:

Code: ags
Hotspot.GetProperty("")

The issue I have, though, is that I can't figure out a way to tell that piece of code to grab the hotspot at mouse.x/mouse.y like the above one. If I just use the term 'Hotspot,' it errors out because I'm not telling it which hotspot to look at, and I can't store the hotspot I want in a variable because it won't accept it as the right input. I'm sure there's a simple way of doing it, I am just blind to it!


Snarky

If I remember this correctly:

Code: ags
Hotspot* h = GetHotspotAt(mouse.x,mouse.y);
if(h.GetProperty("IsExit"))
{
  // do stuff
}


You probably forgot the * after Hotspot in the first line. It means that you're making h a hotspot pointer (a reference to an existing hotspot), instead of actually creating a new hotspot (which you're not allowed to do from the script, I think).

As for your first question, I'm pretty sure AGS doesn't have a mouse release event. What you can do is set a flag when the button is pressed, and check in repeatedly_execute_always() if the flag is set but the button is no longer pressed.

Pyroman

Oh man, you're right I didn't even realise that asterisk did that!
So by putting Hotspot* I'm telling AGS that I'm declaring a variable that holds Hotspot data? Does this hold true for other data types, like Object* or even GUI*?

As for the second question, yeah I've been using that technique of an on-off switch so far, it's just a pain and was hoping I'd missed something!

Thanks for the super quick reply, by the way. I love these forums :D

Khris

Quote from: Pyroman on Thu 06/10/2011 10:34:38Does this hold true for other data types, like Object* or even GUI*?

Yes, it works that way for pretty much every script object.

As for the Full Throttle GUI, AGS comes with a highly customizable verb coin template.
If you want to do your own, you can use on_event / eEventGUIMouseUp.

Another way is checking mouse.IsButtonDown(eMouseLeft) in repeatedly_execute.

In both cases you'd use GUIControl.GetAtScreenXY() to get the verb button under the mouse.

Regarding exit arrows, here's my way using current code:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=41759.msg553607#msg553607

Pyroman

Oh fantastic, the eEventGUIMouseUp function was exactly what I needed, and had completely forgotten about. I had gotten AGS to identify which button the mouse was over, but was struggling with how to make the code 'click' it (Because of course ProcessClick would ignore the interface), but this should work perfectly.

I'm also glad to see the way you do your location arrows is near exactly the same as the way I have done them. I was a little worried when I clicked that link that I'd find some ridiculously obvious and different way of doing it!

Thanks for the detailed responses, guys.

SMF spam blocked by CleanTalk