Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: thehivetyrant on Tue 02/03/2010 14:13:57

Title: Animate (NoBlocking) problems.
Post by: thehivetyrant on Tue 02/03/2010 14:13:57
Hi people, sorry for another post.

I'm having a very difficult problem regarding animating with NoBlock.
Allow me to try to set the scene.

When character B collides with character A he changes his view and attacks.
 
  if (cStitches.IsCollidingWithChar(cGrim) == 1)
   {
     cStitches.LockView(VATTACK);
     cStitches.Animate(0, 2, eOnce, eBlock, eForwards);
     if(cStitches.IsCollidingWithChar(cGrim) && cStitches.View == 2 && cStitches.Frame == 5)
       {
          PlayerHP -= 10;
          HP.Width -= 10;
        }
     cStitches.UnlockView();
    }
 

At the moment i have the Animate configured to eBlock, this works okay but the player is unable to move during this which is bad for this game,
If i change it to eNoBlock, then when they collide character B (who should attack) just stands there.

as i understand it, it just skips the function because nothings stopping it.

I tried setting up SetTimer but couldn't get it to work.
And have also tried to set up a global variable but to no avail niether.

Help?

If more code is needed i'll write some up, since i've tried various alternatives to attempt to get it to work i've deleted ones i couldnt get to work, so dont have it on hand.

Thanks Matt!

Title: Re: Animate (NoBlocking) problems.
Post by: Khris on Tue 02/03/2010 16:24:04
Once the condition is fulfilled, it remains fulfilled until the player moves away, so the Animation is constantly started anew, never getting the chance to change the displayed frame.

Try this:
  if (cStitches.IsCollidingWithChar(cGrim) && !cStitches.Animating)  // not animating
  {
    cStitches.LockView(VATTACK);
    cStitches.Animate(0, 2, eOnce, eNoBlock, eForwards);
  }
  if (cStitches.View == VATTACK && cStitches.Frame == 5)  // animation done
  {
    if (cStitches.IsCollidingWithChar(cGrim))
    {
      PlayerHP -= 10;
      HP.Width -= 10;
    }
    cStitches.UnlockView();
  }


This will probably lead to frame 5 not being displayed; if that's the case, append the standing frame to the loop and change the condition to "== 6".
Title: Re: Animate (NoBlocking) problems.
Post by: thehivetyrant on Tue 02/03/2010 17:00:52
oh wow that works great!
I mean, really, wow! :o

really nice one!
Title: Re: Animate (NoBlocking) problems.
Post by: Khris on Tue 02/03/2010 17:13:37
Heh, glad it did :)