As I mentioned
in the last chapter, you can put as many statements as you want in
Scene1. You can also have as many objects in a scene as you want. Let's
try do show two text objects in a scene
void Scene1 ()
{
Text MyText ( "Hello
World" );
MyText.SetVisible (
true );
Text AnotherText (
"And Hello Again" );
AnotherText.SetVisible (
true );
}
You can probably understand this program by yourself. We are going to
have
two text objects named
MyText
and
AnotherText
in this scene. And we are going to make them visible. But if you try to
compile and run the program and preview the cartoon you will see that
these 2 text objects are displayed at the same time (at the beginning
of your cartoon) and at the same place (in the center of your animated
cartoon) and this does not look good. But this is exactly what we asked
the interpreter to do.
There is a special instruction (you will learn later that this is also a
function) called
SetTime
for changing time in the scene. If we want our second text object to
appear a couple of seconds later then we need to use it like this:
void Scene1 ()
{
Text MyText ( "Hello
World" );
MyText.SetVisible (
true );
SetTime ( 2.0 );
Text AnotherText (
"And Hello Again" );
AnotherText.SetVisible (
true );
}
As you can see it accepts a floating-point value as a parameter
inside parentheses. This is a time in seconds. The statement
SetTime ( 2.0 );
specifies that every instruction the interpreter sees after it will
happen at 2 seconds after the beginning of a scene in your cartoon. If
you want the second text object to appear two and half seconds after
the beginning of a scene, then you should specify
SetTime ( 2.5 );
instead.
You can try to compile and preview this cartoon but it is still
does not perform what we wanted. You still see "Hello World" text for
two seconds (because we used
SetTime (2.0);
and the interpreter automatically changed the length of our cartoon to
2 seconds) but then it stops. This is because we did not specify for
how long we want to see the second line of text. We should use
SetTime
again to change the length of our cartoon to be more than 2 seconds. It
should be something like this:
void Scene1 ()
{
Text MyText ( "Hello
World" );
MyText.SetVisible (
true );
SetTime ( 2.0 );
Text AnotherText (
"And Hello Again" );
AnotherText.SetVisible (
true );
SetTime ( 3.0 );
}
This way the our cartoon will be 3 seconds long and second line of text
will be displayed beginning from the 2
nd
second. You can try to compile it again.
But it is still not perfect. The first line of text is still displayed
though the entire cartoon. And the second line is displayed beginning
from 2nd second. And they are displayed at the same place. We probably
want to hide the first text object after 2
nd
second. You already know how to do this:
void
Scene1 ()
{
Text MyText (
"Hello World"
);
MyText.SetVisible (
true
);
SetTime (
2.0
);
MyText.SetVisible (
false
);
Text
AnotherText (
"And Hello
Again"
);
AnotherText.SetVisible (
true
);
SetTime (
3.0
);
}
As it was explained before we used
MyText.SetVisible ( false );
statement to hide the first text object. It is now perfect! Try to
compile and preview it. The first text object is displayed for two
seconds and then disappears. Then the second text object is displayed
for one more second. The total cartoon length is 3 seconds:
I specially wanted to show you that you can have multiple objects in
your cartoons by using 2 text objects
MyText
and
AnotherText
. But since you are using only one object at a time and they have all
the same default parameters like font and size (you will learn how to
change them later), you can use a special method called
SetText
to change the default text. We can simplify this program:
void Scene1 ()
{
Text MyText ( "Hello
World" );
MyText.SetVisible (
true );
SetTime ( 2.0 );
MyText.SetText (
"And Hello Again" );
SetTime ( 3.0 );
}
But what if you want to output 2 lines of text
at the same time? You can define 2 text objects and make them visible
at the same time. But there is another alternative. Actually strings
can contain a special line break symbol. It is encoded with 2 symbols –
back slash and letter n -
"\n"
. For example if you want to show
"And Hello Again"
text below
"Hello World"
, then you should use
"\n"
between them:
void Scene1 ()
{
Text MyText ( "Hello
World\nAnd Hello Again " );
MyText.SetVisible (
true );
SetTime ( 1.0 );
}
This will produce a one second long cartoon with 2 lines of static text.
Actually symbol
"\"
is reserved in C++ to include special symbols like line breaks (
"\n"
) or tabulate (
"\t"
) and some other in the strings. If you want to include an actual
backslash symbol in a string, then you must use two of them like
"\\"
. The example below will show two lines of text for a second and then a
line of text with backslash:
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
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
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