Figuring out when the app is opened

For the app I'm working on I need to be able to reset the scene when the app is launched. Right now on the device when it is opened it resumes where it left off which does not work for my game. Right now I have the game save the system time every second and then check to see if system time differs from that number. For example the last saved number before they closed the app was 4:30:45 and when the opened it up again the system time was 4:30:49. When there is a gap between the numbers it resets the scene but in addition to doing this when it is opened, it is also triggered if the game lags, if the open the control center, or if they open their notifications. Is there another more reliable way I could detect when the app is launched? Thanks

Comments

  • ArmellineArmelline Member, PRO Posts: 5,369

    If you are wanting to know when the app is launched, just use an attribute you don't save, but set to true when you first launch the app.

    If you want to know when the app is made inactive, but doesn't actually close (i.e. you press home, then tap on the app icon again), you'll need to track the amount of time that's passed since the last app launch. Which gets complicated :D @tatiang has a demo somewhere I think.

  • AkuwiEntertainmentAkuwiEntertainment Member Posts: 53

    Thank you. Yeah i'm trying to figure out when it has been inactive. I have it working but it has got some problems. Just wanted to know if there was a better way :smiley:

Sign In or Register to comment.