坚持一个我似乎无法解决的简单代码? [英] Stuck on a simple code that I can't seem to fix?

查看:63
本文介绍了坚持一个我似乎无法解决的简单代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿CodeProject!



我目前正在使我的游戏在线,并且只有一个错误(更像是一个问题),我似乎无法解决。



假设我的玩家走进另一个世界(/地图)。我的客户(玩家)会尽快绘制世界,但是当玩家是游戏新玩家并且尚未从服务器接收到地图时,它无法绘制它,对吧?



我的意思是,世界将设置为null,直到服务器告诉客户端地图是什么。



那么,在收到地图之前,我怎么能抓住客户端(非常像Thread.Sleep)?这是我到目前为止的尝试:



Hey Codeproject!

I am currently making my game Online, and there is only one error(Well more like a question) that I can't seem to solve.

Assuming that my player walks into another World(/Map). My client(Player) will draw the world as soon as it does so, however when the player is new to the game and it has not yet received the map from the server it can't draw it, right?

I mean, the World will be set to null until the server tells the client what the map is.

So, how would I hold the client(Pretty much like Thread.Sleep) until it has received the map? This is my attempt so far:

World Map;
Map = GetMap(true); // Get the map, and true for requesting the server.


while ((Map = GetMap(false)) == null)
  {
    /* Loop until the map is no longer null. */
    Thread.Sleep(20);
  }

Player.Map = Map;





这似乎不起作用,因为while循环实际上阻止了游戏也接收TCP数据包。



:/任何帮助?



This doesn't seem to be working, because the while loop actually prevents the game from also receiving the TCP packets.

:/ Any help?

推荐答案

好吧我开始即兴创作,并意识到为什么我没有检查图纸和其他需要地图的代码为什么我不会检查它是否为空。



修好了!
Alright I started improvising again, and realised why I just didn't check at the drawing and other codes that require the map why I just won't check if it's null or not.

Got it fixed!


这篇关于坚持一个我似乎无法解决的简单代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆