Exemplo n.º 1
0
 public static void draw(boolean menuEnable) {
   if (showMenu) {
     others.notUserObject("menu").setVisible(Setting.persistence.touchMod);
     if (Setting.persistence.touchMod && GameViews.gameview.stackView == null) {
       float x = pad.getKnobPercentX();
       float y = pad.getKnobPercentY();
       double tan = Math.atan2(y, x);
       if (tan < p4 * 3 && tan > p4) MoveController.up();
       else if (tan > p4 * 3 || (tan < -p4 * 3 && tan < 0)) MoveController.left();
       else if (tan > -p4 * 3 && tan < -p4) MoveController.down();
       else if ((tan > -p4 && tan < 0) || (tan > 0 && tan < p4)) MoveController.right();
       else MoveController.stop();
     }
     others.cleanActions();
     for (Actor actor : others.getItems())
       actor.addAction(
           GameViews.gameview.stackView == null ? Actions.fadeIn(0.1f) : Actions.fadeOut(0.1f));
     if (Setting.persistence.betterDisplay)
       mask.setColor(.5f, .5f, .5f, (1 - others.first().getItem().getColor().a) * .3f);
     else mask.setColor(.2f, .2f, .2f, (1 - others.first().getItem().getColor().a) * .85f);
     stage.act();
     if (menuEnable) stage.draw();
   }
 }
Exemplo n.º 2
0
  public static void init() {
    first = false;
    stage =
        new Stage(
            new ScalingViewport(Scaling.stretch, 1024, 576, new OrthographicCamera()),
            GameViews.gameview.stage.getBatch());

    others =
        $.add(
            $.add(
                    new ImageButton(
                            Res.getDrawable(Setting.IMAGE_GLOBAL + "menu.png"),
                            Res.getDrawable(Setting.IMAGE_GLOBAL + "menu_active.png"))
                        .pos(GameUtil.screen_width - 65, 15)
                        .onClick(
                            new Runnable() {
                              public void run() {
                                GameViews.gameview.onkeyDown(Keys.ESCAPE);
                              }
                            }))
                .appendTo(stage)
                .setUserObject("menu"));
    TouchpadStyle tstyle = new TouchpadStyle();
    tstyle.background = Res.getDrawable(Setting.IMAGE_GLOBAL + "pad_bg.png");
    tstyle.knob = Res.getDrawable(Setting.IMAGE_GLOBAL + "pad_knob.png");
    others.add(
        $.add(pad = new Touchpad(0, tstyle)).setPosition(35, 25).setVisible(!GameUtil.isDesktop));
    others.add(
        $.add(
                new ImageButton(
                    Res.getDrawable(Setting.IMAGE_MENU_GLOBAL + "button_a.png"),
                    Res.getDrawable(Setting.IMAGE_MENU_GLOBAL + "button_a_p.png")))
            .setPosition(810, 45)
            .addListener(
                new InputListener() {
                  public void touchUp(InputEvent event, float x, float y, int pointer, int b) {
                    Input.cleanPress(Keys.Z);
                  }

                  public boolean touchDown(InputEvent event, float x, float y, int pointer, int b) {
                    Input.press(Keys.Z);
                    return true;
                  }
                })
            .setVisible(!GameUtil.isDesktop));
    others.add(
        $.add(
                new ImageButton(
                    Res.getDrawable(Setting.IMAGE_MENU_GLOBAL + "button_b.png"),
                    Res.getDrawable(Setting.IMAGE_MENU_GLOBAL + "button_b_p.png")))
            .setPosition(880, 95)
            .addListener(
                new InputListener() {
                  public void touchUp(InputEvent event, float x, float y, int pointer, int b) {
                    Input.cleanPress(Keys.CONTROL_LEFT);
                  }

                  public boolean touchDown(InputEvent event, float x, float y, int pointer, int b) {
                    Input.press(Keys.CONTROL_LEFT);
                    return true;
                  }
                })
            .setVisible(!GameUtil.isDesktop));
    others.appendTo(stage);

    mask =
        $.add(Res.get(Setting.UI_BASE_IMG).disableTouch())
            .setSize(GameUtil.screen_width, GameUtil.screen_height)
            .setColor(1, 1, 1, .5f)
            .appendTo(stage)
            .getItem();

    Logger.info("Post特效创建成功。");
  }