In-game time passing when app is closed

Monkey Targets Forums/iOS/In-game time passing when app is closed

rIKmAN(Posted 2013) [#1]
What is the best way to handle in-game time passing when an app is closed?

From what I have read OnRender() and onUpdate() are put to sleep, so I would guess some check against Millisecs() in onResume(), unless that goes to sleep too?

I'm looking to have the game carry on (or give the impression of it carrying on) when the player isn't playing and the app may be either closed completely or minimised.


c.k.(Posted 2013) [#2]
Can you write the date/time upon closing and then read that back and compare upon resuming?


rIKmAN(Posted 2013) [#3]
Yeah that was kind of what I meant by comparing against Millisecs(), but I'm not sure if that would work due to how Millisecs() works?


c.k.(Posted 2013) [#4]
Can you use Diddy's RealMillisecs()? I think it is based on the device's clock. Then you'd have to find a way to get the date.

You could also have it contact a clock on a server out there, somewhere...


rIKmAN(Posted 2013) [#5]
I'll have to have a look at Diddy to see about the RealMillisecs() so thanks for that info.

The server idea is out as it would require an internet connection, which I don't really want to be a necessity for the game to run properly.

I just thought there would be an easy way to do it that I had totally missed.


anawiki(Posted 2013) [#6]
I think games like Smurfs must be using some kind of push notifications to handle this. For sure it recalculates things in "on resume", but to display notifications that "crops are ready to harvest" they must be using something that works in the background.


rIKmAN(Posted 2013) [#7]
Are things like push notifications possible in Monkey?


graphikoDE(Posted 2013) [#8]
Are things like push notifications possible in Monkey?

I have the same question.


c.k.(Posted 2013) [#9]
Yes, push notifications are possible with monkey, if I get what you're asking. It's just a simple communication between a server and the client (monkey app on the target).

Push notifications come from a server, so you'll have to be connected to the Internet.

I think your monkey program just opens a socket to the server, and the server pushes notifications when desired. But, again, that requires an Internet connection. Your monkey program can also poll for new notifications. That way, your connection doesn't have to be continuous.