Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ardentsideburns on Tue 26/07/2016 02:29:52

Title: [SOLVED] need some help with syncing the last frame of an animation to a new one
Post by: Ardentsideburns on Tue 26/07/2016 02:29:52
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
Title: Re: i need some help with syncing the last frame of an animation to a new one
Post by: Crimson Wizard on Tue 26/07/2016 03:03:03
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) Select

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

if (!cGirl.Animating)
Title: Re: i need some help with syncing the last frame of an animation to a new one
Post by: Ardentsideburns on Wed 27/07/2016 18:23:04
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) Select
       if (aibell.Frame == Game.GetFrameCountForLoop(75, 0) - 1)
       {
      aibell.LockView(11);
          aibell.Animate(0, 20, eOnce, eBlock );
  }


what am i doing wrong..? :~(
Title: Re: i need some help with syncing the last frame of an animation to a new one
Post by: Crimson Wizard on Wed 27/07/2016 18:54:50
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.
Title: Re: i need some help with syncing the last frame of an animation to a new one
Post by: 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?
Title: Re: i need some help with syncing the last frame of an animation to a new one
Post by: Crimson Wizard on Wed 27/07/2016 22:59:43
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) Select

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

Title: Re: i need some help with syncing the last frame of an animation to a new one
Post by: Ardentsideburns on Wed 27/07/2016 23:31:08
amazing! it worked like a charm! thank you so much crimson wizard! you really hold true to your nickname X3