Download Web Cartoon Maker: a Fun Way to Learn C++

Transcript
You probably noticed that the ball was not moved immediately after seeing second SetPos
instruction. It was moved smoothly during 2 seconds Sleep command between 2 instances of
SetPos. Using SetPos is just like adding a control point at a specific time (also often called a “time
tick”) in you cartoon and the position is changing smoothly from one control point to another. For
example, if you want a ball to move through the cartoon edges, you can create a script like this one:
void Scene1 ()
{
// setup background
Image Coordinates ( "wcm/coordinates.emf" );
Coordinates.SetVisible ( true );
// add a ball image at (0,200)
Image Ball ( "sport/beach_ball.svg" );
Ball.SetVisible ( true );
// add first control point
SetTime ( 0.0 ); // start time, you can omit this one
Ball.SetPos ( 300, 200 ); // right bottom corner
// another control point
SetTime ( 1.0 ); // one second after beginning
Ball.SetPos ( 300, -200 ); // right upper corner
// another control point
SetTime ( 2.0 ); // two seconds after beginning
Ball.SetPos ( -300, -200 ); // left upper corner
// another control point
SetTime ( 3.0 ); // three seconds after beginning
Ball.SetPos ( -300, 200 ); // left bottom corner
// another control point
SetTime ( 4.0 ); // four seconds after beginning
Ball.SetPos ( 300, 200 ); // right bottom corner again
}
If you compile this cartoon you will see something like this:
Web Cartoon Maker: a Fun Way to Learn C++ (revision 2011-03-06)
- 43 -