📄 bambodance.java
字号:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class BamboDance extends MIDlet implements CommandListener {
public BamboDance() {
started = false;
}
public void startApp() {
if (!started) {
display = Display.getDisplay(this);
ts = new Gamescreen(this);
back = new Command("Back", 2, 1);
submit = new Command("Submit", 1, 1);
instruction = new Form("Instructions");
instruction.append("How to play:");
about = new Form("About");
about.append("Name:\nBambooDance\n\nDeveloper:\nMBounce Ltd\n\nVersion:\n1.0\n\nCopyright:\nMBounce Ltd 2003");
about.addCommand(back);
about.setCommandListener(this);
instruction.append("You are a bamboo dancer at the jungle. 2 pandas will be moving the bamboo sticks and collide together occasionally, don't get your feet trap in the sticks! Follow the arrow signs by pressing the indentical direction on the arrow keys as quick as possible, or your feet will be trapped!");
instruction.addCommand(back);
instruction.setCommandListener(this);
textbox1 = new TextBox("Enter your name", "", 6, 0);
textbox1.addCommand(submit);
textbox1.setCommandListener(this);
started = true;
}
display.setCurrent(ts);
}
public void showAbout() {
display.setCurrent(about);
}
public void enterName() {
display.setCurrent(textbox1);
}
public void showForm() {
display.setCurrent(instruction);
}
public void showScore() {
makeScoreForm();
display.setCurrent(scoreForm);
}
private void makeScoreForm() {
scoreForm = new Form("High scores");
scoreForm.addCommand(back);
scoreForm.setCommandListener(this);
for (int i = 0; i < 5; i++) {
Gamescreen _tmp = ts;
scoreForm.append("No " + (i + 1) + ": " + Gamescreen.rankName[i]);
scoreForm.append("\n");
Gamescreen _tmp1 = ts;
scoreForm.append("Score: " + Gamescreen.rankScore[i] + "\n");
scoreForm.append("----------------------\n");
}
}
public void commandAction(Command command, Displayable displayable) {
if (command == submit) {
ts.updateRank(textbox1.getString());
Gamescreen _tmp = ts;
Gamescreen.gamestate = -100;
display.setCurrent(ts);
} else
if (command == back) {
display.setCurrent(ts);
}
}
protected void destroyApp(boolean flag) {
exit();
}
public void exit() {
display.setCurrent(null);
notifyDestroyed();
}
protected void pauseApp() {
}
Display display;
Command back;
Command submit;
Gamescreen ts;
Form instruction;
Form scoreForm;
Form about;
TextBox textbox1;
boolean started;
TextField username;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -