RotatingCube.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- 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