Printing Text on Stage
-
Introduction
In MIT Scratch, to display any text on the stage window, you have to add text to the costumes. On the CreatiCode playground, you can easily print any text using the “print text” blocks.
The “Print” Block
You can find the “print” block in the Looks category.
Parameters
-
Text to Print: any text you want to be printed on the window. Note that they will all be printed in one row.
-
Center Position: the x and y positions of the center of the text. For example, if both x and y are 0, then the text’s center will be at the player window’s center.
-
Bounding Box Size: the width and height inputs determine the size of the text. The text should not be wider than this width, and also not taller than this height. Most of the time, only one of these 2 constraints will be in effect. For example, if you use a really large number for width, then the final size of the text will depend on the value of the height.
-
Color: You can set the color of the text, even with some transparency.
Demo
In this program, we are printing 2 lines of text of different sizes, with the “Hello” in semi-transparent color:
Print for Some Time
You can use another similar “print” block to print some text just for a while then clear it automatically:
You just need to specify the number of seconds for the text to say as the last input.
Clearing the Text
Whenever you click the green flag button, all prints will be cleared automatically. However, if you want to clear the printed text during a program’s run, you can use one of these 2 blocks:
This block will remove all the text printed from the current sprite.
This block will remove all the text printed from any sprite in the project.
Demo
This program will print the value of the timer every second, and clear the previous print as well.
-