Por favor se alguem puder ajudar serei muito grato…
gostaria q alguem descobrisse o que está errado no meu código…
pq ele não chama a tela de game over qdo solicito??..
sempre que o sprite “morre” ao inves de chamar o game over ele trava…
tô colocando ai o code… desde já obrigado… abrass…
public class MIDletZag extends MIDlet implements CommandListener{
public Command sair ,pausar, reiniciar, ok, inserir;
private ZagCanvas gameCanvas;
private Menu menu;
private GameOver gameOver;
private Display screen;
public static MIDletZag ZagMid;
public void startApp(){
pausar = new Command("Pausar",Command.STOP,1);
sair = new Command("Sair",Command.EXIT,0);
reiniciar = new Command("Reiniciar", Command.BACK,1);
ok = new Command("OK", Command.OK,1);
inserir = new Command("Inserir", Command.OK,1);
gameCanvas = new ZagCanvas();
gameCanvas.addCommand(sair);
gameCanvas.setCommandListener(this);
MIDletZag.ZagMid = this;
menu = new Menu(this);
menu.addCommand(sair);
menu.setCommandListener(this);
SplashScreen();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
this.notifyDestroyed();
System.gc();
}
public ZagCanvas gameCanvas(){
return gameCanvas;
}
public void SplashScreen(){
screen = Display.getDisplay(this);
new SplashScreen(screen, menu);
}
public Menu getMenu(){
return menu;
}
public void GameOver() {
gameCanvas.stop();
destroyApp(true);
screen = Display.getDisplay(this);
new GameOver(screen, menu);
}
public void commandAction(Command arg0, Displayable arg1) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
////trecho que o metodo eh chamado no canvas////
if(morrendo){
this.SptZagAnimator.setMoving(true);
this.SptZag.setFrameSequence(ObZag.ZagMorrendo);
caindo = true;
CountDown count = new CountDown();
timer.schedule(count, 5000);
midlet.GameOver();
}
//////////////////////////////
import java.io.IOException;
import java.util.*;
import javax.microedition.lcdui.*;
public class GameOver extends Canvas {
private Display display;
private Displayable next;
private Image img = null;
private Timer timer = new Timer();
private ZagCanvas gameCanvas;
private MIDletZag midlet;
protected int _width;
protected int _height;
public GameOver(Display display, Displayable next){
this._width = this.getWidth();
this._height = this.getHeight();
this.display = display;
this.next = next;
display.setCurrent(this);
}
protected void keyPressed(int keyCode){
dismiss();
}
protected void paint(Graphics g){
try {
g.setColor(0xffffff);
g.fillRect(0, 0, _width, _height);
img = Image.createImage("/GameOver.png");
g.drawImage(img, 240, 240, Graphics.RIGHT | Graphics.BOTTOM);
} catch (IOException ex){
System.out.println("Sem Apresentação"+ex.toString());
}
}
protected void pointerPressed(int x, int y){
dismiss();
}
protected void showNotify(){
timer.schedule(new CountDown(), 4000);
}
private void dismiss(){
timer.cancel();
display.setCurrent(next);
}
private class CountDown extends TimerTask {
public void run(){
dismiss();
}
}
}