欢迎观临
import javax.microedition.lcdui.game.*;
import javax.microedition.lcdui.*;
public class myCanvas extends GameCanvas implements Runnable,CommandListener{
public Graphics offg;
public Sprite bk,sren;
public LayerManager lm ;
public int px,py;
private Command com=new Command("back",Command.BACK,0);
public myCanvas()
{super(false);
this.setFullScreenMode(true);
offg=this.getGraphics();
px=py=30;
lm=new LayerManager();
try{
Image imbk=Image.createImage("/bk.png");
bk=new Sprite(imbk);
Image ren=Image.createImage("/walk.png");
sren=new Sprite(ren,16,24);
}catch(Exception e){}
lm.append(sren);
lm.append(bk);
lm.setViewWindow(0,0,240,289);
this.addCommand(com);
this.setCommandListener(this);
(new Thread(this)).start();
}
public void run()
{while(true)
{input();
sren.nextFrame();
lm.paint(offg,0,0);
offg.setColor(0xFF0000);
offg.drawString("龙",px,py,0);
this.flushGraphics();
try{Thread.sleep(200);}catch(Exception e){}
}
}
public void commandAction(Command c, Displayable d) {
if(c==com){
gameStart.midlet.d.setCurrent(gameStart.midlet.menu);
}
}
public void input()
{int k=this.getKeyStates();
if((k&2)>0){
py-=8;
if(py<0){py=289;}
}
if((k&4)>0){
px-=8;
if(px<0){px=240;}
}
if((k&GameCanvas.RIGHT_PRESSED)>0){
px+=8;
if(px>240){px=0;}
}
if((k&GameCanvas.DOWN_PRESSED)>0){
py+=8;
if(py>289){
py=0;
}
}
}
}
程序运行时为什么没有back按钮出现,那位人才能帮我找找原因啊,我在此三拜九叩了,在原来程序上改出来吧
------解决方案--------------------this.setFullScreenMode(true);//把这句注释了
------解决方案--------------------按一下左右软键不就出现了嘛!!
程序中
public void commandAction(Command c, Displayable d) {
if(c==com){
gameStart.midlet.d.setCurrent(gameStart.midlet.menu);
}
gameStart不知从何而来,无法调试。