Countdown Timer

Hey guys, I was wondering if it is possible to create a timer that would count down from say 10 minutes and be able to continue counting down even when the app is closed? Any suggestions on how to do this would be much appreciated.
Thanks

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803

    You would need use the game.Clock.[Year,Month,Hour,Minute,Seconds] attributes to have a reference start point(stored with a save attribute behavior) and calculate how much time has passed since then. That is a short tip.

    The longer tip/explanation involves calculations of leap years, end of month, end of day, etc. It would probably be too long and too valuable for a forum post.

  • gregfaulksgregfaulks Member Posts: 21

    yes that's what I thought..
    Thanks for your help @codemonkey

  • MattButlerStudiosMattButlerStudios Member Posts: 486
    edited January 2015

    I got this template from @tatiang‌ some time ago. It has helped me out a ton!

  • gregfaulksgregfaulks Member Posts: 21

    thanks @MattButlerStudios I'll take a look at this

  • staticfritzstaticfritz Member, PRO Posts: 1

    I managed to crack this with a ton of experiments, lots of help via the forum, and support at GS. You need to use the device clock so it runs even when the game is off, then set a time in recent history as a "Constrain Attribute" (four years covers all time variants, including Leap Year, so 2012) and remember to load current Lock State of the timer when the game boots so the timer doesn't forget to display. When the user clicks on your button, it needs to activate the bonus AND starts the clock (changing the Lock State to False). Make sure to make the timer reset and for the READY button to appear when the timer reaches <0 (not =0). If it is set at =0, the timer will not update to clickable status unless the user witnesses it hitting 0.

    I posted a turnkey version at GSHelper called "Countdown Clock for Daily/Hourly Rewards".

Sign In or Register to comment.