A set of print commands are provided with AGK. Their purpose is to provide a very quick and effective way of outputting text on screen, which is particularly useful for debugging.
This example will demonstrate how the print commands can be used.
The Print command takes one parameter. It will accept a string, an integer or a floating point variable. These lines of code demonstrate printing out the different types:
Print ( "some text" ) Print ( 123 ) Print ( 9.473 )
After calling these commands the contents will be output on screen, with each subsequent call to Print generating a new line.
It's possible to adjust size, spacing and color properties for printing text on screen.
The command SetPrintSize controls the size of printed text. It only takes one parameter that controls the size. Increase the size to have larger text printed. The default size is calculated based on whether you have specified an aspect ratio or are using a virtual resolution.
The command SetPrintSpacing controls the spacing between characters. This command takes one parameter that controls the spacing. By default this is 0 meaning there are no spaces between characters. Use a larger value to increase spacing between characters.
The command SetPrintColor takes four parameters: red, green, blue and alpha values. This command is used to control the color of text displayed with the Print command. By default all of these values are 255, which will display white text on screen.
Our final program makes three calls to the Print command:
backdrop = CreateSprite ( LoadImage ( "background3.jpg" ) ) SetSpriteColorAlpha ( backdrop, 200 ) SetSpriteSize ( backdrop, 100, 100 )
do Print ( "some text" ) Print ( 123 ) Print ( 9.473 )
Sync ( ) loop
Any text printed out by the Print command will be displayed when the Sync command is called. At this point any text within the print buffer will be cleared. Therefore if you made a call to Print outside of your main loop then the text would be flashed on screen and then disappear. To ensure text with the Print command is displayed on screen then it's advisable to call Print within your main loop.
The Print command is ideal for quickly displaying text on screen. If you need extra control and customization then it's advisable to use the text commands.