简体   繁体   English

LibGDX-HTML5运行程序,具有联网功能?

[英]LibGDX - HTML5 runner, with networking?

I have a 2D game that I created using the LibGDX Engine . 我有一个使用LibGDX Engine创建的2D游戏。 The game was created for Desktop. 该游戏是为台式机创建的。

Also developed a server for the game. 还开发了游戏服务器。

I use the Netty.io networking library to communicate between the server and the client. 我使用Netty.io网络库在服务器和客户端之间进行通信。

Everything works fine, but I want to let users that has no Java installed to play, and the solution I found is use the HTML5 runner that LibGDX offers. 一切正常,但是我想让没有安装Java的用户玩,而我发现的解决方案是使用LibGDX提供的HTML5运行程序。

But if I convert it to HTML5, I have to re-do the networking part for the HTML5 client with websockets, and add a support for a websocket connection in the server, is that correct? 但是,如果将其转换为HTML5,我必须使用websockets重新做HTML5客户端的网络部分,并在服务器中添加对websocket连接的支持,对吗?

Is there any other solution for this? 还有其他解决方案吗?

On the Netty.io website you linked, I see support for Websockets, but no JS implementation. 在您链接的Netty.io网站上,我看到了对Websockets的支持,但是没有JS实现。 So the answer depends if there is a JS implementation for Netty.io available (like Socket.io has clients for Java and JS). 因此答案取决于是否有Netty.io的JS实现可用(例如Socket.io具有Java和JS的客户端)。

If Netty has implementations both for Java and JS, you have to extract all methods you use to an interface that you call in your core project. 如果Netty同时具有Java和JS的实现,则必须将使用的所有方法提取到在核心项目中调用的接口。 The interface implementations for Android and Desktop projects would be the Java implementations you currently use, while for GWT backend you would use JSNI calls to the JS implementations. Android和Desktop项目的接口实现将是您当前使用的Java实现,而对于GWT后端,您将使用JSNI调用JS实现。

For an example, you can see my Github project for using game services: The Google Play Games implementations are available for HTML, Desktop and Android, all implemented against the same interface and HTML implementation is using JSNI calls to Google's JS lib: https://github.com/MrStahlfelge/gdx-gamesvcs/blob/master/html-gpgs/src/de/golfgl/gdxgamesvcs/GpgsClient.java 例如,您可以看到我的Github项目用于游戏服务的使用:Google Play游戏实现可用于HTML,桌面和Android,所有实现都针对同一接口,并且HTML实现使用对Google JS库的JSNI调用: https:/ /github.com/MrStahlfelge/gdx-gamesvcs/blob/master/html-gpgs/src/de/golfgl/gdxgamesvcs/GpgsClient.java

If there is no JS implementation for Netty.io available, you will have to do it yourself or switch to another network layer. 如果没有适用于Netty.io的JS实现,则您必须自己完成操作或切换到另一个网络层。

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

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