Mouse wait cursor looping

Started by vga256, Sat 30/10/2021 23:37:58

Previous topic - Next topic

vga256

After reading this post on mouse cursor looping I went ahead and tried to replicate the same behaviour using the latest build of AGS 3.5.1. It no longer appears to work - the mouse wait cursor continues to reset itself to the first frame when a new Wait(x) is called.

I also noticed that when the animation runs, it "hiccups" and skips between frames. It appears as if the engine is competing with itself for the View's graphic property - sometimes the (below script's) scripting code "wins" and sets the graphic property, other times the view's default animation "wins" and sets the graphic property. Is there a chance that the engine's graphics execution order (or script execution order?), or something else has changed since this code was written in 2014?

Have I missed something obvious?


Update: cause of the problem found. See my response below.

Code below. I have ensured that the correct View is being used, as well as wait delay, frames and sprite numbers.
Code: ags

(at top of script)
// mouse wait cursor
int cursorWaitView = MOUSEWAIT; //view of your cursor
int cursorWaitDelay = 5; //animation delay of your cursor
int cursorWaitFrames = 8; //number of animated frames
int cursorWaitFirstSlot = 21; //ID of the first frame
int cursorWaitCounter; // maintain a counter for the cursor

function UpdateMouseWaitCursor()
{
  if (!IsInterfaceEnabled())
  {
    cursorWaitCounter = (cursorWaitCounter + 1) % (cursorWaitDelay * cursorWaitFrames);

    ViewFrame* vf = Game.GetViewFrame(cursorWaitView, 0, 0);
    vf.Graphic = cursorWaitFirstSlot + cursorWaitCounter / cursorWaitDelay;
  }
}

function repeatedly_execute_always()
{
  UpdateMouseWaitCursor();
}

Crimson Wizard

#1
Trying this code in a test project seem to produce desired effect. Maybe there's something else in your game interfering with the mouse looks?

Here's the test project based on sierra template:
https://www.dropbox.com/s/3q9hh49emif0ohh/test--animcursor.zip?dl=0

I test this by having a blocking walk on pressing Space, and calling Wait() in a loop on pressing Enter/Return.

vga256

#2
Thank you CW. Your example project allowed me to do a side-by-side comparison with mine, and I pinned down the exact cause: I had all 8 frames of my MOUSEWAIT View populated with graphics in the editor! I deleted all but the first frame, then set its image to zero, and voila - perfect looping behaviour.

So for anyone else who wants to use this little mouse cursor looping trick: your View in the editor must have only one frame with no image in it.
This was mentioned in Khris's original post "-remove all frames from the view but one", but I somehow missed that critical point!

Crimson Wizard

Something I am missing about this, but why do you need to animate your cursor manually at all, could not you use plain view animation?

vga256

I am simulating an operating system, which uses a Macintosh-like wristwatch for a wait cursor. It is visually distracting when the hands reset themselves due to a new Wait().

SMF spam blocked by CleanTalk