一、麻将类:
public class majiang {
int num = 0;
int type = 0;
boolean side;
play_majiang pm;
Image mahimage;
public majiang(int n, int t, boolean s, play_majiang pm) {
this.pm = pm;
num = n;
type = t;
side = s;
if (n == pm.magic1 && t == pm.magic2) {
num = 7;
type = 3;
}
if (n == -1) {
num = pm.magic1;
type = pm.magic2;
}
}
}
二、J2ME初始化程序:
/** Main method */
public void startApp() {
Display.getDisplay(this).setCurrent(form);
conn = new Connection(this); // 初始化网络
}
/** Handle pausing the MIDlet */
public void pauseApp() {
}
/** Handle destroying the MIDlet */
public void destroyApp(boolean unconditional) {
}
/** Quit the MIDlet */
public static void quitApp() {
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
public void startgame() {
pm = new play_majiang(this, winner, wei);
Display.getDisplay(this).setCurrent(pm);
}
三、高级用户界面按键响应:
// 进入帮助说明后的按键响应
public void commandAction(Command c, Displayable d) {
if (c == exit) {
Display.getDisplay(midlet).setCurrent(this);
}
}
public void keyPressed(int key) {
switch (getGameAction(key)) {
case Canvas.UP: {
if (choose > 1)
choose--;
else
choose = 3;
}
break;
case Canvas.DOWN: {
if (choose < 3)
choose++;
else
choose = 1;
}
break;
case Canvas.FIRE: {
if (choose == 1) {
if (first) {
midlet.startgame();
first = false;
} else {
//把ff设成true
midlet.pm.changeff();
Display.getDisplay(midlet).setCurrent(midlet.pm);
}
}
if (choose == 2) {
Display.getDisplay(midlet).setCurrent(form);
}
if (choose == 3) {
midlet.quitApp();
}
}
break;
case 0: {
switch (key) {
case Canvas.KEY_NUM2: {
if (choose > 1)
choose--;
else
choose = 3;
}
break;
case Canvas.KEY_NUM8: {
if (choose < 3)
choose++;
else
choose = 1;
}
break;
case Canvas.KEY_NUM5: {
if (choose == 1) {
if (first) {
midlet.startgame();
first = false;
} else {
midlet.pm.changeff();
Display.getDisplay(midlet).setCurrent(midlet.pm);
}
}
if (choose == 2) {
Display.getDisplay(midlet).setCurrent(form);
}
if (choose == 3) {
midlet.quitApp();
}
}
break;
}
}
break;
}
repaint();
}}
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] 下一页