playMaker

Author Topic: How to add while app is off?[SOLVED]  (Read 2082 times)

docdolittle

  • Playmaker Newbie
  • *
  • Posts: 2
How to add while app is off?[SOLVED]
« on: April 15, 2015, 03:37:00 PM »
What is the best way to add to an int from the amount of time the app has been turned off?

I've been looking at the 'Get System Date Time' part but I'd thought I'd ask first just incase I've missed something. Also, while setting this up is there a way to make sure people can't just set their system clock forward to cheat it?
« Last Edit: April 17, 2015, 01:44:14 PM by jeanfabre »

allornothing

  • Playmaker Newbie
  • *
  • Posts: 20
Re: How to add while app is off?
« Reply #1 on: April 15, 2015, 06:18:18 PM »
Not sure on the time since off issue, you would need to somehow grab the time when the user closes or multitasks away from the app, store it, then compare with new time on re-launch. I'd be keen to hear solutions for this too though!

With regards to cheating, I believe the only way around it (and the most commonly used solution) is to grab the time from a server online rather than the device.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to add while app is off?
« Reply #2 on: April 16, 2015, 01:46:13 AM »
Hi,

 you'll need to listen to the application pause event, using the action on this post

http://hutonggames.com/playmakerforum/index.php?topic=1591.msg14044#msg14044

then yes, record the time at the pause, save it in prefs ( safer than in memory if the user decides to kill the app while paused). and then when resuming compute the difference and adjust values.

bye,

 Jean

docdolittle

  • Playmaker Newbie
  • *
  • Posts: 2
Re: How to add while app is off?
« Reply #3 on: April 16, 2015, 02:01:36 PM »
Thats great Jean, thanks so much for the help! :D