?? myship.java
字號:
?
+
/*
* MyShip.java
*
* Copyright 2001 SkyArts. All Rights Reserved.
*/
import javax.microedition.lcdui.*;
/**
* Myship類
*
* @author Hideki Yonekawa
* @version 1.0
*/
class MyShip extends Sprite {
/** 儲存自機圖像的變量*/
private Image shipImg;
/** 儲存自機爆炸圖像的變量 */
private Image burstImg;
/** 構造函數 */
MyShip() {
// 取得圖像
try {
shipImg = Image.createImage("/myship.png");
burstImg = Image.createImage("/burst.png");
}catch(Exception e) {}
//設定寬度與高度
width = shipImg.getWidth();
height = shipImg.getHeight();
}
/** 要移動Sprite時所調用的方法 */
void doMove() {
tickCount++;
if(isHit()) {
if(tickCount > 4) {
setHit(false);
}
}else {
if(tickCount > 4) {
tickCount = 0;
}
}
}
/** 要描繪Sprite時所調用的方法 */
void doDraw(Graphics g) {
if(isHit()) {
//Hit時描繪爆炸圖像
g.drawImage(burstImg, x, y, Graphics.TOP|Graphics.LEFT);
}else {
g.drawImage(shipImg, x, y, Graphics.TOP|Graphics.LEFT);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -