?? aboutcanvas.java
字號:
package gamemidlet;
import javax.microedition.lcdui.*;
/**
* <p>Title: 黃小輝8000106286網通062班</p>
* <p>Description: GameMIDlet</p>
* <p>Copyright: Copyright (c) 2009</p>
* <p>Company: NCU</p>
* @author not attributable
* @version 1.0
*/
public class AboutCanvas
extends Canvas
implements Runnable {
private final MenuCanvas menu;
private final int stayTime;
private static Image appImg = null;
private int currentTime;
private Font nowfont;
Thread thread;
public AboutCanvas(MenuCanvas menu, int stayTime) {
this.menu=menu;
currentTime = 0;
this.stayTime = stayTime;
nowfont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
appImg = GameMIDlet.loadImage("/pic/applogo.png");
this.setFullScreenMode(true);
thread = new Thread(this);
thread.start();
}
private void showMenu() {
Display.getDisplay(GameMIDlet.instance).setCurrent(menu);
}
public void run() {
for (; currentTime <= stayTime; currentTime += 50) {
try {
thread.sleep(50L);
}
catch (InterruptedException interuptedexception) {}
if (currentTime == stayTime) {
showMenu();
}
}
}
protected void paint(Graphics g) {
int w = appImg.getWidth();
int h = appImg.getHeight();
int x = (this.getWidth() - w) / 2;
int y = (this.getHeight() - h) / 2;
g.setColor(0x00000000);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
g.drawImage(appImg, x, y - 5, Graphics.TOP | Graphics.LEFT);
g.setColor(255, 0, 0);
g.setFont(nowfont);
String str = "自己做的游戲菜單";
int fontW = nowfont.stringWidth(str);
int fontH = nowfont.getHeight();
g.drawString(str, (this.getWidth() - fontW) / 2, y + appImg.getHeight(),
Graphics.TOP | Graphics.LEFT);
str = "hxh:2009";
fontW = nowfont.stringWidth(str);
g.drawString(str, (this.getWidth() - fontW) / 2,
y + appImg.getHeight() + fontH, Graphics.TOP | Graphics.LEFT);
}
protected void keyPressed(int i) {
currentTime = stayTime;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -