使用 html 将 Java Slick 游戏放在网站上 [英] Putting Java Slick game on a website using html

查看:32
本文介绍了使用 html 将 Java Slick 游戏放在网站上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Slick 制作了一个 2D java 游戏,它扩展了 StateBasedGame,它没有扩展 JApplet,所以它不是真正的应用程序,但从下面的链接可以看出 StateBasedGame 是 Slick API 的一部分,它可以使用如果 html 代码编码正确,作为小程序,这里是链接:

I have made a 2D java game using Slick and it extends StateBasedGame, it does not extend JApplet so it is not really a real application but from the link bellow it shows that StateBasedGame is part of the Slick API and it can be used as an applet if the html code is coded correctly, here is the link:

http://ninjacave.com/slickapplet

我尝试修改它以适合我的代码并想出了以下内容:

I tried modifying it to fit my code and came up with the following:

   <applet code="org.lwjgl.util.applet.AppletLoader" 
        archive="lwjgl_util_applet.jar" 
        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> 

我基本上按照指南说的做了,我在 eclipse 中制作了一个我的游戏的 .jar 文件,并将其命名为 Racegame.jar,我下载了 lwjgl-2.8.5 并从网站上复制了 html 代码并为我的游戏(上面显示的代码).lwjgl 在我的桌面上创建了一个文件夹,我打开它,进入名为 jar 的文件夹(这是所有 jar 文件的保存位置)并放入我的 jar 文件,即 Racegame.jar,当我收到以下错误时尝试运行 html 代码:

I basically did as the guide said, I made a .jar file of my game in eclipse and called it racegame.jar, I downloaded lwjgl-2.8.5 and I copied the html code from the website and edited it for my game (the code shown above). The lwjgl had made a folder on my desktop, I opened it, went into the folder called jar (which was where all the jar files were kept) and put in my jar file which was racegame.jar, I got the following error when I tried to run the html code:

ClassNotFoundException
org.lwjgl.util.applet.AppletLoader

ClassNotFoundException
org.lwjgl.util.applet.AppletLoader

这是否意味着在我的 lwjgl 中找不到 AppletLoader?

Does this mean that the AppletLoader cant be found in my lwjgl?

推荐答案

这正是它的意思.因此,请检查以下内容.

This is exactly what it means. So, check the following.

  1. 检查您编写的类名是否确实是 AppletLoader 的完全限定类名.这个 AppletLoader... 是什么意思?行尾的省略号是什么?
  2. 检查jar中的类lwjgl_util_applet.jar
  3. 检查 jar 是否可以从 URL 中获得,就像您用于 HTML 页面的 URL 一样,但是页面名称被 jar 的名称替换,即如果您的 url 是 http://host/app/my.html,请在浏览器中输入 http://host/app/lwjgl_util_applet.jar 并下载它.如果不可用,请检查原因.
  1. Check that class name you wrote indeed the fully qualified class name of your AppletLoader. What does this AppletLoader… mean? What is the elipsis in the end of the line?
  2. Check that the class in jar lwjgl_util_applet.jar
  3. Check that jar is available from URL like one that you are using for your HTML page but where the page name is replaced by name of the jar, i.e. if your url is http://host/app/my.html, type http://host/app/lwjgl_util_applet.jar in your browser and to download it. If it is not available check why.

祝你好运.顺便说一句,你知道小程序在过去近 10 年里几乎已经过时了吗?仅供参考...

Good luck. BTW, do you know that applets are almost obsolete for last almost 10 years? It is just FYI...

这篇关于使用 html 将 Java Slick 游戏放在网站上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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