Reputation: 63
I'm trying to understand the most logical way of creating an iOS game that runs continuously in the background.
For example.. you have tower and enemy waves. The game has endless enemy waves even when the game exits. When you open the game again, it will retrieve the data that occurred when the app was closed.
I assume a database on a server would be the best solution. The values continuously increment on the server. The game connects to the server and retrieves the specific user's updated game data.
Upvotes: 1
Views: 175
Reputation: 1006
A server / database will only be helpful if you would like to present your information to multiple users, for a high score board for example.
In your case it seems that the easiest way to do it would be to store locally the time when the app was exited, and when you open the game again, you compare the current time to time stored before, and you calculate the impacts of all waves occuring between time now - time before.
Example: let's say you have 10 enemy monsters per minute, i exit the game i store the time (12:35), i open the game again at 12:45, 10 minutes difference * 10 enemy monsters have attacked my towers... From there you calculate the impact of 100 enemy monsters on your towers :)
Makes sense ? And all without any complicated client / server programming.
Cheers
Upvotes: 3