Problem with cursor animation [solved]

Started by , Mon 28/01/2019 22:45:29

Previous topic - Next topic

Neo_One

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;
  }
}

Khris

You should be able to add a delay to each frame in the View editor.

Neo_One

I tried but it doesn't work, the animation is still very fast.

Neo_One


morganw

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).

Neo_One

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.

Khris

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
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;
}

Neo_One

Thanks Khris, but it's The same,  the cursor is animated todo fast.
At last I think os better simulate It using hotspots.

Khris

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?

Neo_One

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.

Khris

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.

SMF spam blocked by CleanTalk