Tutorial - Synchronizing Actions
There are 2 macro defined in Web Cartoon Maker to help you to synchronize actions. These are THIS_TIME and SAME_TIME. Some methods and functions like GoesTo () or Winks() and all Change...() methods and functions can change the current time in scene. For example a boy in the script below first moves to a new location and then raises his hand and then winks:
#include <boy.h>
void Scene1 ()
{
Boy Max;
Max.SetPos ( 300, 290 );
Max.SetVisible ();
Max.ChangePos ( -300, 290, 2 );
Max.RightArm.ChangeAngle ( 65, 2 );
Max.Winks ();
}
But what if we want these 3 things to happen together? You can use GetTime () and SetTime () of course:
#include <boy.h>
void Scene1 ()
{
Boy Max;
Max.SetPos ( 300, 290 );
Max.SetVisible ();
double dStartTime = GetTime ();
Max.ChangePos ( -300, 290, 2 );
SetTime ( dStartTime );
Max.RightArm.ChangeAngle ( 65, 2 );
SetTime ( dStartTime );
Max.Winks ();
}
But it is not very convenient. There is a more convenient way to use THIS_TIME before first action and SAME_TIME before other actions happening at the same time:
#include <boy.h>
void Scene1 ()
{
Boy Max;
Max.SetPos ( 300, 290 );
Max.SetVisible ();
double dStartTime = GetTime ();
THIS_TIME Max.ChangePos ( -300, 290, 2 );
SAME_TIME Max.RightArm.ChangeAngle ( 65, 2 );
SAME_TIME Max.Winks ();
}
At the end of this tutorial please compile the above script and preview it in WCM Player
|