Looping animations backwards and forwards

Started by xenogia, Mon 25/01/2010 11:20:44

Previous topic - Next topic

xenogia

I am trying to loop an animation backwards and forwards not being blocked (i don't want to add the reverse frames in the view as there are like 50 frames per view)

I put the following in the room code, but it doesn't seem to register.  Any ideas why?

Code: ags

function repeatedly_execute_always()
{
  
  if (oCutscene.Frame == 216) oCutscene.Animate (2, 3, eOnce, eNoBlock, eForwards);
  if (oCutscene.Frame == 479) oCutscene.Animate (2, 3, eOnce, eNoBlock, eBackwards);
  if (oCutscene.Frame == 480) oCutscene.Animate (3, 3, eOnce, eNoBlock, eForwards);
  if (oCutscene.Frame == 585) oCutscene.Animate (3, 3, eOnce, eNoBlock, eBackwards);
  if (oCutscene.Frame == 586) oCutscene.Animate (4, 3, eOnce, eNoBlock, eForwards);
  if (oCutscene.Frame == 656) oCutscene.Animate (4, 3, eOnce, eNoBlock, eBackwards);
}

Khris

If you animate something using eNoBlock, the subsequent command gets executed immediately afterwards.
Thus, only the very last command will actually do something.
But, since this is inside rep_ex_always, all lines are called 40 times per second.

The animation doesn't get a chance to actually begin.

You can either use Timers (since you know how long each animation is going to take) or use conditions:
Code: ags
  if (!oCutscene.Animating && oCutscene.Loop == L && oCutscene.Frame == F) oCutscene.Animate(...);

For L and F, put the loop and last frame of the previous animation.

Marion

Hello ! Sorry for uping this old topic but I am interested : is there today a way to play animation forwards then backwards when it's finished, in an automatic way (for Idle Views and Speech Views, for example) ? Because it's very long to add the reverse frames manually when you have many views and many frames ! Thank you :)

Marion

That's okay, I found out by right-clicking on the sprites and choose the "assign to view" option :)

SMF spam blocked by CleanTalk