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;
}
}
You should be able to add a delay to each frame in the View editor.
I tried but it doesn't work, the animation is still very fast.
I made a video to show the problem.
https://vimeo.com/314007481 (https://vimeo.com/314007481)
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).
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.
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.
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;
}
Thanks Khris, but it's The same, the cursor is animated todo fast.
At last I think os better simulate It using hotspots.
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?
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.
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.