开发者

turn based iphone game networking

Is there a way to create a game that is turn based without having to set up a server for it? For example, say you want to make a chess game. You want users to be able to take a turn whenever they have the chance during the day (rather than playing the match right then with the opponent). When the user makes 开发者_如何转开发a move, the opponent needs to now make a move. Is there an api from apple that will handle such simple multiplayer networking functionality? Or is the only possibility to create a server to handle the backend? This is obviously only for extremely simple apps/games.


As announced at WWDC 2011 keynote address, turn-based game support is coming to Game Center with iOS 5.0, however we are not allowed to discuss the details here while it's under NDA so you should just check it out at the beta section of iOS Dev Center under what's new in Game Kit and ask any related question in the developer forums.

(note: both links require iPhone Developer Program account and acceptance of the latest agreement)


Currently the Answer is No

You are essentially asking, is there a way to save application state in such a way that allows two disconnected gamers to both access that saved application state without using any sort of external save mechanism.

When asked that way, I think the answer is fairly clear -- no. You have to save your state somewhere and since each gamer's app doesn't have any way to message the other gamer's app to request state, you are stuck.

Having said that, saving game state to an external mechanism such as Amazon S3 is exceedingly simple. All you would really need to save is a key that has values for each gamer's id, the current state of the game and which player's turn it is.

Soon the Answer Will Be Yes...Sorta

There are some upcoming changes in iOS5 which will allow you to do this without setting up the external storage mechanism yourself. This may be what you are interested in. But in this case, there is still a server involved -- you just don't have to set it up.

Hope this helps.


The basic pattern is:

  • Player A takes a Turn
  • Player A's Program Saves the Game State(eg to a file).
  • Game State is Transferred to Player B
  • Player B takes a Turn
  • Player B's Program Saves the Game State.
  • Game State is Transferred to Player A.

You transfer the game state using what ever method you want (even email).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜