Switch animations with frame offset

Started by TM, Wed 04/08/2010 18:18:39

Previous topic - Next topic

TM

Hello. I have a slight problem and I hope its easily remedied. I have a character with two animations that I want to switch between. So say animation A is playing, but at frame 13 something happens and I want to now play animation B starting from frame 14. Please tell me this is possible. :)

Edit: This can occur at any frame, so splitting up the animations at a certain point is not an option.

My website & blog

Dualnames

Quote from: TM on Wed 04/08/2010 18:18:39
Hello. I have a slight problem and I hope its easily remedied. I have a character with two animations that I want to switch between. So say animation A is playing, but at frame 13 something happens and I want to now play animation B starting from frame 14. Please tell me this is possible. :)

Edit: This can occur at any frame, so splitting up the animations at a certain point is not an option.

Code: ags

function repeatedly_execute() {
 if ((cEgo.View==A) && (cEgo.Frame==13)) {
   cEgo.UnlockView();
   cEgo.LockViewFrame(B,cEgo.Loop, 14);
   cEgo.Animate(cEgo.Loop,5,eOnce,eBlock,eForwards);//Not sure if you need these one you don't define when you want the animation to play
   cEgo.UnlockView();//same as above
 }
}
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

TM

Hm, that doesn't work for me. When I use your code, the Animate command starts loop B at frame 0 again instead of at frame 14.

My website & blog

Khris

You can always do this manually. It depends on the circumstances which way to approach this is best.

If the frame at which the view is going to switch is known before the animation starts, you could generate the loop dynamically using an empty loop and the ViewFrame commands.
Otherwise you'd have to manually advance the frame/change the view using a timer, i.e. set a variable to true when you want the animation to start and inside repeatedly_execute, advance the frame if the variable is true and x loops have passed. You can get the frame delay using the ViewFrame command, then add the animation's delay.

Since this process is non-blocking, all that's left to do is change the View during the animation.

SMF spam blocked by CleanTalk