I am creating an Android game and have come across a problem. It is a simple Pong style game where a bat is moved left or right to block a ball. However I am trying to control the bat via a UDP connection. I have my server set up on my Android code and then a separate Java class for the client. At the minute I can only send strings or longs from the client to server. What I am trying to achieve is, on the client while it is waiting for an input if I press the left or right arrows then it will get this data, convert it to bytes and then send it to the server. The server should then receive the data as a key press so that the bat image of the game will move in the appropriate direction. If anyone has any idea how to do this it would be greatly appreciated. Thanks
Asked
Active
Viewed 1,476 times
2 Answers
1
I recently created a game myself where I also needed to do some client-server synchronisation. I came across the KryoNet library which also works for Android.
http://code.google.com/p/kryonet/
It might be worth looking into it since it's not that hard to grasp
Good luck on your game!

Byron Voorbach
- 4,365
- 5
- 27
- 35
0
You have to make your own "server codes." What I mean by that is you should send certain key words to the server to let it know that a specific action should be taken. In Sun's tutorials on creating sockets, you're able to see that the connection does not close until a keyword has been sent to the server. You are able to do the same with this.
The Server and Client Example, Telling When The Server Should Close

Anthony
- 496
- 3
- 9