📄 gamesplash.java
字号:
/*
* 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 static final int COLOR_LIGHT_BLUE = 0x0092FF;
private GameShell canvas;
private Display display;
private Displayable previousDisplay;
private Image splashImage;
private boolean run;
//Class simply prints the gameSplash to the screen
public GameSplash(GameShell canvas, Display display, Displayable previousDisplay)
{
this.canvas = canvas;
this.display = display;
this.previousDisplay = previousDisplay;
try
{
splashImage = Image.createImage("/pulldown/Image_8bit_16.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();
//Loading of game-related images. This doesn't make any sense, I know.
//Speed was of the essence in completing this game.
short loadProgress = 0;
while(loadProgress < 6)
{
loadProgress++;
canvas.loadImages(loadProgress);
}
while (run)
{
if (endStamp - startStamp < 5000)
{
endStamp = System.currentTimeMillis();
}
else
{
run = false;
}
Thread.currentThread().yield();
}
terminateSplash();
}
protected void paint(Graphics g)
{
g.setColor(COLOR_LIGHT_BLUE);
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);
}
}
public void terminateSplash()
{
display.setCurrent(previousDisplay);
}
public Canvas getCanvas()
{
return canvas;
}
protected void keyPressed(int keyCode)
{
if (keyCode > -1 || getGameAction(keyCode) > -1)
{
run = false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -