?? splashscreen.java
字號:
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
public class SplashScreen extends GameCanvas
implements Runnable
{
private Display display;
private MainMenu menu;
private Image splashImage = GameScreen.getImage(GameScreen.IMAGE_SPLASH);
private boolean isShowing;
private int tick = 0;
public SplashScreen(Display display,MainMenu menu)
{
super(false);
this.display = display;
this.menu = menu;
this.setFullScreenMode(true);
}
private void render(Graphics g)
{
g.setColor(0,0,0);
g.fillRect(0,0,getWidth(),getHeight());
g.drawImage(splashImage,menu.borderX,menu.borderY,Graphics.TOP | Graphics.LEFT);
flushGraphics();
}
protected void keyPressed(int keyCode)
{
stop();
}
public void start()
{
isShowing = true;
Thread t = new Thread(this);
t.start();
}
private void stop()
{
isShowing = false;
display.setCurrent(menu);
menu.start();
}
public void run()
{
Graphics g = getGraphics();
long startTime = 0;
long timeTake = 0;
while(isShowing == true)
{
startTime = System.currentTimeMillis();
render(g);
tick++;
if(tick == 10)stop();
timeTake = System.currentTimeMillis() - startTime;
if (timeTake < GameScreen.MILLIS_PER_TICK)
{
try
{
Thread.sleep(GameScreen.MILLIS_PER_TICK - timeTake);
} catch(InterruptedException e){System.out.println(e);}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -