📄 tracks.java
字号:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class Tracks extends List
implements CommandListener
{
private MIDlet midlet;
private GameCanvas nextForm;
private Form previousForm;
private Command backCommand = new
Command("Back", Command.SCREEN, 1);
private static String trackNames[] =
{"City", "Forest", "Mountain"};
private static int lengths[] =
{500, 800, 1400};
private static int speeds[] =
{ 2, 3, 4};
public Tracks(MIDlet midlet, GameCanvas nextForm,
Form previousForm)
{
super("Tracks:", List.IMPLICIT, trackNames, null);
this.midlet = midlet;
this.nextForm = nextForm;
this.previousForm = previousForm;
addCommand(backCommand);
setCommandListener(this);
}
public void commandAction(Command c, Displayable s)
{
if (c.equals(List.SELECT_COMMAND))
{
int trackID = getSelectedIndex();
// Set the length based on the track
nextForm.setLength(lengths[trackID]);
// Set the speed based on the track
nextForm.setSpeed(Float.createFloat(speeds[trackID]));
nextForm.initEnemies();
nextForm.initPowerups();
Display.getDisplay(midlet).setCurrent(nextForm);
nextForm.start();
}
else if (c == backCommand)
{
Display.getDisplay(midlet).setCurrent(previousForm);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -