rotatingcube.java

来自「J2ME手机游戏开发技术详解随书光盘」· Java 代码 · 共 39 行

JAVA
39
字号
import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import java.util.*;// Our custom MIDlet public class RotatingCube extends MIDlet{    static RotatingCube instance;    MyCanvas displayable = new MyCanvas(); // Custom Canvas does 3D graphics    Timer iTimer = new Timer();    // Timer to implement animation    // MIDlet's constructor    public RotatingCube() {        this.instance = this;    } // end constructor    // Main entry point    public void startApp() {        Display.getDisplay(this).setCurrent(displayable);        iTimer.schedule( new MyTimerTask(), 0, 40 ); // Start timer    } // end startApp()    // Manage pausing the MIDlet    public void pauseApp() {    } // end pauseApp    // Manage terminating the MIDlet    public void destroyApp(boolean unconditional) {    } // end destroyApp()    // Quit the MIDlet, doing any clean-up before calling destroyApp()    public static void quitApp() {        instance.destroyApp(true);        instance.notifyDestroyed();        instance = null;    } // end quitApp()    // Our timer task for providing animation    class MyTimerTask extends TimerTask {        public void run() {            if( displayable != null ) { // If Canvas is present...                displayable.repaint(); // ... call its repaint()            } // end if        } // end run    } // end TimerTask} // end MIDletMain

⌨️ 快捷键说明

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