I am having trouble with multiplayer player movement in my game.
The client is in AS3 and the server is in C#.
Here is my problem: When I first launch the game, it connects to the server, and everything works fine. But... when I try to move my player, it isn't sending the UTF8 bytes over to the server. I even have it trace output after the socket sends the bytes. I sent the exact same bytes to the server when the game started just to see if the server recognized it, and it did.
I am not sure why it isn't even sending it at all. This is very frustrating.
private function keyDown(event:KeyboardEvent):void
{
switch(event.keyCode)
{
case Keyboard.W:
up = true;
break;
case Keyboard.S:
down = true;
break;
case Keyboard.A:
left = true;
break;
case Keyboard.D:
right = true;
break;
}
}
private function keyUp(event:KeyboardEvent):void
{
switch(event.keyCode)
{
case Keyboard.W:
up = false;
break;
case Keyboard.S:
down = false;
break;
case Keyboard.A:
left = false;
break;
case Keyboard.D:
right = false;
break;
}
}
private var playerSpdTemp:int = 5;
private function enterFrame(e:Event):void{
if (up){
archer.y -= playerSpdTemp;
socket.writeUTFBytes("move--"+archer.x+":"+archer.y);
trace("Sent...");
}
if (left){
archer.x -= playerSpdTemp;
}
if (down){
archer.y += playerSpdTemp;
}
if (right){
archer.x += playerSpdTemp;
}
}
I tried putting the socket.writeUTFBytes()
in the keyDown and keyUp functions but nothing happens either...
And yes, I have the correct event listeners set up. The player moves correctly but not the socket.