// crea los objetos de textura y audio
  private void crearObjetos() {
    AssetManager assetManager = principal.getAssetManager(); // Referencia al assetManager
    // Textura de fondos y botones
    texturaFondo = assetManager.get("seleccionNivel/recursosPerdiste/gameOver.png");
    texturaBtnMenu = assetManager.get("seleccionNivel/recursosPausa/menu.png");
    texturaBtnContinue = assetManager.get("seleccionNivel/recursosPerdiste/continue.png");

    // Crear fondo
    fondo = new Fondo(texturaFondo);

    fondo.getSprite().setCenter(Principal.ANCHO_MUNDO / 2, Principal.ALTO_MUNDO / 2);
    fondo.getSprite().setOrigin(1500 / 2, 1500 / 2);

    // botones
    btnContinue = new Boton(texturaBtnContinue);
    btnContinue.setPosicion(Principal.ANCHO_MUNDO / 2 - 160, Principal.ALTO_MUNDO / 2 - 200);

    btnMenu = new Boton(texturaBtnMenu);
    btnMenu.setPosicion(Principal.ANCHO_MUNDO / 2 - 160, Principal.ALTO_MUNDO / 2 - 350);

    efectoClick = assetManager.get("sonidoVentana.wav");
    efectoMuerteNinja = assetManager.get("seleccionNivel/recursosPerdiste/muerteNinja.wav");
    // Batch
    batch = new SpriteBatch();
  }
  @Override
  public void render(float delta) {
    // Borrar la pantalla
    Gdx.gl.glClearColor(0, 0, 0, 0);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.setProjectionMatrix(camara.combined);

    // DIBUJAR
    batch.begin();
    fondo.render(batch);
    btnMenu.render(batch);
    btnContinue.render(batch);
    batch.end();
  }
Exemplo n.º 3
0
  /**
   * Creates a new configuration method
   *
   * @param backMenu Menu instance used to control its music
   */
  public Config(Menu backMenu) {

    try {
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
      try (ObjectInputStream entradaObjs =
          new ObjectInputStream(new FileInputStream("Saves" + File.separator + "config.dat"))) {
        configSave = (float[]) entradaObjs.readObject();
      }
    } catch (ClassNotFoundException
        | IOException
        | InstantiationException
        | IllegalAccessException
        | UnsupportedLookAndFeelException e) {
      System.out.println(e.getMessage());
    }

    this.setSize(800, 300);
    this.add(fondo = new Fondo("fondoConfig.png"));
    this.setUndecorated(true);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setIconImage(Toolkit.getDefaultToolkit().getImage("Images" + File.separator + "logo.png"));
    this.backMenu = backMenu;

    icon = new ImageIcon("Images/brick.png");

    fondo.setLayout(new BorderLayout());

    returns = CustomButton.createButton("Go Back", this.getGraphicsConfiguration(), 18);
    returns.addActionListener(this);

    musicSlider = new JSlider(JSlider.HORIZONTAL, -30, 0, (int) configSave[0]);
    musicSlider.setOpaque(false);
    musicSlider.setMajorTickSpacing(10);
    musicSlider.setMinorTickSpacing(2);
    musicSlider.setPaintTicks(true);

    volumeSlider = new JSlider(JSlider.HORIZONTAL, -30, 0, (int) configSave[1]);
    volumeSlider.setOpaque(false);
    volumeSlider.setMajorTickSpacing(10);
    volumeSlider.setMinorTickSpacing(2);
    volumeSlider.setPaintTicks(true);

    fondo.add(returns, BorderLayout.SOUTH);
    fondo.add(musicSlider, BorderLayout.NORTH);
    fondo.add(volumeSlider, BorderLayout.CENTER);

    try {
      this.getContentPane()
          .setCursor(
              Toolkit.getDefaultToolkit()
                  .createCustomCursor(
                      CompatibleImage.toCompatibleImage(
                          ImageIO.read(new File("Images" + File.separator + "cursor.png"))),
                      new Point(0, 0),
                      "cursor"));
    } catch (IOException ex) {
      Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
    }

    this.setVisible(true);
  }