Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Mon 28/01/2019 22:45:29

Title: Problem with cursor animation [solved]
Post by: on Mon 28/01/2019 22:45:29
Morning, everybody.
Recently I'm creating a Broken Sword style cursor (changes the image of the cursor and animates itself according to a hotspot, object, etc...)
The problem is that the animation plays very fast and I'm unable to change the speed. Could someone give me a hand, this is the code (quite simple).

function repeatedly_execute()
{
   if(GetLocationType(mouse.x, mouse.y) == eLocationObject)
  {
    mouse.ChangeModeView(eModeInteract, CURSORCOGER);
    mouse.Mode=eModeInteract;
  }
  else
  {
    mouse.Mode=eModeWalkto;
  }
}
Title: Re: Problem with cursor animation
Post by: Khris on Tue 29/01/2019 08:40:56
You should be able to add a delay to each frame in the View editor.
Title: Re: Problem with cursor animation
Post by: on Tue 29/01/2019 09:19:57
I tried but it doesn't work, the animation is still very fast.
Title: Re: Problem with cursor animation
Post by: on Tue 29/01/2019 12:54:02
I made a video to show the problem.

https://vimeo.com/314007481 (https://vimeo.com/314007481)
Title: Re: Problem with cursor animation
Post by: morganw on Tue 29/01/2019 13:10:42
I think this is because you are continually calling ChangeModeView on every frame, which is bumping the animation forwards (ignoring any delays that you may have set).
Title: Re: Problem with cursor animation
Post by: on Tue 29/01/2019 13:43:54
I don't quite understand why this is happening. It also happens with the hotspots, but these do not produce the animation
I am using an empty template, however if I use the Sierra template everything works correctly.
I think I'll start from scratch using the Sierra style and modifying parts I don't need.
Title: Re: Problem with cursor animation
Post by: Khris on Tue 29/01/2019 14:21:50
Your approach is correct in principle, but as morganw says, you're setting the mouse animation 40 times per second.
The key is to only call mouse.ChangeModeView() when the animation is in fact supposed to change.

Code (ags) Select
LocationType previousLT;

function repeatedly_execute()
{
  LocationType currentLT = GetLocationType(mouse.x, mouse.y);
  if (currentLT == previousLT) return; // no change required

  if(currentLT == eLocationObject)
  {
    mouse.ChangeModeView(eModeInteract, CURSORCOGER);
    mouse.Mode=eModeInteract;
  }
  else
  {
    mouse.Mode=eModeWalkto;
  }
  previousLT = currentLT;
}
Title: Re: Problem with cursor animation
Post by: on Tue 29/01/2019 21:46:37
Thanks Khris, but it's The same,  the cursor is animated todo fast.
At last I think os better simulate It using hotspots.
Title: Re: Problem with cursor animation
Post by: Khris on Wed 30/01/2019 09:33:56
You can set a cursor animation in the editor, and you can set it to only animate over hotspots.
Combining that with a change of the active mode should be enough (and requires no code), unless you want to use more than one animation for a single cursor.

So do you need code or not? And what do you have currently?
And when you say "animated too fast", do you mean it looks like the video you posted?
Title: Re: Problem with cursor animation
Post by: on Wed 30/01/2019 10:48:03
I already got it done through hotspots, thanks Krhis.
A problem writing it using code is that it breaks the animations made using hotspots. Although it's a bit messy to make the hotspot match the object without having it in front of you.

Yeah, that's the speed I meant.
Title: Re: Problem with cursor animation [solved]
Post by: Khris on Wed 30/01/2019 12:09:43
But not on a per-hotspot basis, I hope? I'm talking about the cursor property, which by "hotspots" refers to all interactive areas, not just drawn actual capital H hotpots.