示例#1
0
  private void nextGame() {
    done = false;
    sp.setText("Start Next Level");
    for (int i = 0; i < 16; i++) {
      gpane.getChildren().remove(iv[i]);
    }
    levelComplete0 = new Label();
    levelComplete0.setId("lc0");
    levelComplete0.setAlignment(Pos.CENTER);
    levelComplete0.setText("Level " + (level - 1) + " completed");
    levelComplete0.setPrefSize(320, 80);

    levelComplete1 = new Label();
    levelComplete1.setId("lc1");
    levelComplete1.setAlignment(Pos.CENTER);
    levelComplete1.setText("Your score " + ((level * 10) - 10) + " Points");
    levelComplete1.setPrefSize(320, 160);

    levelComplete2 = new Label();
    levelComplete2.setId("lc2");
    levelComplete2.setAlignment(Pos.CENTER);
    levelComplete2.setText("Next Level : " + level);
    levelComplete2.setPrefSize(320, 80);

    gpane.add(levelComplete0, 0, 0, 4, 1);
    gpane.add(levelComplete1, 0, 1, 4, 2);
    gpane.add(levelComplete2, 0, 3, 4, 1);

    mediaPlayer.stop();
    // songName = new TextField("w.mp3");
    // songPath = "C:\\Users\\Nihal\\Google Drive\\SCHOOL\\Java
    // 2\\Programs\\JavaFinalProject\\src\\javafinalproject\\";
    // MiniMP3Player();
    // mediaPlayer.play();

    sp.setOnAction(
        e -> {
          iniGame();
        });
  }
示例#2
0
  public FinalGame() {
    sp = new Button();
    sp.setAlignment(Pos.CENTER);
    sp.setText("Start");
    sp.setPrefSize(160, 80);

    stop = new Button();
    stop.setAlignment(Pos.CENTER);
    stop.setText("Stop");
    stop.setPrefSize(160, 80);

    exit = new Button();
    exit.setAlignment(Pos.CENTER);
    exit.setText("Exit");
    exit.setPrefSize(200, 80);

    mv = new Label();
    mv.setId("mv");
    mv.setAlignment(Pos.CENTER);
    mv.setText("MOVES");
    mv.setPrefSize(200, 80);

    lvl = new Label();
    lvl.setId("lvl");
    lvl.setAlignment(Pos.CENTER);
    lvl.setText("LEVEL");
    lvl.setPrefSize(200, 80);

    clock = new Label();
    clock.setId("clock");
    clock.setAlignment(Pos.CENTER);
    clock.setText("TIMER");
    clock.setPrefSize(200, 80);

    hc = new Label();
    hc.setId("hc");
    hc.setAlignment(Pos.CENTER);
    hc.setText("HIGH SCORE");
    hc.setPrefSize(200, 80);

    gpane = new GridPane();
    gpane.setId("pane");
    iv = new ImageView[16];
    rct = new Rectangle2D[17];
    rct[0] = new Rectangle2D(0, 0, 80, 80);
    rct[1] = new Rectangle2D(80, 0, 80, 80);
    rct[2] = new Rectangle2D(160, 0, 80, 80);
    rct[3] = new Rectangle2D(240, 0, 80, 80);
    rct[4] = new Rectangle2D(0, 80, 80, 80);
    rct[5] = new Rectangle2D(80, 80, 80, 80);
    rct[6] = new Rectangle2D(160, 80, 80, 80);
    rct[7] = new Rectangle2D(240, 80, 80, 80);
    rct[8] = new Rectangle2D(0, 160, 80, 80);
    rct[9] = new Rectangle2D(80, 160, 80, 80);
    rct[10] = new Rectangle2D(160, 160, 80, 80);
    rct[11] = new Rectangle2D(240, 160, 80, 80);
    rct[12] = new Rectangle2D(0, 240, 80, 80);
    rct[13] = new Rectangle2D(80, 240, 80, 80);
    rct[14] = new Rectangle2D(160, 240, 80, 80);
    rct[16] = new Rectangle2D(240, 240, 80, 80);
    rct[15] = new Rectangle2D(320, 0, 80, 80);
    iniGame();
    addObjects();
  }