示例#1
0
  /*
   * (non-Javadoc)
   *
   * @see com.oop.gamepanel.GameState#gameRender(java.awt.Graphics)
   */
  @Override
  public void gameRender(Graphics g) {

    if (needUpdate) {
      for (MapButton btn : mButtons) {
        if (btn != null) {
          btn.update();
        }
      }
    }

    layer.render();
    g.drawImage(layer.getLayer(), 0, 0, null);
  }
示例#2
0
  /*
   * (non-Javadoc)
   *
   * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
   */
  @Override
  public void mousePressed(MouseEvent arg0) {
    Button clicked = (Button) layer.getClickedObj(new Point(arg0.getX(), arg0.getY()));

    if (clicked != null) {
      SoundEffect.BUTTONCLICK.play();
      if (clicked == btnBack) {
        changeState(lastState);
      } else {
        MapButton btn = (MapButton) clicked;

        int id = btn.getId();
        if (!saveFile.getLock(id)) {
          ModelMap map = ModelMap.createMap(Helper.getCurrentDirectory() + "map//" + id);
          if (map != null) {
            int nextId = -1;
            if (id < LEVEL_COUNT) nextId = id + 1;
            PlayState playState =
                new PlayState(parent, this, map, saveFile.getHighscore(id), nextId);
            needUpdate = true;

            parent.setState(playState);
          }
        }
      }
    }
  }
示例#3
0
  private void initialize() {

    layer = new Layer(parent.width, parent.height);
    layer.setBackground(OtherImage.BG);

    /* Khoi tao cac button level */
    for (int i = 0; i < LEVEL_COUNT; ++i) {
      mButtons[i] =
          new MapButton(
              new Point(100 + 100 * (i % 5), 70 + 100 * (i / 5)), i + 1, saveFile.getLock(i + 1));

      layer.addDrawable(mButtons[i]);
    }

    btnBack = new Button(new Point(245, 425));
    btnBack.setImage(ButtonImage.BTN_BACK);
    layer.addDrawable(btnBack);
  }