[SOLVED] need some help with syncing the last frame of an animation to a new one

Started by Ardentsideburns, Tue 26/07/2016 02:29:52

Previous topic - Next topic

Ardentsideburns

so.. i have this girl jumping around on a loop and when my  main character talks to her i'd like for her to stop and assume her normal view with an animation.
i thought of using character.animating , but the example on the faq doesn't really explain how to check if an animation has finished, only if an animation is currently playing...

can anyone guide me to the solution? :X

Crimson Wizard

From description I got it that you need to test if girl is on her last animation frame?
You can check it following way:
Code: ags

if (cGirl.Frame == Game.GetFrameCountForLoop(cGirl.View, cGirl.Loop) - 1)
{
}

This checks if the frame is equal to the last frame index of character's current animation view & loop.


As additional note, checking Animating property does not work for looping animation, only one played once. In latter case you can do inverse check to know if it is done:
Code: ags

if (!cGirl.Animating)

Ardentsideburns

so , i tried applying crimson wizards's code  , but the script just jumps on the actions after it without doing what i wrote in the braces...
i'll post what i'm trying to do:
Code: ags
       if (aibell.Frame == Game.GetFrameCountForLoop(75, 0) - 1)
       {
      aibell.LockView(11);
          aibell.Animate(0, 20, eOnce, eBlock );
  }


what am i doing wrong..? :~(

Crimson Wizard

Where do you actually put this code? I was thinking you were talking about checking her animation in repeatedly execute, but you may do something else.

Ardentsideburns

it's tied to a talk action in the monkey island-style premade script, should i post a bigger portion of the code?

Crimson Wizard

Quote from: Ardentsideburns on Wed 27/07/2016 22:43:29
it's tied to a talk action in the monkey island-style premade script, should i post a bigger portion of the code?

Oh, I see, so this is an action function, not "repeatedly execute". I would make a guess that you want to wait until another animation "round" finishes, and then switch to normal view and start dialog? If not, then please elaborate.

If this is right, then you may try using a slightly different code:

Code: ags

int last_frame = Game.GetFrameCountForLoop(aibell.View, aibell.Loop) - 1;
while (aibell.Frame != last_frame)
{
   Wait(1);
}
// ... proceed with view/animation change and other actions
aibell.LockView(11);
aibell.Animate(0, 20, eOnce, eBlock );


Ardentsideburns

amazing! it worked like a charm! thank you so much crimson wizard! you really hold true to your nickname X3

SMF spam blocked by CleanTalk