Animating Characters Through a Series of Views

Started by GoToHellDave, Tue 22/01/2013 14:31:40

Previous topic - Next topic

GoToHellDave

Hi.

I'm having a little trouble animating a particular character through several different views. I'm attempting to have a character do a set series of actions at regular intervals during the game loop using a series of timers. Here is the code:

Code: AGS

function room_AfterFadeIn()
{
  // Create timers for character animations
  cDealer.LockView(9);
  SetTimer(1, Random(400) + 100);
  SetTimer(2, 300);
  SetTimer(3, 400);
  SetTimer(3, 900);
}

function room_RepExec()
{     

        // Animate NPCs
        if(IsTimerExpired(1))
        {
          cDealer.Animate(0, 5, eOnce, eNoBlock, eForwards);
          SetTimer(1, Random(400) + 100);
        }
        
        if(IsTimerExpired(2))
        {
          cBouncer.LockView(2);
          cBouncer.Animate(0, 5, eOnce, eNoBlock, eForwards);
        }
        
        if(IsTimerExpired(3))
        {
          cBouncer.LockView(21);
          cBouncer.Animate(0, 5, eOnce, eNoBlock, eForwards);
          cBouncer.UnlockView();
        }
        
        if(IsTimerExpired(4))
        {
          cBouncer.LockView(2);
          cBouncer.Animate(0, 5, eOnce, eNoBlock, eBackwards);
          SetTimer(2, 300);
          SetTimer(3, 520);
          SetTimer(3, 900);
        }
}


The 'cDealer' character works fine but the 'cBouncer' character seems to just hang at the end of the first animation. Can anyone shed any light on what I'm doing wrong here? It is worth noting that I have also tried this using 'UnlockView' at the end of each if statement and it still doesn't seem to work.

Thanks in advance.

Ben.

Khris

Look at line 8, you're setting timer #3 again instead of #4.

GoToHellDave

Oh dear. I feel like a bit of an idiot. I think it's a case of not being able to see the woods for the trees.

SMF spam blocked by CleanTalk