将我的 Java Slick 游戏放到网站上 [英] Putting my Java Slick game onto a website
问题描述
我使用基于状态的游戏在 Java 中制作了一个 GUI,因为它扩展了 StateBasedGame
而不是 JApplet
它不是一个真正的小程序,我想把它放在一个网站上我不确定如何执行此操作,有人告诉我,以下代码允许我使用 html 将其制作成小程序,而不必编辑 Java 代码:
I have made a GUI in Java using State Based Game, as it extends StateBasedGame
and not JApplet
its not a true applet, I want to put it on a website and am unsure on how to do this, I have been told that the following code allows me to make this into an applet using html and not having to edit the Java code:
<applet code="org.lwjgl.util.applet.AppletLoader"
archive="org.lwjgl.util.applet.AppletLoader"
codebase="."
width="640" height="480">
<param name="al_title" value="Ham Blaster">
<param name="al_main" value="org.newdawn.slick.AppletGameContainer">
<param name="game" value="org.javagame.Game">
<param name="al_jars" value="racegame.jar, lwjgl.jar, slick.jar">
<param name="al_windows" value="windows_natives.jar">
<param name="al_linux" value="linux_natives.jar">
<param name="al_mac" value="macosx_natives.jar">
<param name="separate_jvm" value="true">
</applet>
当我运行 html 代码时,我的屏幕中央出现以下错误:
When I run the html code I get the following error on the centre of my screen:
An error occurred while loading the applet. Please contact support to resolve this issue. missing required applet parameter: al_main.
我查看了 ApplerGameContainer
的 slick 内部,但我只能找到 chrome 文件,我尝试将这些文件与 html 文件放在同一目录中,但我仍然遇到相同的错误.
I have looked inside slick for the ApplerGameContainer
but I can only find chrome files, I tried putting these in the same directory as the html file but I still get the same error.
如果有些事情看起来很简单并且问我似乎太明显了,请告诉我,因为我是 Java 新手,我之前使用此代码的错误是因为我的 html 和 lwjgl_util_applet.jar 不在同一目录中,所以请告诉我任何可能对我有帮助的.
If something seems very simple and may seem too obvious to ask me, please tell me because I am new to Java, my previous error with this code was because I did not have my html and lwjgl_util_applet.jar in the same directory, so please tell me anything that may help me.
推荐答案
Emm...
我不太确定,但根据 sources 错误来自 init 方法
I am not pretty sure, but according to sources the error comes from init method
/*
* @see java.applet.Applet#init()
*/
public void init() {
state = STATE_INIT;
// sanity check
String[] requiredArgs = {"al_main", "al_logo", "al_progressbar", "al_jars"};
for(int i=0; i<requiredArgs.length; i++) {
if(getParameter(requiredArgs[i]) == null) {
fatalErrorOccured("missing required applet parameter: " + requiredArgs[i], null);
return;
}
//... }
}
所以看起来你的 al_main 参数值是 null 或什么:S
so it seems your al_main param value is null or something :S
问题可能出在这里
<param name="al_main" value="org.newdawn.slick.AppletGameContainer">
... 可能 因为我没有看到您将所有其余必需的参数初始化为 "al_logo", "al_progressbar"
... maybe because I don't see you to init all the rest required params as "al_logo", "al_progressbar"
不管怎样,把问题代码给你看会更有帮助
Anyways, it would be more helpful you to show the problem code
如果有帮助请报告
这篇关于将我的 Java Slick 游戏放到网站上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!