Cocoa Touch Bluetooth TicTacToe (GameKit) [duplicado]

I'm going to create a bluetooth Tic-Tac-Toe App for iPhone. Now I've connected 2 Devices. How do I differentiate Player 1 and Player 2? I want Player 1 to be able to make the first turn (so Player 1 is RED and Player 2 is blue).

The one who Confirms the Connection should be Player 1 and the other one should be Player 2

preguntado el 05 de mayo de 13 a las 14:05

1 Respuestas

This is usually how you do it - upon connection, both devices generate a random number. Then you share the numbers between devices, and then whoever has the bigger number is Player1(RED) and the other one is Player2(BLUE).

Of course don't forget to handle the case where both devices send the same number, if that happens, you should generate and then send a new number. (which is highly unlikely but do it for the sake of completeness).

contestado el 05 de mayo de 13 a las 15:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.