Probably a stupid question but as the title suggests are both necessary for custom text,
CreateText()
SetTextString()
??
I saw there was a command called
SetTextDefaultFontImage()
, just wondering if there might be an easier way to set it up than creating it for each new text object ? Perhaps someone could provide a small example..
Thanks in advance here is the current code. I have also provided a small gif of it in action for now they both use the same images for text but this could change in the future.
// Project: Timer_test
// Created: 2018-01-07
// Error Constants
#CONSTANT ERROR_IGNORE = 0 // MODE = 0 - IGNORE
#CONSTANT ERROR_REPORT = 1 // MODE = 1 - REPORT
#CONSTANT ERROR_STOP = 2 // MODE = 2 - STOP
// show all errors
SetErrorMode(ERROR_STOP)
// Window/Screen Constants
#CONSTANT SCREEN_WIDTH = 1024 // Screen Width
#CONSTANT SCREEN_HEIGHT = 768 // Screen Height
#CONSTANT APP_TITLE = "Timer Test"
// set window properties
SetWindowTitle( APP_TITLE )
SetWindowSize( SCREEN_WIDTH, SCREEN_HEIGHT, 0 )
// set display properties
SetVirtualResolution( SCREEN_WIDTH, SCREEN_HEIGHT )
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
UseNewDefaultFonts( 1 ) // since version 2.0.20 we can use nicer default fonts
// App Constants
#CONSTANT CURRENT_TIME_INDEX = 1 // Index Id for current time
#CONSTANT CURRENT_FPS_INDEX = 2
#CONSTANT ALIGN_LEFT = 0
#CONSTANT ALIGN_CENTER = 1 // Set the mode for the text alignment (0 = left, 1 = center, 2 = right)
#CONSTANT CURRENT_TIME_TEXT_SIZE = 40 // Constant variable sets the size of the current time text
#CONSTANT CURRENT_FPS_TEXT_SIZE = 40 // Constant variable sets the size of the current time text
Current_Time$ = GetCurrentTime() // Create a variable and assign it the value of current time
FPS = ScreenFPS()
/// TODO: Modify this in to a function!
// Create our current time text object
CreateText(CURRENT_TIME_INDEX, Current_Time$)
CreateText( CURRENT_FPS_INDEX, str(FPS) )
LoadImage ( CURRENT_TIME_INDEX, "custom-numbers.png" )
LoadImage ( CURRENT_FPS_INDEX, "custom-numbers.png" )
SetTextFontImage ( CURRENT_TIME_INDEX, 1 )
SetTextFontImage ( CURRENT_FPS_INDEX, 2 )
// Sets the text size for current time
SetTextSize(CURRENT_TIME_INDEX, CURRENT_TIME_TEXT_SIZE)
SetTextSize(CURRENT_FPS_INDEX, CURRENT_FPS_TEXT_SIZE)
// Sets the text alignment for current time
SetTextAlignment(CURRENT_TIME_INDEX, ALIGN_CENTER)
SetTextAlignment(CURRENT_FPS_INDEX, ALIGN_LEFT)
// Sets the position on screen of where the current time will be displayed
SetTextPosition(CURRENT_TIME_INDEX, SCREEN_WIDTH / 2, 0)
do
/// TODO: Update Current Time Here
// Updates the current time displayed on screen in real time
SetTextString( CURRENT_TIME_INDEX, GetCurrentTime() )
SetTextString( CURRENT_FPS_INDEX, str(ScreenFPS()))
Sync()
loop