📄 gamesplash.java
字号:
/* * GameSplash.java * * Created on den 8 augusti 2003, 11:21 */package DXBenchmarker;/* * GameSplash.java * * Created on den 8 augusti 2003, 08:48 */import javax.microedition.lcdui.*;import javax.microedition.midlet.MIDlet;import java.io.IOException;public class GameSplash extends Canvas implements Runnable{ private static final int COLOR_WHITE = 0xFFFFFFFF; private static final int COLOR_BLACK = 0x00000000; private static final int COLOR_YELLOW = 0x00FFFF00; private Display display; private Displayable previousDisplay; private Image splashImage; private boolean run; public GameSplash(Display display, Displayable previousDisplay) { this.display = display; this.previousDisplay = previousDisplay; try { splashImage = Image.createImage("/biorythmsplash.png"); } catch (IOException ioe) { System.out.println("Can't load splash image. " + ioe); } repaint(); run = true; } public void run() { long startStamp = System.currentTimeMillis(); long endStamp = System.currentTimeMillis(); while (run) { if (endStamp - startStamp < 5000) { endStamp = System.currentTimeMillis(); } else { run = false; } Thread.currentThread().yield(); } terminateSplash(); } protected void paint(Graphics g) { g.setColor(COLOR_BLACK); g.fillRect(0, 0, getWidth(), getHeight()); if (getHeight() > splashImage.getHeight() && getWidth() > splashImage.getWidth()) { g.drawImage(splashImage, (getWidth() - splashImage.getWidth()) / 2, (getHeight() - splashImage.getHeight()) / 2, g.TOP | g.LEFT); } else if (getHeight() > splashImage.getHeight()) { g.drawImage(splashImage, 0, (getWidth() - splashImage.getWidth()) / 2, g.TOP | g.LEFT); } else if (getWidth() > splashImage.getWidth()) { g.drawImage(splashImage, (getHeight() - splashImage.getHeight()) / 2, 0, g.TOP | g.LEFT); } else { g.drawImage(splashImage, 0, 0, g.TOP | g.LEFT); } System.out.println("W: " + getWidth() + " H: " + getHeight() + " IW: " + splashImage.getWidth() + " IH: " + splashImage.getHeight()); } public void terminateSplash() { display.setCurrent(previousDisplay); } protected void keyPressed(int keyCode) { if (keyCode > -1 || getGameAction(keyCode) > -1) { run = false; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -