📄 cutoff.java
字号:
package cutOff;import java.util.*;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;/** * This is the main class of the mini games. * * @author Jeremiah McLeod */public class cutOff extends MIDlet implements CommandListener { private Command myExitCommand = new Command("Exit", Command.EXIT, 1); private Command myPauseCommand = new Command("Pause", Command.SCREEN, 2); private Command myGoCommand = new Command ("Go",Command.SCREEN, 3); private Command myNewGameCommand = new Command ("New Game",Command.SCREEN,4); private long pauseTime; //* the the canvas that all of the game will be drawn on. //*/ cutOffCanvas myCutOffCanvas; /** * the thread that advances the animation */ GameThread myGameThread; //----------------------------------------------------- // initialization and game state changes /** * Initialize the canvas and the commands. */ public cutOff () { pauseTime=0; myCutOffCanvas = new cutOffCanvas(this); myCutOffCanvas.addCommand(myExitCommand); myCutOffCanvas.addCommand(myNewGameCommand); myCutOffCanvas.setCommandListener(this); } //---------------------------------------------------------------- // implementation of MIDlet /** * Start the application. */ public void startApp() throws MIDletStateChangeException { myGameThread = new GameThread(myCutOffCanvas); myCutOffCanvas.start(); myGameThread.go(); } /** * stop and throw out the garbage. */ public void destroyApp(boolean unconditional) throws MIDletStateChangeException { myGameThread.requestStop(); myGameThread = null; myCutOffCanvas=null; System.gc(); } public void pauseApp() { myGameThread.pause(); }public void setMyPauseCommand () { myCutOffCanvas.removeCommand (myNewGameCommand); myCutOffCanvas.addCommand (myPauseCommand);}public void setMyGoCommand () {myCutOffCanvas.removeCommand (myPauseCommand);myCutOffCanvas.addCommand (myGoCommand);}public void setMyNewGameCommand () { myCutOffCanvas.removeCommand (myPauseCommand); myCutOffCanvas.addCommand (myNewGameCommand);} //---------------------------------------------------------------- // implementation of CommandListener /* * Respond to a command issued on the Canvas. */ public void commandAction(Command c, Displayable s) { int p,t; if (c == myExitCommand) { try { destroyApp(false); notifyDestroyed(); } catch (MIDletStateChangeException ex) { } } else if (c==myGoCommand) { myCutOffCanvas.paused=false; myCutOffCanvas.removeCommand(myGoCommand); myCutOffCanvas.addCommand(myPauseCommand); myCutOffCanvas.pausedAbouted=false; } else if (c==myPauseCommand) { pauseTime=System.currentTimeMillis(); myCutOffCanvas.paused=true; myCutOffCanvas.removeCommand (myPauseCommand); myCutOffCanvas.addCommand (myGoCommand); } else if (c==myNewGameCommand) { myCutOffCanvas.newGame(); }//if mynewgame}//commandlistener}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -