⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 splashscreen3d.java

📁 这是一个3D手机游戏的原码恭大家参考! 希望大家喜欢!
💻 JAVA
字号:
import javax.microedition.midlet.*;import javax.microedition.lcdui.*;/** * Shows how to display a 3D Splash Screen to the user * while time consuming initialization of the main * screen takes place. * * The 3D Splash Screen uses Mascot Capsule version 3 * to render the graphics. * * If one just tries to display the splash in the startApp, * it might not show up at all until the initialization is done! * To prevent this separate Threads are used for the Splash * and the initialization. The init Thread doesn't start until * the splash actually has been drawn to the Canvas. * * Beacuse the Splash is animated it's important to give the Thread * CPU cycles now and then to be able to render! *  * * This code is part of the Tips & Tricks section at  * www.SonyEricsson.com/developer * * Written by J鰊s Weimarck, 2004 * 3D code based on code from HI Corp */public class SplashScreen3D extends MIDlet implements CommandListener, Runnable {        private Command exitCommand;     private Display display;    private SplashScreen splashScreen;        private Form myForm;               public SplashScreen3D() {        display = Display.getDisplay(this);        exitCommand = new Command("Exit", Command.EXIT, 0);    }        public void startApp() {        //Creates the 3D Splash and dispalys it using a separate thread.        splashScreen= new SplashScreen(display);        //Creates and starts the main game        Thread myGameThread = new Thread(this);        myGameThread.start();           }       /**     *    The main game thread   */    public void run(){        // Don't start initializing until the Splash is shown, otherwise        // the initializaation will delay the Splash from being shown!        while(!SplashScreen.splashIsShown){            Thread.yield();        }                doTimeConsumingInit();                while(true){            // Game loop                       Thread.yield();        }    }        /**     * Do all initialization for the game here     */    private void doTimeConsumingInit(){         // Just mimic some lengthy initialization for 10 secs        long endTime= System.currentTimeMillis()+10000;        while(System.currentTimeMillis()<endTime ){            //Give the animation some time to render new frames...            try{Thread.sleep(20);}catch(java.lang.InterruptedException e){}        }                // init the game's main Displyable (here a Form)        myForm = new Form("Game Started!");        myForm.addCommand(exitCommand);        myForm.setCommandListener(this);                display.setCurrent(myForm);                // Tell the Splash to finish because the initialization is over.        splashScreen.isInitialized=true;     }        public void pauseApp() {}        public void destroyApp(boolean unconditional) { }        public void commandAction(Command c, Displayable s) {        if (c == exitCommand) {            destroyApp(false);            notifyDestroyed();        }    }        }

⌨️ 快捷键说明

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