基于J2ME WTK的2D手机游戏开发(英文文献翻译) 第14页
public void getAnimation() {// 将要改变的图片赋上固定值
for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data[0].length; j++) {
switch (data[i][j]) {
case 55:
data[i][j] = -1;
break;
case 56:
data[i][j] = -2;
break;
case 65:
data[i][j] = -3;
break;
case 66:
data[i][j] = -4;
break;
case 75:
data[i][j] = -5;
break;
case 76:
data[i][j] = -6;
break;
}
}
}
}
public void update() {
aniCounter = ++aniCounter % 3;
for (int i = 0; i < map_num.length; i++) {
this.setAnimatedTile(AIN[i], map_num[i] + aniCounter * 2);
}
}
}
Tools类
import javax.microedition.lcdui.Image;
public class Tools {
static final int UP_TYPE = -1;// 向上按键
static final int DOWN_TYPE = -2;// 向下按键
static final int LIFT_TYPE = -3;// 向左按键
static final int RIGHT_TYPE = -4;// 向右按键
static final int ATTACK_TYPE = -5;// 攻击键
static final int L_TYPE = -6;//左按键
static final int R_TYPE = -7;//右按键
static final byte PLAY=0,LOADING=3,LOGO=1;//
public static final byte LEFT = 7, RIGHT = 8;
// 读图片
public static Image read_image(String filename) {
Image img = null;
try {
img = Image.createImage("/" + filename + ".png");
} catch (Exception e) {
// TODO 自动生成 catch 块
// System.out.println("图象加载错误 " + filename);
}
return img;
}
}
ScreenBase类
public abstract class ScreenBase {
public ScreenBase() {
// TODO Auto-generated constructor stub
}
/**
* 逻辑更新
*/
public abstract void update();
/**
* 按键
* @param iAction
*/
public abstract void input(int iAction);
/**
* 画图
* @param grap 画笔
*/
public abstract void render();
/**
* 释放
*/
public abstract void free();
// TODO Auto-generated method stub
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] 下一页