Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: shaun9991 on Tue 28/10/2014 16:48:09

Title: animating an object when the mouse is hovering over it
Post by: shaun9991 on Tue 28/10/2014 16:48:09
Hi guys,

Forgive me if this is a stupid question - but is it possible to animate (non-blocking) an object when the mouse cursor passes over/on it? In the style of Quest for Glory IV character selection screen.

Any help much appreciated, thanks.

Shaun
Title: Re: animating an object when the mouse is hovering over it
Post by: Snarky on Tue 28/10/2014 20:19:18
Sure! Something like...

Code (ags) Select
bool myObjectAlreadyAnimating=false;

function repeatedly_execute()
{
  Object* mouseObject = Object.GetAtScreenXY(mouse.x, mouse.y);
  if(mouseObject != null && mouseObject.ID == myObject.ID)
  {
    if(!myObjectAlreadyAnimating)
    {
      myObject.Animate(..,..);            // Fill in the parameters here
      myObjectAlreadyAnimating=true;
    }
  }
  else if(myObjectAlreadyAnimating)
  {
    myObject.StopAnimating();            // Fill in parameters
    myObjectAlreadyAnimating=false;
  }
}


You could also use a Character instead of an Object, the methods are the same.
Title: Re: animating an object when the mouse is hovering over it
Post by: shaun9991 on Wed 29/10/2014 10:09:43
Thank you very much!!! :D