Reputation: 147
I have made a simple class that allows me to submit scores to my online highscore-system, but I am wondering what I would do if there is no internet connection availible. I save the scores in a plist, but it doesn't get synchronised there, that happens after a player gets a new highscore, after a game thus. If there is no connection with the internet, the score won't get submitted.
My question is : "How can I make sure that the highscores are synchronised when there is a connection availible?"
Thanks in advance,
Joe
Upvotes: 0
Views: 386
Reputation: 5393
The last Cocos2d game I wrote I used Steffen Itterheim’s GameKitHelper class for this to great effect.
Also see:
Integrate Gamecenter in cocos2d game
Synchronizing Offline Game Center Achievements and Scores
You could probably adapt one of these for your own high-score system, but it does beg the question "why not use game center?"
Upvotes: 1
Reputation: 387
I don't know anything about iPhone development yet, but on a logic level, why don't you have a boolean flag set to false stating that it never was synced online yet. Then when the game starts, check the flag and if the flag is false and internet is available update the score data. You can either then set the flag to be true, or delete the value out of the plist.
Upvotes: 0
Reputation: 8147
You can keep a record of the score upload status (with date+time, so you can have multiple scores) in a file and check it on startup for any scores that weren't synchronized.
Upvotes: 0