【问题标题】:Converting Java application to an applet confusion将 Java 应用程序转换为小程序混淆
【发布时间】:2012-03-30 21:46:06
【问题描述】:

我正在创建一个 Space Invaders 类型的克隆,我已经完成了它。现在的问题是我想让我的朋友将此发布到他的网站,因此我需要将其从应用程序转换为小程序。我在网上查看了一些示例并对其进行了一些尝试,并尝试将其放入一个用 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();

}

【问题讨论】:

    标签: java deployment applet


    【解决方案1】:

    这可能是一个更好的主意 - 与其尝试将方形钉(创建 JFrame 的程序)推入圆孔(将其更改为小程序),不如使用 Java Web Start,这样网页可以发布JFrame吗?我认为从长远来看,这会让你更轻松。

    请看这里:

    【讨论】:

    • 我同意 JWS/JFrame 是此用例的最佳选择。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多