コード例 #1
0
  /*
   * espera que se precione un boton, controla el juego; las barras objetos, dificultado y
   * el game over
   */
  public void act() {
    if (opcion == 0) {
      leeboton();
    }

    if (opcion == 1) {
      tiempo();
      agregaBarra();
      agregaObjetos();

      cambioDific();
      muestraColor.cambia(orbPj.getColAct());

      if (orbPj.getGameOver() == 1) {
        opcion = 2;
        sound.stop();
        record = tiempoActual;
        eliminaObjetos();
        setBackground("gameover.png");
        addObject(new Mensaje("ATRAS"), 710, 27);
        bot5 = new boton();
        addObject(bot5, 716, 31);

        addObject(new Mensaje("PUNTUACION"), 400, 458);
        total = new Counter();
        addObject(total, 401, 502);
        total.setValue(record);

        actualizaRecord();
      }

      // System.out.println(orbPj.getGameOver());
    }

    if (opcion == 2) {
      if (Greenfoot.mouseClicked(bot5)) {
        eliminaObjetos();
        opcion = 0;
        sound2.playLoop();
        menu();
      }
    }

    if (opcion == 3) {

      if (Greenfoot.mouseClicked(bot5)) {

        opcion = 2;
        // menu();

      }
    }
  }