splash.java
来自「基于J2ME的手机游戏软件。可以控制游戏人物在地图上上下左右行走;可以在地图上放」· Java 代码 · 共 95 行
JAVA
95 行
import javax.microedition.lcdui.*;
public class Splash extends Canvas
implements Runnable
{
private boolean running;
private Image word;
private Image word1;
private Image background;
private Image image;
private int width;
private int height;
private int baseLine;
private boolean word1isShow;
private long lastWord1Show;
protected BombMan midlet;
public Splash(BombMan midlet)
{
running = true;
setFullScreenMode(true);
this.midlet = midlet;
width = getWidth();
height = getHeight();
baseLine = 0;
word = ImageSet.loadClippedImage("/splash_word.png", 0, 0, 120, 120);
word1 = ImageSet.loadClippedImage("/splash_word1.png", 0, 0, 120, 120);
background = ImageSet.loadClippedImage("/splash_background.png", 0, 0, 120, 120);
image = Image.createImage(120, 120);
word1isShow = false;
lastWord1Show = 0L;
Thread thread = new Thread(this);
thread.start();
}
protected void keyPressed(int keyCode)
{
running = false;
// System.out.println("key pressed!");
}
public void paint(Graphics gra)
{
gra.setColor(0xffffff);
gra.fillRect(0, 0, getWidth(), getHeight());
gra.drawImage(image, width / 2, height / 2, 3);
gra.drawImage(word, width / 2, height / 2, 3);
if(word1isShow)
{
gra.drawImage(word1, width / 2, height / 2, 3);
}
}
protected void cycle()
{
image.getGraphics().drawImage(background, baseLine, 0, 20);
image.getGraphics().drawImage(background, -(120 - baseLine), 0, 20);
baseLine = (baseLine + 4) % 120;
if(System.currentTimeMillis() - lastWord1Show > 600L)
{
word1isShow = !word1isShow;
lastWord1Show = System.currentTimeMillis();
}
}
public void run()
{
// System.out.println("splash start...");
long deltaTime = 0L;
long bufTime = 0L;
do
{
if(!running)
{
break;
}
bufTime = System.currentTimeMillis();
cycle();
repaint();
deltaTime = System.currentTimeMillis() - bufTime;
if(deltaTime < 100L)
{
try
{
Thread.sleep(100L - deltaTime);
}
catch(InterruptedException e) { }
}
} while(true);
// System.out.println("splash end...");
midlet.activateGameMenu();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?