简体   繁体   English

即使我注册也没有注册Kryonet类

[英]Kryonet class not registered even though I register

I'm making a 2d game and want to implement multiplayer , to be easier I'm using an API called Kryonet . 我正在制作2D游戏,并且想要实现多人游戏 ,为了更容易,我使用了一个名为Kryonet 的API Following this tutorial . 遵循本教程 The version of Kryonet I'm using is, like the tutorial, 1.04. 我使用的Kryonet版本与本教程类似,为1.04。


I saw all the 6 videos and my code looks a bit like him as you can see: 我看了全部6个视频,并且您看到的代码看起来有点像他:

Client : 客户

Server : 服务器


It seems to be fine but then I run the server and the client and on client I get : 似乎很好,但是随后我运行服务器和客户端,并在客户上得到

客户端控制台输出

Server runs without an error. 服务器运行无错误。


Thanks in advance. 提前致谢。

Just found the problem by looking at the Kryonet Examples , it was that on the register method at Multiplayer class it shouldn't be: 通过查看Kryonet示例才发现问题,那是在Multiplayer类的register方法上不应该这样:

Kryo kryo = new Kryo();

But instead 但反而

Kryo kryo = client.getKryo();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM