简体   繁体   English

创建libGDX小程序

[英]Creating libGDX applet

I know there's a guide on how to create a libGDX applet, but I feel it's highly outdated and somewhat confusing. 我知道有一个有关如何创建libGDX applet的指南,但是我觉得它已经过时且有些混乱。 Here's what I've already done: 这是我已经完成的工作:

  1. Created applet class in my desktop project: 在我的桌面项目中创建了applet类:

     public class DesktopApplet extends LwjglApplet { private final static LwjglApplicationConfiguration DEFAULT_CONFIG = new LwjglApplicationConfiguration() { { width = 512; height = 512; } }; public DesktopApplet() { super(new Core(),DEFAULT_CONFIG); } private static final long serialVersionUID = -1916205038641068252L; } 
  2. Exported desktop project as a regular jar. 将桌面项目导出为常规jar。 Added the project's jar (along with gdx and all lwjgl jars in "applet/basic" folder). 添加了项目的jar(以及gdx和“ applet / basic”文件夹中的所有lwjgl jar)。

  3. Created a html file, based on basic lwjgl applet and the tutorial: 根据基本的lwjgl applet和教程创建了一个html文件:

     <applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar" codebase="." width="512" height="512"> <!-- Name of Applet, will be used as name of directory it is saved in, and will uniquely identify it in cache --> <param name="al_title" value="mygametitle"> <!-- Main Applet Class --> <param name="al_main" value="my.packages.desktop.DesktopApplet"> <!-- List of Jars to add to classpath --> <param name="al_jars" value="mygamejar.jar, gdx.jar, gdx-backend-lwjgl.jar, lwjgl_applet.jar, lwjgl.jar, jinput.jar, lwjgl_util.jar"> <!-- signed windows natives jar in a jar --> <param name="al_windows" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar, windows_natives.jar"> <!-- signed linux natives jar in a jar --> <param name="al_linux" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar, linux_natives.jar"> <!-- signed mac osx natives jar in a jar --> <param name="al_mac" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar, macosx_natives.jar"> <!-- signed solaris natives jar in a jar --> <param name="al_solaris" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar, solaris_natives.jar"> 
  4. Created a keystore file. 创建了密钥库文件。 Deleted default lwjgl signing (META-INF folders), added timestamps to the signing command, created a bash script for jar signing and - finally - signed all jars. 删除默认的lwjgl签名(META-INF文件夹),在签名命令中添加时间戳,创建用于jar签名的bash脚本,最后-对所有jar进行签名。 While signing produces no errors, jarsigner -verify returns one warning "This jar contains entries whose certificate chain is not validated." 签名没有错误时, jarsigner -verify返回一个警告“此jar包含证书链未经验证的条目”。 and I'm not sure how to get rid of it. 而且我不确定如何摆脱它。 Here's my signing command: jarsigner -keystore .keystore -digestalg SHA1 -tsa http://timestamp.comodoca.com/rfc3161 -storepass mypass $jar gdxkey . 这是我的签名命令: jarsigner -keystore .keystore -digestalg SHA1 -tsa http://timestamp.comodoca.com/rfc3161 -storepass mypass $jar gdxkey

  5. Changed Java security level to medium. 将Java安全级别更改为中。 It allowed me to - finally - run the applet without security errors (thanks kabb!). 最终,它使我能够运行小程序而不会出现安全错误(感谢kabb!)。

  6. The applet... doesn't work. 小程序...不起作用。 It stays that an error occurred when "Switching applet". 仍然存在“切换小程序”时发生错误的情况。 I'm not sure if I exported the right projects - should I include a jar with desktop project or just the core and manually add all assets and libraries? 我不确定是否导出了正确的项目-我应该在桌面项目中添加jar还是仅包含核心,然后手动添加所有资产和库?

The issue is that the applet is self signed. 问题是小程序是自签名的。 As of JDK7u51, self signed and unsigned applications are blocked if your java security settings are set to high or above. 从JDK7u51开始,如果将Java安全性设置设置为高或更高,则自签名和未签名的应用程序将被阻止。 You can read more about this here . 您可以在此处了解更多信息。

To be able to test your applet, you can simply go to the java control panel, go to the security tab, and set the security level to medium. 为了能够测试您的小程序,您只需转到Java控制面板,转到“安全性”选项卡,然后将安全性级别设置为“中”即可。

However, if you wish for other people to be able to run your applet without having to go through the hassle of changing their security settings, you'll have to get a certificate by a Certificate Authority, and sign your applet using that. 但是,如果您希望其他人能够运行您的applet而不必经历更改其安全设置的麻烦,则必须获得证书颁发机构颁发的证书,并使用该证书对applet进行签名。 Unfortunately, this costs money, and there is no workaround to it that I know of. 不幸的是,这要花钱,而且我还没有解决方法。

If you want to run your game in a browser, you could consider using GWT instead. 如果要在浏览器中运行游戏,则可以考虑使用GWT。 LibGDX has some tutorials on it's wiki on how to setup a project with GWT. LibGDX的Wiki上有一些教程,介绍如何使用GWT设置项目。 However, it could be a hassle, especially if you're using libraries not supported by GWT. 但是,这可能很麻烦,特别是如果您使用的是GWT不支持的库。

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

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