我製作了一個使用Java的遊戲,我的遊戲是一個基於狀態的遊戲,所以它擴展了StateBasedGame,我想把遊戲放在一個網站上,這需要我將它變成一個小程序(除非有另一種方式),所以它也必須擴展JApplet,在嘗試擴展多個類並在線閱讀之後,我沒有運氣,並且在論壇帖子上閱讀,它不可能有多個擴展。現在這是否意味着我無法將我的遊戲放到網站上?Java上的多個擴展
這裏是我的主類,到目前爲止,它延伸StateBasedGame:
package javagame;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
public class Game extends StateBasedGame{
public static final String gamename = "Croft";
public static final int menu = 0;
public static final int play = 1;
public Game(String gamename){//create window on statup
super(gamename);//adds title to screen
this.addState(new Menu(menu));//"this" means get from this class
this.addState(new Play(play));
}
public void initStatesList(GameContainer gc) throws SlickException{
//we need this because we inhereted from StateBasedGame, gc manages behind the scene stuff
this.getState(menu).init(gc, this);//telling java what states we have
this.getState(play).init(gc, this);
this.enterState(menu);//tells java that you want to show menu before play
}
public static void main(String[] args) {
AppGameContainer appgc;//the window for your game
try{
appgc = new AppGameContainer(new Game(gamename));//window holding the Game
appgc.setDisplayMode(640, 360,false);//size, sizetrue would make it full screen //640,360
appgc.start();//creates the window
}catch(SlickException e){//built into slick for error handelling
e.printStackTrace();}
}
}
EDIT1:
的html代碼:
<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="slick.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>
我的jar文件的名稱是racegame,我的主類是遊戲中,我的軟件包名稱是javagame。
錯誤:ClassNotFoundException的 org.lwjgl.util.applet.AppletLoader
這是什麼狀態?你解決了這個問題嗎? – tsm