Boolean set when animation is finished? [SOLVED]

Started by rich, Mon 05/11/2007 06:06:44

Previous topic - Next topic

rich

Is there way to have a boolean set to true when an animation is completed?

Why would I want this? Well, this was how it was done in AGI Studio, so, that is how I'm used to it. But, let me give an example of why it would be useful. Now, if I had a series of animations and various events I want executed, I could very easily just list them one after the other inside a function, but only if they were all eBlocked. I couldn't do that if I wanted them to be eNoBlocked. Here is where my request could come in handy. You could have your first animation go and then inside the repeatedly_execute function check to see if it's done by checking if that boolean has been set to true. Then, you could set it to false and execute your next command. Then, check to see if the boolean is set to true for that one and so forth. I could also add a series of SetTimer and IsTimerExpired to slow it all down.

Now, I  suppose I could set this up manually with a walk around... by when I start an animation, set a boolean up... and then check to see if both that boolean is set, and check if that particular object or character is no longer animating with the animating property, but it's a bit cumbersome. Does what I'm saying make sense to anyone? Is it an already built in feature? If not, I'd love to request it for the next build.

EDIT: I guess there would be similar booleans attached to walk, move, etc. commands.
I'm so excited!

Radiant

Effectively, yes. You can check character[EGO].IsAnimating (). If that's false, the character's animation is finished.

rich

Yes, like I said, I can check with IsAnimating, but if I have a series of different animations, this will not distinguish which particular animation has just finished. Nor would it distinguish whether the animation just finished, or if it has even started yet. I would need to use another variable along with it, which complicates things more than I'd like.
I'm so excited!

Rui 'Trovatore' Pires

Arr, but it's the way AGS does it. If you want to distinguish the animation, you check the character's loop and view just before or while the animation's going on; to see if it's just finished, simple code in rep_exec would make the game react as soon as it finished, or start a timer for a delayed reaction. And if done right, it wouldn't get confused with "animation hasn't started yet".
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Radiant

Quote from: rich on Mon 05/11/2007 09:58:51
Yes, like I said, I can check with IsAnimating, but if I have a series of different animations, this will not distinguish which particular animation has just finished. Nor would it distinguish whether the animation just finished, or if it has even started yet. I would need to use another variable along with it, which complicates things more than I'd like.

Oh well in that case, use character[EGO].loop to check which animation it is, and character[EGO].frame to find whether it's started (if it's zero, it hasn't yet).

rich

So... here is ultimately what I did...

  ... //stuff leading up to animation.
  animation_counter=1;
  cEgo.animate(1,4,eOnce,eNoBlock);
}
if (cEgo.Animating==false && animation_counter==1) {
  animation_counter=0;
  ...//stuff afterwords.

Works just fine. And, I can set animation_counter to other numbers for other unblocked animations,walks, etc. within the same script.
I'm so excited!

Radiant

That's good.

Also, perhaps, to avoid forgetting things -

Code: ags

function AnimateReally (int chr, int loop) {
  animation_counter = loop;
  character[chr].Animate (loop, 4, eOnce,eNoBlock);
}

function IsLoopFinished (int chr, int loop) {
  if (character[chr].Animating==false && animation_counter == loop) return true;
  else return false;
}


SMF spam blocked by CleanTalk