Example #1
0
  public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));

    Label nameLabel = new Label("Name:", skin);
    TextField nameText = new TextField("", skin);
    Label addressLabel = new Label("Address:", skin);
    TextField addressText = new TextField("", skin);

    Table table = new Table();
    stage.addActor(table);
    table.setSize(260, 195);
    table.setPosition(190, 142);
    // table.align(Align.right | Align.bottom);

    table.debug();

    TextureRegion upRegion = skin.getRegion("default-slider-knob");
    TextureRegion downRegion = skin.getRegion("default-slider-knob");
    BitmapFont buttonFont = skin.getFont("default-font");

    TextButton button = new TextButton("Button 1", skin);
    button.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("touchDown 1");
            return false;
          }
        });
    table.add(button);
    // table.setTouchable(Touchable.disabled);

    Table table2 = new Table();
    stage.addActor(table2);
    table2.setFillParent(true);
    table2.bottom();

    TextButton button2 = new TextButton("Button 2", skin);
    button2.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            System.out.println("2!");
          }
        });
    button2.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("touchDown 2");
            return false;
          }
        });
    table2.add(button2);
  }
 void toast(String text) {
   Table table = new Table();
   table.add(new Label(text, skin));
   table.getColor().a = 0;
   table.pack();
   table.setPosition(-table.getWidth(), -3 - table.getHeight());
   table.addAction(
       sequence( //
           parallel(moveBy(0, table.getHeight(), 0.3f), fadeIn(0.3f)), //
           delay(5f), //
           parallel(moveBy(0, table.getHeight(), 0.3f), fadeOut(0.3f)), //
           removeActor() //
           ));
   for (Actor actor : toasts.getChildren()) actor.addAction(moveBy(0, table.getHeight(), 0.3f));
   toasts.addActor(table);
   toasts.getParent().toFront();
 }
Example #3
0
  public void showMenu() {
    continua = new TextButton("CONTINUA", Assets.getInstance().getButtonStyle());
    continua.setPosition(100, 400);
    toMenu = new TextButton("MENIU", Assets.getInstance().getButtonStyle());
    group = new Group();
    group.setSize(100, 100);
    group.addActor(continua);
    group.addActor(toMenu);
    group.setPosition(100, 400);

    Table table = new Table();
    table.add(continua);
    table.setPosition(100, 400);
    // stage.addActor(table);

    // stage.addActor(continua);
  }
Example #4
0
  private void loadScreen() {

    // Grafo de escena que contendrá todo el menú
    stage = new Stage();

    // Crea una tabla, donde añadiremos los elementos de menú
    Table table = new Table();
    table.setPosition(Constants.SCREEN_WIDTH / 2.5f, Constants.SCREEN_HEIGHT / 1.5f);
    // La tabla ocupa toda la pantalla
    table.setFillParent(true);
    table.setHeight(500);
    stage.addActor(table);

    // Etiqueta de texto
    Label label = new Label("Bienvenido a JFighter2DX", game.getSkin());
    table.addActor(label);

    // Botón
    TextButton buttonPlay = new TextButton("Partida Rapida", game.getSkin());
    buttonPlay.setPosition(label.getOriginX(), label.getOriginY() - 120);
    buttonPlay.setWidth(200);
    buttonPlay.setHeight(40);
    buttonPlay.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

            dispose();
            game.setScreen(new GameScreen(game, GameType.QUICK));
          }
        });
    table.addActor(buttonPlay);

    // Botón
    TextButton buttonHistory = new TextButton("Modo Historia", game.getSkin());
    buttonHistory.setPosition(label.getOriginX(), label.getOriginY() - 170);
    buttonHistory.setWidth(200);
    buttonHistory.setHeight(40);
    buttonHistory.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

            dispose();
            game.setScreen(new GameScreen(game, GameType.HISTORY));
          }
        });
    table.addActor(buttonHistory);

    // Botón
    TextButton buttonConfig = new TextButton("Configurar", game.getSkin());
    buttonConfig.setPosition(label.getOriginX(), label.getOriginY() - 220);
    buttonConfig.setWidth(200);
    buttonConfig.setHeight(40);
    buttonConfig.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

            dispose();
            game.setScreen(new ConfigurationScreen(game));
          }
        });
    table.addActor(buttonConfig);

    // Botón
    TextButton buttonQuit = new TextButton("Salir", game.getSkin());
    buttonQuit.setPosition(label.getOriginX(), label.getOriginY() - 270);
    buttonQuit.setWidth(200);
    buttonQuit.setHeight(40);
    buttonQuit.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
          }

          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

            game.dispose();
            System.exit(0);
          }
        });
    table.addActor(buttonQuit);

    Gdx.input.setInputProcessor(stage);
  }
Example #5
0
  @Override
  public void show() {

    skin = new Skin(Gdx.files.internal("uiskin.json"));
    stage = new Stage(new ScreenViewport());
    batch = new SpriteBatch();

    Gdx.input.setInputProcessor(stage);

    // Adding the game title to the screen
    Sprite spriteTitle = new Sprite(Assets.zombieShooterTitle);
    Assets.spriteDefaultColorSolid(spriteTitle);
    SpriteDrawable spriteDrawableTitle = new SpriteDrawable(spriteTitle);
    imageTitle = new Image(spriteDrawableTitle);

    // Creating all the containers for the positioning and arranging of our stuff
    container = new Table();
    container.setWidth(stage.getWidth());
    container.align(Align.center | Align.top);
    container.setPosition(0, Constant.HEIGHT_SCREEN);

    containerFirstRow = new Table();
    containerFirstRow.setWidth(stage.getWidth());
    containerFirstRow.align(Align.center | Align.top);
    containerFirstRow.setPosition(0, Constant.HEIGHT_SCREEN);

    containerSecondRow = new Table();
    containerSecondRow.setWidth(stage.getWidth());
    containerSecondRow.align(Align.center | Align.top);
    containerSecondRow.setPosition(0, Constant.HEIGHT_SCREEN);

    creatingRegisterButton();

    creatingTheTextFields();

    // Setting the text field text to be on the center
    settingTextFieldsTextToCenter();

    // Remove any text in hte text fields on click so that user can write his information
    cleaningTextFieldsToBlank();

    // Adding all the object into the stage. First of all we add to the container
    // for the row then to the main container , finally into the main stage
    arrangingTheScreen();

    // Creating the background
    backGroundSprite = new Sprite(Assets.backgroundMenu);
    backGroundSprite.setSize(Constant.WIDTH_SCREEN, Constant.HEIGHT_SCREEN);

    // Setting the back key on android to true, so it can accept interaction
    Gdx.input.setCatchBackKey(true);

    inizializiraneWarningMessage();

    // When clicking on the register button we start the validation process.
    // It calls all the methods which are checking the user input
    registerButton.addListener(
        new ClickListener() {
          public void clicked(InputEvent e, float x, float y) {
            Assets.clickButton.play();
            if ((checkUserField(userField.getText().toString()))
                && (checkPasswordField(passwordField.getText().toString()))
                && (checkPasswordAndRePassword(
                    passwordField.getText().toString(), passwordCheckField.getText().toString()))
                && (checkEmailField(emailField.getText().toString()))) {
              registerJson();
            }
          }
        });
  }
  public LevelEditorGameState(GameStateManager gsm) {
    super(gsm);

    bitmapFont = new BitmapFont();
    stage = new Stage();

    Skin skin = new Skin(Gdx.files.internal("uiskin.json"));
    Label titleLabel = new Label("Level Editor", skin);
    stage.addActor(titleLabel);
    Table table = new Table();
    stage.addActor(table);
    table.setSize(V_WIDTH / 3, V_HEIGHT);
    table.setPosition(0, 0);
    table.debug(); // show debug shit

    int i = 0;
    for (E_TOOL e : E_TOOL.values()) {
      // for use in the input listener
      final E_TOOL temp = e;
      TextButton b = new TextButton(e.name(), skin);
      b.addListener(
          new InputListener() {
            @Override
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
              current_Tool = temp;
              return false;
            }
          });

      if (++i % 2 == 0) {
        table.row();
      }
      table.add(b);
    }

    table.row();

    table.add(new Label("Zoom", skin));
    zoomSlider = new Slider(0.1f, 10.0f, 0.1f, false, skin);
    zoomSlider.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            cam.zoom = zoom = zoomSlider.getValue();
          }
        });
    table.add(zoomSlider);

    table.row();

    table.add(new Label("Grid", skin));
    gridSlider = new Slider(1, 20, 1, false, skin);
    gridSlider.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            gridSize = (int) gridSlider.getValue();
          }
        });
    table.add(gridSlider);

    final List pointTypeList = new List(skin);
    pointTypeList.setItems(Point.TYPE.values());
    pointTypeList.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            point_Type = (Point.TYPE) pointTypeList.getSelected();
          }
        });

    final List shapeTypeList = new List(skin);
    shapeTypeList.setItems(Shape.TYPE.values());
    shapeTypeList.addListener(
        new ChangeListener() {
          @Override
          public void changed(ChangeEvent event, Actor actor) {
            shape_Type = (Shape.TYPE) shapeTypeList.getSelected();
          }
        });

    table.row();
    table.add(pointTypeList);

    table.row();
    table.add(shapeTypeList);

    current_Tool = E_TOOL.SELECT;
    point_Type = Point.TYPE.SPAWN;
    shape_Type = Shape.TYPE.WALL;

    gridSize = 2;
    width = V_WIDTH;
    height = V_HEIGHT;
    zoom = 5;

    cam.zoom = zoom;

    filename = "blacklevel.lvl";
    loadLevel(filename);

    setInputProcessor(new InputMultiplexer(stage, new EditorInputAdapter()));
  }
Example #7
0
  public void init() {
    add = new ParticleEffect();
    add.load(
        Gdx.files.internal(Setting.GAME_RES_PARTICLE + "addp.p"),
        Gdx.files.internal(Setting.GAME_RES_PARTICLE));
    add.setPosition(835, 111);

    render = new ShapeRenderer();
    render.setAutoShapeType(true);

    stage =
        new Stage(
            new ScalingViewport(
                Scaling.stretch,
                GameUtil.screen_width,
                GameUtil.screen_height,
                new OrthographicCamera()),
            GameMenuView.stage.getBatch());

    $.add(
            new ImageButton(
                Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_GLOBAL + "exit.png"),
                Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_GLOBAL + "exitc.png")))
        .setPosition(960, 550)
        .fadeOut()
        .addAction(Actions.parallel(Actions.fadeIn(0.2f), Actions.moveTo(960, 510, 0.1f)))
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                Music.playSE("snd210");
                GameViews.gameview.stackView.disposes();
              }
            })
        .appendTo(stage);

    $.add(
            new ImageButton(
                Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_GLOBAL + "min.png"),
                Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_GLOBAL + "minc.png")))
        .setPosition(910, 550)
        .fadeOut()
        .addAction(Actions.parallel(Actions.fadeIn(0.2f), Actions.moveTo(910, 510, 0.1f)))
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                GameViews.gameview.stackView.onkeyDown(Keys.ESCAPE);
                Music.playSE("snd210");
              }
            })
        .appendTo(stage);

    Image bg = Res.get(Setting.GAME_RES_IMAGE_MENU_ITEM + "item_bg.png");
    bg.setColor(1, 1, 1, 0);
    bg.setPosition(160, 28);
    bg.addAction(Actions.fadeIn(0.2f));
    stage.addActor(bg);

    ListStyle style = new ListStyle();
    style.font = FontUtil.generateFont(" ".toCharArray()[0], 22);
    style.selection = Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_EQUIP + "equipsel.png");
    style.fontColorSelected = Color.valueOf("f5e70c");
    elist = new com.rpsg.rpg.system.ui.List<Item>(style);
    elist.onClick(
        new Runnable() {
          @Override
          public void run() {
            item = elist.getSelected();
            Music.playSE("snd210");
          }
        });
    elist.layout();
    pane = new ScrollPane(elist);
    pane.getStyle().vScroll = Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_ITEM + "scrollbar.png");
    pane.getStyle().vScrollKnob =
        Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_ITEM + "scrollbarin.png");
    pane.setForceScroll(false, true);
    pane.layout();

    Table table = new Table();
    table.add(pane);
    table.padRight(20);
    table.setPosition(170, 40);
    table.setSize(270, 390);
    table.getCell(pane).width(table.getWidth()).height(table.getHeight() - 20);
    table.setColor(1, 1, 1, 0);
    table.addAction(Actions.fadeIn(0.2f));
    stage.addActor(table);
    topbarSel = Res.get(Setting.GAME_RES_IMAGE_MENU_ITEM + "topsel.png");
    topbar = new Table();
    topbar.setBackground(Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_ITEM + "topbar.png"));
    topbar.setSize(818, 42);
    topbar.setPosition(160, 455);
    int tmpI = 0, offsetX = 135;
    topbar.add(new TopBar("medicine", tmpI++ * offsetX));
    topbar.add(new TopBar("material", tmpI++ * offsetX));
    topbar.add(new TopBar("cooking", tmpI++ * offsetX));
    topbar.add(new TopBar("equipment", tmpI++ * offsetX));
    topbar.add(new TopBar("spellcard", tmpI++ * offsetX));
    topbar.add(new TopBar("important", tmpI++ * offsetX));
    for (Cell cell : topbar.getCells()) {
      cell.padLeft(50).padRight(34).height(40);
      cell.getActor()
          .addListener(
              new InputListener() {
                public boolean touchDown(
                    InputEvent event, float x, float y, int pointer, int button) {
                  Music.playSE("snd210");
                  return true;
                }
              });
    }

    stage.addActor(topbar);

    generateLists("medicine");

    final Actor mask = new Actor();
    mask.setWidth(GameUtil.screen_width);
    mask.setHeight(GameUtil.screen_height);
    mask.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return false;
          }
        });
    stage.addActor(mask);
    scuse = Res.get(Setting.GAME_RES_IMAGE_MENU_SC + "sc_use.png");
    scuse.loaded =
        new Runnable() {
          @Override
          public void run() {
            scuse.setPosition(
                (int) (GameUtil.screen_width / 2 - scuse.getWidth() / 2),
                (int) (GameUtil.screen_height / 2 - scuse.getHeight() / 2));
          }
        };
    sellist = new com.rpsg.rpg.system.ui.List<ListItem>(style);
    sellist.onDBClick(
        new Runnable() {
          @Override
          public void run() {
            sellist.getSelected().run.run();
          }
        });
    can =
        new Runnable() {
          @Override
          public void run() {
            scuse.visible = false;
            sellist.setVisible(false);
            mask.setVisible(false);
            layer = 0;
          }
        };
    sellist.setPosition(368, 240);
    sellist.setSize(254, 100);
    sellist.layout();

    stage.addActor(
        sellist.onClick(
            new Runnable() {
              @Override
              public void run() {
                Music.playSE("snd210");
              }
            }));

    final Actor mask2 = new Actor();
    mask2.setWidth(GameUtil.screen_width);
    mask2.setHeight(GameUtil.screen_height);
    mask2.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return false;
          }
        });

    elist.onDBClick(
        new Runnable() {
          @Override
          public void run() {
            scuse.visible = true;
            sellist.offsetX2 = 20;
            sellist.getItems().clear();
            if (item.type == Item.TYPE_USEINMAP)
              sellist
                  .getItems()
                  .add(
                      new ListItem("使用")
                          .setUserObject(Res.get(Setting.GAME_RES_IMAGE_ICONS + "yes.png"))
                          .setRunnable(
                              new Runnable() {
                                @Override
                                public void run() {
                                  scfor.visible = true;
                                  herolist.setVisible(true);
                                  mask2.setVisible(true);
                                  layer = 2;
                                }
                              }));
            if (item.throwable)
              sellist
                  .getItems()
                  .add(
                      new ListItem("丢弃")
                          .setUserObject(Res.get(Setting.GAME_RES_IMAGE_ICONS + "bin.png"))
                          .setRunnable(
                              new Runnable() {
                                @Override
                                public void run() {
                                  group.setVisible(true);
                                  mask2.setVisible(true);
                                  can.run();
                                  currentCount = 1;
                                  layer = 3;
                                }
                              }));
            sellist
                .getItems()
                .add(
                    new ListItem("取消")
                        .setUserObject(Res.get(Setting.GAME_RES_IMAGE_ICONS + "no.png"))
                        .setRunnable(
                            new Runnable() {
                              @Override
                              public void run() {
                                can.run();
                              }
                            }));
            sellist.onDBClick(
                new Runnable() {
                  @Override
                  public void run() {
                    sellist.getSelected().run.run();
                  }
                });
            sellist.setVisible(true);
            sellist.setSelectedIndex(0);
            sellist.setItemHeight(27);
            sellist.padTop = 2;
            mask.setVisible(true);
            layer = 1;
          }
        });

    stage.addActor(mask2);
    scfor = Res.get(Setting.GAME_RES_IMAGE_MENU_ITEM + "selbg.png");
    scfor.setPosition(500, 87);

    herolist = new com.rpsg.rpg.system.ui.List<ListItem>(style);
    herolist.offsetX2 = 20;
    herolist
        .getItems()
        .add(new ListItem("取消").setUserObject(Res.get(Setting.GAME_RES_IMAGE_ICONS + "no.png")));
    for (Hero h : HeroController.heros) {
      herolist.getItems().add(new ListItem(h.name).setUserObject(h));
    }

    herolist
        .onDBClick(
            new Runnable() {
              @Override
              public void run() {}
            })
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                Music.playSE("snd210");
              }
            });
    herolist.setPosition(492, 273);
    herolist.setSize(257, 140);
    herolist.layout();
    stage.addActor(herolist);

    can2 =
        new Runnable() {
          @Override
          public void run() {
            scfor.visible = false;
            herolist.setVisible(false);
            mask2.setVisible(false);
            layer = 1;
          }
        };
    TextButtonStyle butstyle = new TextButtonStyle();
    butstyle.over =
        butstyle.checkedOver = Res.getDrawable(Setting.GAME_RES_IMAGE_GLOBAL + "button_hover.png");
    butstyle.down = Res.getDrawable(Setting.GAME_RES_IMAGE_GLOBAL + "button_active.png");
    butstyle.up = Res.getDrawable(Setting.GAME_RES_IMAGE_GLOBAL + "button.png");
    group = new Group();
    Image tbg = new Image(Setting.GAME_RES_IMAGE_MENU_SC + "throw.png");
    tbg.setPosition(350, 200);
    group.addActor(tbg);
    TextButton button;
    button =
        new TextButton("确定", butstyle)
            .onClick(
                new Runnable() {
                  @Override
                  public void run() {
                    ItemUtil.throwItem(currentBar.name, item, currentCount);
                    AlertUtil.add("丢弃成功。", AlertUtil.Yellow);
                    ItemView.this.generateLists(currentBar.name);
                    item = new TipItem();
                    can3.run();
                  }
                });
    button.setPosition(630, 290);
    button.setSize(100, 50);
    group.addActor(button);
    TextButton button2 =
        new TextButton("取消", butstyle)
            .onClick(
                new Runnable() {
                  @Override
                  public void run() {
                    can3.run();
                  }
                });

    button2.setPosition(630, 225);
    button2.setSize(100, 50);
    group.addActor(button2);
    ImageButton upbutton1 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "up.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "ups.png"));
    upbutton1
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount + 100 <= item.count) currentCount += 100;
              }
            })
        .setPosition(395, 340);
    group.addActor(upbutton1);
    ImageButton upbutton2 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "up.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "ups.png"));
    upbutton2
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount + 10 <= item.count) currentCount += 10;
              }
            })
        .setPosition(435, 340);
    group.addActor(upbutton2);
    ImageButton upbutton3 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "up.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "ups.png"));
    upbutton3
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount + 1 <= item.count) currentCount += 1;
              }
            })
        .setPosition(475, 340);
    group.addActor(upbutton3);
    ImageButton dbutton1 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "down.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "downs.png"));
    dbutton1
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount - 100 >= 1) currentCount -= 100;
              }
            })
        .setPosition(395, 240);
    group.addActor(dbutton1);
    ImageButton dbutton2 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "down.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "downs.png"));
    dbutton2
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount - 10 >= 1) currentCount -= 10;
              }
            })
        .setPosition(435, 240);
    group.addActor(dbutton2);
    ImageButton dbutton3 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "down.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "downs.png"));
    dbutton3
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount - 1 >= 1) currentCount -= 1;
              }
            })
        .setPosition(475, 240);
    group.addActor(dbutton3);

    Table buttable = new Table();
    buttable
        .add(
            new TextButton("最大", butstyle, 16)
                .onClick(
                    new Runnable() {
                      @Override
                      public void run() {
                        currentCount = item.count == 0 ? 1 : item.count;
                      }
                    }))
        .size(80, 33)
        .row();
    buttable
        .add(
            new TextButton("+1", butstyle, 16)
                .onClick(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (currentCount < item.count) currentCount++;
                      }
                    }))
        .size(80, 35)
        .row();
    buttable
        .add(
            new TextButton("-1", butstyle, 16)
                .onClick(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (currentCount > 1) currentCount--;
                      }
                    }))
        .size(80, 35)
        .row();
    buttable
        .add(
            new TextButton("最小", butstyle, 16)
                .onClick(
                    new Runnable() {
                      @Override
                      public void run() {
                        currentCount = 1;
                      }
                    }))
        .size(80, 33)
        .row();
    for (Cell c : buttable.getCells()) {
      c.padTop(2).padBottom(2);
    }

    buttable.setPosition(575, 300);
    group.addActor(buttable);
    stage.addActor(group);
    for (final Actor a : group.getChildren()) {
      a.addListener(
          new InputListener() {
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
              if (!(a instanceof Image)) Music.playSE("snd210");
              return true;
            }
          });
    }

    can3 =
        new Runnable() {
          @Override
          public void run() {
            group.setVisible(false);
            mask2.setVisible(false);
            can.run();
          }
        };
    can3.run();
    can2.run();
    can.run();
  }
Example #8
0
  public MainMenuScreen(final SpaceLord2Game game, final ActionResolver resolver) {
    this.game = game;
    this.resolver = resolver;

    this.game.font = new BitmapFont();
    this.game.font.getData().scale(3);
    this.game
        .font
        .getRegion()
        .getTexture()
        .setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    title = new Texture(Gdx.files.internal("space_lord_2_title.png"));

    backGround = new BackGround();

    table = new Table();
    table.defaults().width(600).padBottom(100);

    stage = new Stage(new FitViewport(GameConstants.GAME_WIDTH, GameConstants.GAME_HEIGHT));

    Gdx.input.setInputProcessor(stage);

    launchSound = Gdx.audio.newSound(Gdx.files.internal("sounds/space.mp3"));

    buttonClick = Gdx.audio.newSound(Gdx.files.internal("sounds/button_click.mp3"));

    skin = new Skin();
    skin.add("default", game.font);
    Pixmap pixmap = new Pixmap(100, 100, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.GRAY);
    pixmap.fill();
    skin.add("white", new Texture(pixmap));

    // Configure a TextButtonStyle and name it "default". Skin resources are stored by type, so this
    // doesn't overwrite the font.
    TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
    textButtonStyle.up = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.down = skin.newDrawable("white", Color.WHITE);
    textButtonStyle.checked = skin.newDrawable("white", Color.DARK_GRAY);
    textButtonStyle.over = skin.newDrawable("white", Color.LIGHT_GRAY);

    textButtonStyle.font = skin.getFont("default");

    skin.add("default", textButtonStyle);

    // Create a button with the "default" TextButtonStyle. A 3rd parameter can be used to specify a
    // name other than "default".
    final TextButton playButton = new TextButton("Play", textButtonStyle);
    table.add(playButton);
    table.row();

    final TextButton leaderboardButton = new TextButton("Leaderboard", textButtonStyle);
    table.add(leaderboardButton);
    table.row();

    final TextButton achievementButton = new TextButton("Achievements", textButtonStyle);
    table.add(achievementButton);
    table.row();

    signInButton = new TextButton("Sign In", textButtonStyle);

    table.add(signInButton);
    table.row();

    table.setPosition(GameConstants.GAME_WIDTH / 3, (GameConstants.GAME_HEIGHT / 5) * 2);

    stage.addActor(table);

    playButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            buttonClick.play();
            game.setScreen(new SpaceLord2(game, resolver));
            dispose();
          }
        });

    leaderboardButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            resolver.showLeaderboard();
          }
        });

    achievementButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            resolver.showAchievements();
          }
        });

    signInButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            buttonClick.play();
            resolver.signIn();
          }
        });

    camera = new OrthographicCamera();
    viewport = new FitViewport(GameConstants.GAME_WIDTH, GameConstants.GAME_HEIGHT, camera);
    viewport.apply();
    camera.position.set(camera.viewportWidth / 2, camera.viewportHeight / 2, 0);
  }