gameoverform.java

来自「j2me的打飞机的小程序」· Java 代码 · 共 45 行

JAVA
45
字号
package GameTest;

import java.io.IOException;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;

public class GameOverForm extends Form implements CommandListener {
	Image alertImage = null;

	public GameOverForm(String c) {
		super("Game Over");
		String message = "";
		if (FirstGame.score > 100) {
			message = "\n" + "You did a good job! Congratulation!";
		} else if (FirstGame.score > 50) {
			message = "\n good";
		} else {
			message = "\n 加油,继续努力!";
		}
		String alertMessage = FirstGame.userName + "\n" + "Your Score "
				+ FirstGame.score + "\n" + "You have killed "
				+ FirstGame.killEnemyNum + " enemies!" + "\n"
				+ "But, you lose " + FirstGame.loseNum + " enemies!" + "\n"
				+ message;
		try {
			alertImage = Image.createImage("/res/" + "gameover.png");
		} catch (IOException e) {
			e.printStackTrace();
		}

		addCommand(new Command("EXIT", Command.EXIT, 0));
		append(alertImage);
		append(alertMessage);
		this.setCommandListener(this);
	}

	public void commandAction(Command c, Displayable arg1) {
		Navigator.flow(c.getLabel());
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?