workaround for Mouse_Move over Objects? *SOLVED*

Started by selmiak, Thu 12/05/2011 23:31:35

Previous topic - Next topic

selmiak

I was just searching and only found a bug tracker report for the Mouse moves over an Object function. Is this somehow possible easily?
I by now disable clickable on the object and draw a hotspot over the area the Object fills. But this is annoying. Any other suggestions?

Khris

#1
Do you need this for an active cursor or something like that (i.e. the mouse animates/changes when over an object)?
Because behaviors like this are incredibly tedious and uncomfortable to implement on a per-object basis.

Just imagine you wanted to change something about what happens and had to go through each hotspot and object in the game... 8)

You always do stuff like that globally:

Code: ags
// above repeatedly_execute

bool mouse_at_location;

// inside repeatedly_execute

  int lt = Game.GetLocationType(mouse.x, mouse.y);

  if (lt != eLocationNothing && !mouse_at_location) {
    // mouse was just moved over a clickable/enabled hotspot/object/character
    mouse_at_location = true;
    ...
  }
  else if (lt == eLocationNothing && mouse_at_location) {
    // mouse is no longer over a clickable location
    mouse_at_location = false;
    ...
  }


Edit: typo

selmiak

thanks, This works and is really easy to handly. I had to remove the Game. from Game.GetLocationType(mouse.x, mouse.y); though to make it work in AGS3.1.2.

What I'm doing is a simple gui with @OVERHOTSPOT@ shown when the mouse hovers over a hotspot, no fancy mousecursors, but this is an interesting idea, but I think maybe in my next game, if I ever finish this one ;)

Snarky

@OVERHOTSPOT@ automatically displays not just hotspot names, but also object and character names, so there should be no need for the workaround you describe. If you don't see it, could it be that you simply forgot to set the Object.Name (or Object.Description, I forget exactly what it's called) property?

Incidentally, finding out about GetLocationType() instantly made a whole function I wrote yesterday (exactly for the purpose of highlighting the mouse cursor over any interactive element) redundant. Thanks a lot Khris!  >:(


;)

Well, at least I still need my own code to highlight over inventory items (and not empty inventory slots), buttons, sliders and textboxes, so it wasn't all in vain.

Khris

 :)

selmiak:
Right, GetLocationType is enough, the other function is Game.GetLocationName and there you need the Game. because it returns a string and is thus static.

Like Snarky explained you shouldn't need my code at all though; it's called @OVERHOTSPOT@ but a better name would probably be @OVERLOCATION@.

selmiak

I have it over a semitranparent GUI and enable and disable the semitransparent BG of the GUI, or actually the whole gui with this.
How would I add @OVERHOTSPOT@ to normal gameplay without a gui anyways?

Khris

Right, but your original problem was, I take it, different behavior on AGS's side for hotspots and objects. That shouldn't be the case though if you're using @OVERHOTSPOT@ since it works the same for all three locations.

Never mind, you're using my code to turn the @OVERHOTSPOT@ gui on/off and used to do it using the mouse over hotspot event, now I got it :)

selmiak

cool, thanks for the pointer to Game.GetLocationType again Khris :)

and I'd call it @OVERCLICKABLEAREA@ or @OVERWHEREYOUCANCLICKANDSOMEACTIONHAPPENS@ ;)

SMF spam blocked by CleanTalk