Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: xenogia on Tue 09/06/2009 12:30:38

Title: Mouse over Object
Post by: xenogia on Tue 09/06/2009 12:30:38
I noticed that hotspots have a mouse-over property, want I want to do is have a map and each location is an object.  And as you put the mouse over the object, the object zooms in and then when the mouse is off the object the object zooms out.  I have already made the zoom views, but are perplexed on how to integrate this.
Title: Re: Mouse over Object
Post by: GuyAwesome on Tue 09/06/2009 13:01:47
I'm guessing the 'zoom views' should animate the object under the mouse, rather than displaying the zoom somewhere else? If so, try (untested)


Object *oAtMouse; // Top of room script

// Set Object views/loops in room_Load

// rest in room_RepExec
if (Object.GetAtScreenXY(mouse.x, mouse.y) != null) {
 if (oAtMouse == null) {
   oAtMouse = Object.GetAtScreenXY(mouse.x, mouse.y);
   oAtMouse.Animate(oAtMouse.Loop, 3, eOnce, eNoBlock);
 }
}

else {
 if (oAtMouse != null) {
   oAtMouse.Animate(oAtMouse.Loop, 3, eOnce, eNoBlock, eBackwards);
   oAtMouse = null;
 }
}

If you're playing the zoom somewhere else, just change the .Animate function as needed.


Down side to this is, is you move the mouse off while it's still zooming in it'll still play the zoom out from the end (jump-cut to fully zoomed before zooming out). If the zoom anims are short enough, you could maybe make them blocking, or code some customised, interuptable animation function that'll reverse from the current frame.
Title: Re: Mouse over Object
Post by: Trent R on Tue 09/06/2009 16:51:47
This has been asked a bunch before, so a forum search will turn up plenty of threads (I say that not to be rude, but because its been explained before much better than I could now). I am also thinking that someone may have modularized it.... maybe monkey_05_06?

~Trent
Title: Re: Mouse over Object
Post by: xenogia on Wed 10/06/2009 06:04:15
I checked for something modulised but couldn't find anything.  I have applied the code and it works fine. Now I am just wondering what I would have to edit for multiple objects.
Title: Re: Mouse over Object
Post by: Khris on Wed 10/06/2009 09:24:53
The code should already work for multiple objects.
Title: Re: Mouse over Object
Post by: Trent R on Wed 10/06/2009 18:54:10
You can also use Custom Properties in conjunction with this to do some powerful stuff.


Quote from: Xenogia on Wed 10/06/2009 06:04:15
I checked for something modulised but couldn't find anything.
I must be crazy then. Oh well.


~Trent
Title: Re: Mouse over Object
Post by: Snake on Wed 10/06/2009 21:31:29
QuoteI must be crazy then. Oh well.
It's funny, that when you're crazy, you're the last one to find out.
Title: Re: Mouse over Object
Post by: GuyAwesome on Wed 10/06/2009 21:53:04
Quote
Now I am just wondering what I would have to edit for multiple objects.

As Khris said, that code should work for every object in the room, unless you haven't assigned it a view (in which case it'll crash - but you could throw in an 'oAtMouse.View != null' check, which'd also let you disable zooming for certain objects if you wanted, by just not giving them views). Is it not working properly for you? Or do you mean something different like animating multiple objects?