📄 splash.java
字号:
/*
* 创建日期 2007-2-20 @author cpiz
*
* Splash画面
*/
package src;
import java.util.Timer;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class Splash extends Canvas
{
GameMIDlet midlet= null;
Timer timer = null;
/**
* 构造函数
*
* @param midlet
* 父MIDlet对象
*/
public Splash(GameMIDlet midlet)
{
this.midlet = midlet;
}
public void showMe()
{
// 使用MIDP2.0自带的全屏模式
this.setFullScreenMode(true);
// 初始化计时器,一定时间后跳转至游戏
/* timer = new Timer();
timer.schedule(new TimerTask()
{
public void run()
{
showNextScreen();
}
}, GameMIDlet.SPLASH_TIME);*/
midlet.setDisplayable(this);
}
/**
* 显示下一屏
*/
private void showNextScreen()
{
//timer.cancel();
// timer = null;
midlet.startGame();
}
/**
* 清除屏幕
* @param g 屏幕对象
*/
private void clearGraphics(Graphics g)
{
g.setColor(0xffffff);// 默认清理为黑色
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0x000000);
}
protected void paint(Graphics g)
{
clearGraphics(g);
try
{
// 在屏幕中央绘制splash图片
g.drawImage(Image.createImage("/res/splash.png"),
GameMIDlet.CANVAS_WIDTH / 2,
GameMIDlet.CANVAS_HEIGHT / 2 - 30,
Graphics.VCENTER | Graphics.HCENTER);
// 设置字体
g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN,
Font.SIZE_MEDIUM));
g.drawString("作者:Fly can fly",10,210, Graphics.LEFT | Graphics.BOTTOM);
g.drawString("QQ:63913660",10,230, Graphics.LEFT | Graphics.BOTTOM);
// 在屏幕左上方绘制版本号
g.drawString(
"v" + midlet.getAppProperty("MIDlet-Version"),
0,
0,
Graphics.LEFT | Graphics.TOP);
// 在屏幕右下方绘制skip提示
g.drawString(GameMIDlet.SKIP_SPLASH_TIP, getWidth() - 2, getHeight() - 2,
Graphics.RIGHT | Graphics.BOTTOM);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
/**
* 处理按键事件
*/
protected void keyPressed(int keyCode)
{
// 按任意键开始游戏
showNextScreen();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -