Mouse over Object

Started by xenogia, Tue 09/06/2009 12:30:38

Previous topic - Next topic

xenogia

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.

GuyAwesome

I'm guessing the 'zoom views' should animate the object under the mouse, rather than displaying the zoom somewhere else? If so, try (untested)

Code: ags

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.

Trent R

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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

xenogia

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.

Khris

The code should already work for multiple objects.

Trent R

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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Snake

QuoteI must be crazy then. Oh well.
It's funny, that when you're crazy, you're the last one to find out.
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

GuyAwesome

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?

SMF spam blocked by CleanTalk