-3
我正在做一個任務,我需要使用XNA開發機器人環境,並使用另一臺計算機的c#TCP/IP套接字技術控制機器人。但是,當我將服務器代碼插入XNA時,它會啓動,但遊戲無法加載。從其他計算機移動精靈
protected override void Update(GameTime gameTime)
{
//Server Settings
ipAddress = IPAddress.Parse("192.168.0.11");
myList = new TcpListener(ipAddress, 8000);
myList.Start();
s = myList.AcceptSocket();
b = new byte[100];
int? k = s.Receive(b);
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
if (Keyboard.GetState().IsKeyDown(Keys.Right))
//if (k != null)
myRectangle.X += 3;
if (Keyboard.GetState().IsKeyDown(Keys.Left))
myRectangle.X -= 3;
if (Keyboard.GetState().IsKeyDown(Keys.Up))
myRectangle.Y -= 3;
if (Keyboard.GetState().IsKeyDown(Keys.Down))
myRectangle.Y += 3;
//Screen Boundries
if (myRectangle.X <= 0)
myRectangle.X = 0;
if (myRectangle.X + myTexture.Width >= screenWidth)
myRectangle.X = screenWidth - myTexture.Width;
if (myRectangle.Y <= 0)
myRectangle.Y = 0;
s.Close();
myList.Stop();
base.Update(gameTime);
}
任何想法?????
你會得到什麼錯誤?你有沒有嘗試單步執行代碼? – MyCodeSucks 2013-03-21 16:39:16
是的。我試過我沒有收到任何錯誤,但沒有發生任何事情 – mshiyam 2013-03-21 17:54:17