当前位置: 代码迷 >> J2ME >> 关于J2ME游戏切换屏幕的有关问题,求指导
  详细解决方案

关于J2ME游戏切换屏幕的有关问题,求指导

热度:346   发布时间:2016-04-17 21:07:09.0
关于J2ME游戏切换屏幕的问题,求大虾指导~
请问怎么切换屏幕?为什么我的代码不起作用呢?贴代码

public void commandAction(Command c, Displayable d) {
if(c==cmdbk){
System.out.println("huiqu22");
game_state=GAME_STATE_GAMING;
System.out.println(cmdbk);
System.out.println("qwqwqwwq");

}else if(c==cmdok){
System.out.println("qwqdffdfd");
game_state=GAME_STATE_MENU;

System.out.println("huiqu");
}else if(c==backCommand){
game_state=GAME_STATE_GAMING;
}

}

下面是主循环
public void run() {
while(!bQuit){
//if(flag==true){
offg.setColor(255,255,255);
offg.fillRect(0,0,getWidth(),getHeight());
repaint();
input();
 try {
Thread.currentThread();
Thread.sleep(80);
} catch (InterruptedException e) {

e.printStackTrace();

}
}


input函数
public void input(){
int k=this.getKeyStates();
switch (game_state) {
case GAME_STATE_INIT:
paintINIT();
break;
case GAME_STATE_LOGO:
paintLOGO();
break;
case GAME_STATE_MENU:
paintMeun();
break;
case GAME_STATE_GAMING:
switch (game) {
case GAMING:
lm.paint(offg,0, 0);
//检测边界碰撞
checkBound();
//检测精灵之间的碰撞
iscollision();
//检测Sprite方向
checkDir(k);
break;
}
case DEP_HR:
//game_state=GAME_STATE_LOGO;
break;
case GAME_STATE_ROLE:
rolefrm.append(cg);
rolefrm.addCommand(cmdbk);
rolefrm.addCommand(cmdok);
//frm.setCommandListener(this);
this.m4.dis.setCurrent(rolefrm);
break;
case GAME_STATE_HELP:
paintHelp(offg);

这里有点问题,求指教 break;
case GAME_STATE_EXIT:
exit();
break;
default:
break;
}
}



------解决方案--------------------
给你推荐几本书看看:
http://s.click.taobao.com/t?e=zGU34CA7K%2BPkqB07S4%2FK0CFcRfH0GoT805sipKj7KsCcmDVcXCwc7HfCWEm3sHo0JusXBgBePx6gw0hSZOgv5pn6g5r6gGz%2FxcgRZIh8E1b0IFk%3D