Calculating elapsed time

ChunksterChunkster Member Posts: 3
edited August 2012 in Working with GS (Mac)
Hi

I am trying to write a timer that will report the minutes that have elapsed since pressing a button.

Things work fine using a timer to advance a counter by adding one to the counter every minute, but this not very efficient, and certainly does not work if the game shifts to the background when running another app.

Any suggestions/examples on how to monitor the elapsed time so it will work when the app is not open?

Thanks

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    You have access to the system time. You could always log the start time the you would just need to calculate the difference in start time and current time to know how long it has ran. This is going to be the only way to have any idea of the time while the app is closed.

    Cheers
  • ChunksterChunkster Member Posts: 3
    That is what I thought, but I can find no documentation on how to use device.hour, device.minutes and so on.

    Cant even determine what type (real, integer, etc) these variables are in.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    There most likely is not documentation on it. They re probably real attributes. And you will just have to figure the math out to calculate to time elapsed.
  • ADTaylorADTaylor Member Posts: 10
    If you can hang on until the 24/25th August I'm actually going to be putting up a video tutorial on this sort of thing in the Community Tutorials section.

    It will be a demo to show how you can know whether the app has been made inactive either via the home button or switching to another app. This obviously relies on the system time and includes how to find out the elapsed time.

    Have to wait for the game contest I'm currently in to finish before I can get any work done on creating the video though sorry :(
Sign In or Register to comment.