Main Menu


Sponsored Links

  


  
  
Web Cartoon Maker: a Fun Way to Learn C++ Contents Previous Next

Coordinates

When we created our first cartoons we displayed text or images in the center of them. But we can place them anywhere we want to. We just need to learn about coordinates in Web Cartoon Maker. To help you with coordinates we have a special image in our library "wcm/coordinates.emf". Please try to compile the following program:

void Scene1 ()

{

Image Coordinates ( "wcm/coordinates.emf" );

Coordinates.SetVisible ( true );

}

You will see a static one second long cartoon displaying the coordinate's grid:

As you can see the default coordinates of the cartoon's center are (0,0). The coordinates of the right bottom corner are (400,300) and the coordinates of the left upper corner are (-400,-300) . Every object can be placed anywhere in the scene by using these coordinates and SetPos method. The default coordinates for any object are (0,0) . The origin of a text or an image object is located in its center and when you use SetPos method you specify the coordinates of its origin. If you specify coordinates outside of the visible grid, then an object may become partially or fully invisible. This is like driving a car away from the camera’s view in a real movie.

Hint: When making a cartoon, don’t confine your thinking to just the area currently seen by the camera. As the above paragraph indicates, it can be effective to move things in and out of the camera’s view area and, as a later section will discuss, the camera can also be moved.

Let's use the coordinate's grid image as a background and add another ball image at the bottom:

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 );

Ball.SetPos ( 0, 200 );

}

You can also change the ball coordinates. If you place another instruction like Ball.SetPos ( 0, -200 ); immediately after Ball.SetPos ( 0, 200 ); then you will not even see the ball at (0,200) because the second instruction is executed at the same time in your cartoon. But if you change the current cartoon time using SetTime or Sleep... You will get the ball moving!

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 );

Ball.SetPos ( 0, 200 );


// move it to (0,-200)

Sleep ( 2 );

Ball.SetPos ( 0, -200 );

}

Here is what you should see after compilation of the program. You first real animated cartoon with a ball moving from bottom to the top:


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:


Contents Previous Next
  
News

New Tales Animator Video by Alan Sturgess

Alan Sturgess shared an excellent video he made using Tales Animator! You can still download Tales Animator here. Unfortunately it is only available for Wi

...

Simple Online Character Designer

There is a prototype of simple online character designer available HERE. It is only a prototype, it does not contain many pieces yet but it can already generat

...

Book is updated

Now our book "Web Cartoon Maker: A Fun Way to Learn C++" is fully in synch with WCM 1.5! It is available for download and online reading HERE.

...

Web Cartoon Maker 1.5 is here!

Web Cartoon Maker 1.5 is finally here! You can download it HERE! Here is what was updated in version 1.5: Web Cartoon Maker Desktop Edition is now fully standal

...

read more news...


Poll