簡體   English   中英

將Java應用程序轉換為applet混亂

[英]Converting Java application to an applet confusion

我正在創建一個Space Invaders類型的克隆,並且快完成了。 現在的問題是,我想讓我的朋友將此內容發布到他的網站上,因此我需要將其從應用程序轉換為applet。 我在網上看了一些示例,並對其進行了一些嘗試,然后嘗試將其放到用html制作的簡單網頁中,但是我似乎無法使其正常工作。 有人可以看一下我的代碼,然后帶領我完成此轉換嗎? 我將不勝感激任何幫助! 我正在發布應用程序代碼,因此我嘗試過的任何事情都不會混淆。

public class InvadersMain implements KeyListener{

// GUI, Keyboard, Game Data here
private JFrame frame;
private JPanel playArea;
private JPanel sidePanel;
private JLabel scoreLabel;
private JLabel scoreDisplay;
private JLabel livesLabel;
private JLabel livesDisplay;
private JLabel title1;
private JLabel title2;


private final int playWidth = 500;
private final int playHeight = 500;

public String name = "";

public int baddysDead = 0;
public int playerScore = 0;
public int playerLives = 3;
public int waveNumber = 1;
public int waveScore = 20;

public double baddySpeed = 1 + (waveNumber-1)/5000;
// Game Data
private InvadersShip ship;

public ArrayList<InvadersShot> shots;
public ArrayList<InvadersBaddy> baddys;

private boolean shipDead; // Whether or not the ship has been blown up
private long shipTimeOfDeath; // The time at which the ship blew up

// Keyboard data
private boolean rightHeld = false;
private boolean leftHeld = false;
private boolean firing = false;

// Set up the game and play
public InvadersMain(){

    // set everything up
    configureGUI();
    configureGameData();

    // display window
    frame.setVisible(true);

    // start game
    playGame();
    name = JOptionPane.showInputDialog( null, "GAME OVER \nPlease enter your name");

}

我正在嘗試隔離需要更改的部分,因此,如果需要進一步處理,請告訴我。

public static void main(String[] args){
    new InvadersMain();

}

這可能是一個更好的主意-與其嘗試將方釘(創建JFrame的程序)推入圓孔(將其更改為applet),不如使用Java Web Start,以便在Web頁上發布JFrame? 我認為,從長遠來看,這將使您更輕松。

請在這里看看:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM