How to do a energy bar with system clock timer.

stannystanny Member Posts: 26
edited October 2013 in Working with GS (Mac)
I'm trying to do a simple energy bar. 5 energy maximum which is used for starting games. Whenever one is used, a countdown is started for 30 minutes till it fills up 1 energy. If 2nd energy is used, another clock of 30 minutes will need to start after the current one is completed, and so on. Countdown should also continue when app is not running. Any ideas?

Comments

  • nir3112nir3112 Member, PRO Posts: 312
    edited October 2013
    Hi
    i think you can do like this
    make attribute for the clock (integer=30)
    and make timer that say "every 1 sec change attribute clock by -1"
    all that will work when the app is running...
    so you need to save to timer every time the player died AND save the iphone real clock(mins & hours)
    and load them to another attributes when the game starts
    then create one more attribute (lets call it "sum")
    and then do this commands Change Attribute: "sum" to "real clock (min & hours) - real saved clock" then make rule to check if "sum" >= 30 if yes change attribute "Energy" by +1
    i hope you will understand what i said here if not i hope you get the concept
    (i'm sorry for my english)[=
  • darrelfdarrelf Member Posts: 243
    @stanny Consider using a table to store the time when the energy runs out so the value isn't lost if the player closes the app completely from multi-tasking...
  • stannystanny Member Posts: 26
    I'm trying to save the time the user uses an energy and then at intervals using a timer check by subtracting the current time from it. How would I accomplish this? Do I need a separate attribute for minute,hour,day? What if it has passed the hour, then a minute comparison of ">30" won't work right?
Sign In or Register to comment.