animating an object when the mouse is hovering over it

Started by shaun9991, Tue 28/10/2014 16:48:09

Previous topic - Next topic

shaun9991

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
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

Snarky

Sure! Something like...

Code: ags
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.


SMF spam blocked by CleanTalk