开发者

Game Center get players in order they were added to the game

开发者 https://www.devze.com 2023-03-08 01:53 出处:网络
I am trying to get an array of all players in a match game but in the order they were added to the game this must also indicate the position the local player was added to the game as well.

I am trying to get an array of all players in a match game but in the order they were added to the game this must also indicate the position the local player was added to the game as well.

E.g The f开发者_开发技巧ollowing join (Sarah, Rachael, Me, John) in that order. Could i then get an array including myself in position 2 in the array?

Thanks for any help


There is nothing like this built in, but here is how I would solve the problem: When you connect to the game, save the current time ([NSDate date] NSDate stores the time pretty precise in the GMT time zone, so no worry about time zone mess ups). When you need to build the array, you can request the times the other clients joined and then use the differences to determine who joined first.

If you use a client/server infrastructure where one peer plays the server, you can build the array there but just sending a handshake from the joined client, the server then maintains the list with clients. Hope this helps.

0

精彩评论

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