So GetPaused() doesn't do this? In order to get to the Cancel screen you have to pause the app right?
Sorry. My bad. Only applies to Desktop. I'll do some research
*EDIT*
There is a perceptible drop in frame rate just prior to the app going into sleep mode.
In order to make it work i think you would need to average the frame rate and if it strayed a certain amount then save your data.
I would also make sure that after writing out your data you pause for some amount of time before checking again, In case of an unforeseen slowdown that would cause it to constantly write out the file.
Here is a very simple example that will write out a line to a file when the home button is press (or some unforeseen event causes a slowdown)
// Project: test102
// Created: 20-01-09
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "test102" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
setvsync(1)
mode as integer
i as integer
f as integer
lastMs as float
Ms as float
Diff as float
Data as string
do
if GetResumed() = 1
mode = 1
f = OpenToRead("savefile")
Data = ReadLine(f)
CloseFile(f)
endif
print("Diff="+str(Diff))
print("Data="+Data)
if mode = 0
LastMs = Timer()
endif
Sync()
if mode = 0
Diff = Timer() - LastMs
endif
if mode = 0 and Diff > 0.5
f = openToWrite("savefile")
WriteLine(f, "Look at that. I wrote out all the data!")
CloseFile(f)
endif
loop
Hope this helps