Main Menu


Sponsored Links

  


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

Cartoon Time Functions

You already know one of these functions: SetTime . It does not return anything but changes a current scene time. Here is the full list of functions available to change and retrieve a current scene time: SetTime , GetTime and Sleep . In our first examples it was clear what the current scene time was at every moment. But in more complex examples it might not be that clear. And you might want to retrieve a current scene time using GetTime . Function Sleep changes the current scene time by a given amount of seconds. For example if you use it as Sleep ( 1.5 ) it is equal to SetTime ( GetTime () + 1.5 ) . Here is an example below

void Scene1 ()

{

SetTime ( 1.0 );

Sleep ( 1.5 );

Text TimeInScene ( "Scene Time is: " + GetTime () + " seconds");

TimeInScene.SetVisible ( true );

Sleep ( 1.0 );

}

This example will display a black screen for 2.5 seconds (1.0 + 1.5) and then the following text: "Scene Time is: 2.500000 seconds";

There is another function in WCM C++, which is not exactly a "cartoon time function". You probably noticed that it is not very convenient to create a text object every time you want to display a text. This is mostly because we work with simple programs and outputting test mostly for debugging purposes. When you are making a real cartoon, you will want to do different things with your text object, like rotate and move it, and you will find that having an object is a very convenient thing. But it is still not convenient for debugging.

Thus, there is a special function which displays a text for debugging in WCM C++ called ShowText . It automatically creates a text object, makes it visible, waits for one second and then makes it invisible. The last three lines of our example above could be rewritten with just one sentence using ShowText . Please keep in mind, that beside displaying text, this function also changes a current scene time by one second similar to Sleep (1) . Here is another example:

void Scene1 ()

{

SetTime ( 1.5 );

ShowText ( "Scene Time is: " + GetTime () );

ShowText ( "Scene Time is: " + GetTime () );

ShowText ( "Scene Time is: " + GetTime () );

}

This example will display a black screen for 1.5 seconds and then "Scene Time is: 1.500000 seconds" for one second, then "Scene Time is: 2.500000 seconds" for another second and "Scene Time is: 3.500000 seconds" for one more second:

Finally there is a pair of macros, THIS_TIME and SAME_TIME that are essentially equivalent to GetTime and SetTime but were defined aid in synchronizing multiple actions to a particular cartoon time “tick”. The best way to understand these macros is to examine and run the “Synchronization of Actions” tutorial script. An example of their use will also be presented in a later section


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