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

📄 splashscreen.java

📁 我做的手机游戏。有关宠物的
💻 JAVA
字号:


import java.io.IOException;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
//闪屏类
public class SplashScreen extends Canvas implements Runnable {
	
	private Image splashImage;
	//进度条
	private int progressValue;
	private boolean end;
	private boolean paintbackGround = false;
	
	public SplashScreen() {
		try {
			splashImage = Image.createImage("/开始.png");
		} catch (IOException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		
		new Thread(this).start();

		//3秒钟后关闭闪屏内部类
		new Thread() {

			public void run() {
				try {
					Thread.sleep(3000);
				} catch (InterruptedException e) {
				}
				close();
			}
			
		};
	}

	protected void paint(Graphics g) {
		int width = this.getWidth();
		int height = this.getHeight();

		if (!paintbackGround) {
			g.setColor(0xFF0000);
			g.fillRect(0, 0, width, height);
			paintbackGround = true;
		}

		if (splashImage != null) {
			g.drawImage(splashImage, 80, 0, Graphics.TOP
					| Graphics.HCENTER);
			splashImage = null;
		}

		g.setColor(0xFF);
		g.fillRect(0, height - 10, progressValue, 10);

	}

	public void setProgress(int value) {
		this.progressValue = value;
	}

	public void run() {
		end = false;
		while(!end) {
			repaint();
			try {
				Thread.sleep(50);
			} catch (InterruptedException e) {
			}
		}
	}
   //关闭
	public void close() {
		this.end = true;
	}
	//任意键退出
	protected void keyPressed(int key) {
		close();
	}


}

⌨️ 快捷键说明

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