This function works:
function OvaSquat(int x, int y) // pass the x,y of where you want her hand to be
{
if (cOva.x < (x - 40)) cOva.Walk((x-40), y, eBlock, eWalkableAreas);
else cOva.Walk((x+40), y, eBlock, eWalkableAreas);
cOva.ChangeView(18);
switch (cOva.Loop)
{
case 0: cOva.Animate(4, 4, eOnce, eBlock, eForwards); break;
case 1: cOva.Animate(5, 4, eOnce, eBlock, eForwards); break;
case 2: cOva.Animate(4, 4, eOnce, eBlock, eForwards); break;
default: cOva.Animate(5, 4, eOnce, eBlock, eForwards); break;
}
}
This function DOESN'T work, and tries to play a loop from her walk animation, despite the changeview call being literally right there in the same place.
function OvaKeycard(int x, int y) //pass the bottom center of door
{
if (cOva.x < (x - 60)) cOva.Walk((x-60), (y+25), eBlock, eWalkableAreas);
else cOva.Walk((x+60), (y+25), eBlock, eWalkableAreas);
cOva.ChangeView(18);
switch (cOva.Loop)
{
case 0: cOva.Animate(6, 4, eOnce, eBlock, eForwards); break;
case 1: cOva.Animate(6, 4, eOnce, eBlock, eForwards); break;
case 2: cOva.Animate(7, 4, eOnce, eBlock, eForwards); break;
default: cOva.Animate(7, 4, eOnce, eBlock, eForwards); break;
}
}
This isn't the only time this has come up. What's wrong with this function?
With Animate function you are supposed to call LockView before Animate and UnlockView after. This is explained in the relevant article from the manual:
https://adventuregamestudio.github.io/ags-manual/Character.html#characteranimate
ChangeView is not meant for calling Animate, it's meant for setting current standing/walking view that engine animates automatically as character walks around. This is also noted in its article:
https://adventuregamestudio.github.io/ags-manual/Character.html#characterchangeview
To be honest, I cannot tell why exactly it switches to a regular walking view in your second function. Maybe there's another factor affecting this situation. I'd would need to have a minimal test case where the problem reproduces to diagnose this.
In any case, using LockView/UnlockView pair is supposed to ensure that Animate plays correctly.
Thanks for the info. I need to read the manual more I suppose.