Hi all,
It's been some time since I have done any programming in AGK2 and I think my brain has just melted. I am probably being very dumb here but I am looking for a way to update GetCurrentTime() as a text object.. If this is possible at all, so I can display the time in the app as I think it will be a nice little feature.
I guess it needs to go into the main loop so it can update. However, I can only see the print command available which updates the GetCurrentTime(), if I add the CreateText() command to the do loop it just moans at me that the index id already exists (as it is trying to create the same object every frame), so I tried a conditional such as if GetTextExists(CURRENT_TIME_INDEX) = 1 /* create the text etc.. */ endif but this again leaves me in the same boat where the time doesn't update.
Any help on this would be greatly appreciated.
Here is what I have so far:
// Project: App Prototype
// Created: 2017-01-04
// 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 = "App Prototype"
// 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 ALIGN_CENTER = 1 // Set the mode for the text alignment (0 = left, 1 = center, 2 = right)
#CONSTANT CURRENT_TIME_TEXT_SIZE = 16 // Constant variable sets the size of the current time text
Current_Time$ = GetCurrentTime() // Create a variable and assign it the value of current time
/// TODO: Modify this in to a function!
// Create our current time text object
CreateText(CURRENT_TIME_INDEX, Current_Time$)
// Sets the text size for current time
SetTextSize(CURRENT_TIME_INDEX, CURRENT_TIME_TEXT_SIZE)
// Sets the text alignment for current time
SetTextAlignment(CURRENT_TIME_INDEX, ALIGN_CENTER)
// 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
Sync()
loop
Kind Regards
GunnerJnr