2 Replies Latest reply: Nov 23, 2009 8:32 AM by 843853 RSS

    need help on mobile gaming development basic

    843853
      my game canvas is like this

      public a1Canvas(Display display){
      super(true);
      this.display = display;
      frameDelay = 33;
      gameOverState = false;
      }

      public void start(){
      display.setCurrent(this);

      try {
      //get the images up
      } catch (IOException ex) {
      System.err.println("Failed to load images");
      }

      Thread t = new Thread(this);
      t.start();
      }

      public void run() {

      while (!gameOverState){


      update();
      draw(getGraphics());
      try{
      Thread.sleep(frameDelay);
      }catch(InterruptedException ie){}

      }
      gotoMainMenu(getGraphics());

      }

      private void draw(Graphics graphics) {
      //clear background to black

      //draw the background
      }

      private void update() {
      // Process user input

      // Check for game over condition
      if ( collision detection )
      gameOverState = true;


      }//if
      }//for
      }

      private void gotoMainMenu(Graphics graphics) {
      //clear screen to black colour
      //draw the main menu

      flushGraphics();

      //if i press the fire button the game will start again
      int keyState = getKeyStates();
      if ( (keyState & FIRE_PRESSED) != 0 ){
      System.out.println("game start");
      gameOverState = false;
      }
      }


      The problem i am facing is :
      the FIRE button is not functioning, i put a system.out.println and it didnt print.
      i am unsure whether i put the key input listener at the correct function
      this button is supposed to start the game again.

      What i want to do :
      i want to display the main menu when i launched the game
      when game is over, it will display back to the main menu again
      when i press the fire button it will play the game again.

      i hope someone can help me on this :)