Text will display a string or value to the screen at a user specified position. FACTS:
* Text can display Integer, Float & String information.
* Using Text does not alter the 'Print Cursor' position that the Print command uses.
* Text will display any information using the current FONT. See GetCurrentFont
* Text renders to the current surface, except when the either CaptureToScene, or CaptureToWorld are activated. In either situation, the draw request will be add to the scene or world queues.
Mini Tutorial:
This simple example displays the classic "Hello World" messages to the screen.
; Display the first message at position 100(x),150(y) Text 100,150,"Hello World" ; Display the Screen and wait for the user to press a key Sync WaitKey |
This example would display.
Mini Tutorial:
This example shows that we can not only display string messages, but we can disdplay variables and the results of calculations too.
; Declare the integer variable SCORE ;and assign it a value of 500 Score=500 ; Declare the float variable Friction# ;and assign it a value of 22.456 Friction#=22.456 ; Declare the string variable ProgramName$ ;and assign it the string "PlayBasic" ProgramName$="PlayBasic" ; Display message at 100x,100y on the screen Text 100,100,"Text Can Display Variables" ; Display the contents of the Score Variable Text 100,120,Score ; Display the contents of the Friction Variable Text 100,140,Friction# ; Display the contents of the ProgramName$ Variable Text 100,160,ProgramName$ ; Display message at 100x,300y on the screen Text 100,300,"Text Can Display Results of Calculations" ; Display the contents of the Score Variable * 10 Text 100,320,Score*10 ; Display the contents of the Friction Variable * 10 Text 100,340,Friction# * 10 ; Display the contents of the ProgramName$ + " Is Fun" Text 100,360,ProgramName$+" Is Fun!" ; Display the Screen and wait for the user to press a key Sync WaitKey |
This example would output. Print Can Display Variables 500 22.456 PlayBasic Print Can Display Results of Calculations 5000 224.56 PlayBasic Is Fun! |
Mini Tutorial:
This example demonstrates how we can print combinations of Integer /Float and string Variables together, using String Addition and the Str$() / Digits$() functions.
; Declare the integer variable SCORE ; and assign it a value of 500 Score=500 ; Display the message Text 100,100,"Combining Strings And Values" ; Since Text can only display one item at a time, if we ; wish to combine items, such a string and integer/float ; together, then we'll need to convert any values into ; strings and append (Add) them together for output. ; So here we'll display the String message "Score:" ; combined with Integer Variable Score. ; Do to this, we'll use the STR$() function to convert the ; variable Score into a temp string. This temp string is ; then added the "Score:" creating the resulting "Score:500" ; string, for Text to display. ; SoThis the In order to display Display the "Score" on ; the screen Text 100,120,"Score:" + Str$(Score) ; Embed the Score into a sentence Text 100,140,"You only scored " + Str$(Score)+" that time!" ; Display message Text 100,200,"Formatted Texting" ; Display the score message and score formated ; to 6 digits Text 100,220,"Score:" + Digits$(Score,6) ; Embed the Score into a sentence Text 100,240,"You only scored " + Digits$(Score,6)+" that time!" ; Display the Screen and wait for the user to press a key Sync WaitKey |
This example would output. Combining Strings And Values Score:500 You only scored 500 that time! Formatted printing Score:000500 You only scored 000500 that time! |
|