Tutorial - Text Objects
We were already using text objects and know how to move them, rotate, change size and do some other operations common for all kinds of objects. There are some other methods available specific to text objects:
- SetFont () - you can use this method to change a font of your text to any font installed on your system. To view list of fonts you can go Notepad application and pick "Format/Font" menu item. You can change font using a simple instruction like this one:
MyText.SetFont ( "Tahoma" );
- SetStyle () - text objects can have one or several of the flags below:
- B - Bold
- I - Italic
- U - Underlined
- S - Stroked out
You should supply a string including letters corresponding to the desired flags like this:
MyText.SetStyle ( "BIS" );
- SetColor () - this method can be used to change a text color. You should supply a string with hex encoded color. First 2 symbols encode red component. Second 2 symbols encode green component. Last 2 digits encode blue component. Values for one component could be from 00 to FF. For example blue color can be encoded as "0000FF":
MyText.SetColor ( "0000FF" );
- SetSize () and ChangeSize ()- you can use these methods to set/change a font size. There are actually 2 ways to change your text size. One is to use SetScale () method which can be used for any kind of object and another is to use SetSize () or ChangeSize () method. Here is an example of using ChangeSize () which smoothly change the text size from its current value to 50 during 1 second
MyText.ChangeSize ( 50, 1 );
Here is what you can try after reading this topic. Lets make a small Web Cartoon Maker introduction cartoon:
- Lets display "Web Cartoon Maker" text. We will use bold text
void Scene1 ()
{
// setup a text object
Text Intro ( "Web Cartoon Maker" );
Intro.SetFont ( "Tahoma" );
Intro.SetColor ( "0000FF" );
Intro.SetStyle ( "B" );
Intro.SetSize ( 30 );
Intro.SetVisible ();
}
- Lets make it to appear by increasing size and rotating it. We are going to use 2 macros THIS_TIME and SET_TIME to synchronize 2 events. You can also use GetTime () and SetTime for time synchronization but these macros are just an easier way:
void Scene1 ()
{
// setup a text object
Text Intro ( "Web Cartoon Maker" );
Intro.SetFont ( "Tahoma" );
Intro.SetColor ( "0000FF" );
Intro.SetStyle ( "B" );
Intro.SetSize ( 30 );
Intro.SetVisible ();
// make it to appear
Intro.SetScale ( 0 );
THIS_TIME Intro.ChangeAngle ( 360, 2 );
SAME_TIME Intro.ChangeScale ( 2.5, 2 );
}
- Lets add "presents" text moving from right to left. We will use bold, italic, underlined and stroked out text. Copy this script to Web Cartoon Maker, compile it and preview in WCM Player
void Scene1 ()
{
// setup a text object
Text Intro ( "Web Cartoon Maker" );
Intro.SetFont ( "Tahoma" );
Intro.SetColor ( "0000FF" );
Intro.SetStyle ( "B" );
Intro.SetSize ( 30 );
Intro.SetVisible ();
// make it to appear
Intro.SetScale ( 0 );
THIS_TIME Intro.ChangeAngle ( 360, 2 );
SAME_TIME Intro.ChangeScale ( 2.5, 2 );
// prepare "presents" text object
Text Presents ( "presents" );
Presents.SetFont ( "Tahoma" );
Presents.SetColor ( "0000FF" );
Presents.SetStyle ( "BIUS" );
Presents.SetScale ( 2 );
Presents.SetVisible ();
// make it to move
Presents.SetPos ( 1000, 200 );
Presents.ChangePos ( -1000, 200, 5 );
}
|