Jibble

Author Topic: animation not animating in rep exec always SOLVED  (Read 206 times)

Oookay - raising my head with a question again (always find this scary)  8-0
Imagine an industrial complex overrun by aliens. We enter the room (industrial complex), an alien scout spots us, dives back into a shed where it raises the alarm and the alarm brings out a small army of aliens who line up and start shooting at us. That's what I want. Every thing works fine until the shooting bit - that animation stops on the first frame. I put that animation in repexec-always because I thought with enoblocking it would work there whilst with enoblock in standard repexec it did not work. However, it stops on the first frame  (wtf)  Why? Similar situations have been covered elsewhere but I still just do not get it.
Here's the code - when it starts the scout is already animating. What do you think? I know this is going to be something simple again. I shall steel myself.  :-D

Code: Adventure Game Studio
  1. function room_RepExec()
  2. {
  3.   ShakeScreenBackground(5, 2, 80);
  4. }
  5.  
  6. function repeatedly_execute_always()
  7. {
  8.   if (object[0].Frame == 39){    // alien scout already animating from room after fade in
  9.     object[3].Animate(0, 5, eRepeat, eNoBlock);   ///    siren
  10.     asiren.Play(eAudioPriorityNormal, eRepeat);
  11.     object[4].Animate(0,  15,  eOnce, eNoBlock);   // army
  12.     }
  13.     if (object[4].Frame == 13){
  14.       object[5].Visible = true;      
  15.       object[5].Animate(0, 10, eOnce, eNoBlock);    // army lining up to fire
  16.       if (object[5].Animating){
  17.         Display("attacking!");       // I know it's animating because this shows
  18.     }
  19.     }
  20. }
  21.  
« Last Edit: 15 Oct 2021, 18:14 by smartastreacle »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: animation not animating in rep exec always
« Reply #1 on: 15 Oct 2021, 17:35 »
Uhm?

Quote
Display("attacking!");       // I know it's animating because this shows

How on earth are you doing a blocking action (Display) inside rep_exec_always?  ???

But to answer your question, you need to understand that rep_exec_always runs 40 time a second! (40 is AGS default, might be more or less if you have change it - but most people leave it in the default).

So, every time the code runs, it reads the code and starts doing it again, and again and again. (40 times in a second) This is the reason that you can't see it animating more than the 1st frame.
What you need to do, is create a start condition (to set things in motion), and then check for if the object is not animating if (!object
  • .Animating) // the run the animation code.[/b]
    This away, it will only run the animation code, if it has stopped animating (and thus you can see the object animating).
There are those who believe that life here began out there...

Re: animation not animating in rep exec always
« Reply #2 on: 15 Oct 2021, 18:09 »
'How on earth are you doing a blocking action (Display) inside rep_exec_always?  ???(laugh) No idea, but it happened!

Apart from that, your bold emphasis really hammered it into my head.

I was checking for object 4 not animating, ie, checking it had finished instead of checking for object 5 not animating (at least that was one of the many things I tried). That was the answer. And now it works and I can enjoy the weekend. Brilliant. You are a super star. Thank you.   (nod)

For completeness, this is what I ended up with. Beware the world! They are coming!

Code: Adventure Game Studio
  1.  
  2. function room_RepExec()
  3. {
  4.   ShakeScreenBackground(5, 2, 80);
  5. }
  6.  
  7. function repeatedly_execute_always()
  8. {
  9.   if (object[0].Frame == 39){    // alien scout already animating from room after fade in
  10.     object[3].Animate(0, 5, eRepeat, eNoBlock);   ///    siren
  11.     asiren.Play(eAudioPriorityNormal, eRepeat);
  12.     object[4].Animate(015,  eOnce, eNoBlock);   // army
  13.     }
  14.     if (object[4].Frame == 20){
  15.       object[5].Visible = true;     /// army firing
  16.  
  17.     if (!object[5].Animating){
  18.       object[5].Animate(0, 10, eRepeat, eNoBlock);
  19.     }
  20.     }
  21. }
  22.  
  23.  
« Last Edit: 15 Oct 2021, 18:21 by smartastreacle »