예제 #1
0
  public void update(float dt, OrthographicCamera cam) {
    stage.act(dt);
    if (Core.persistentAssets.update() && !assetsLoaded) {

      GameSave.save();

      assetsLoaded = true;

      layout = new Table(Core.persistentAssets.get("skins/uiskin.json", Skin.class));
      layout.setFillParent(true);
      layout.center().bottom();

      pressBtn =
          new Label(
              "Press any key to continue",
              Core.persistentAssets.get("skins/uiskin.json", Skin.class));

      layout.add(pressBtn).padBottom(40);

      layout.debug();

      stage.addActor(layout);

      stage.addListener(
          new InputListener() {
            public boolean keyUp(InputEvent event, int keycode) {
              gsm.setState(GameStateManager.MENU);
              return false;
            }

            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) {
              gsm.setState(GameStateManager.MENU);
            }
          });
    }

    if (Core.persistentAssets.isLoaded("images/main-menu/background.jpg")) {
      if (!bgLoaded) {
        bgLoaded = true;
        bg =
            new Sprite(Core.persistentAssets.get("images/main-menu/background.jpg", Texture.class));
        float[] size =
            ImageUtils.minimalStretch(bg.getWidth(), bg.getHeight(), Core.WIDTH, Core.HEIGHT);

        bg.setSize(size[0], size[1]);
        bg.setPosition(size[2], size[3]);
      }
      bgOpacity += bgOpacityModifier * dt;
      bgOpacity = bgOpacity > 1 ? 1 : bgOpacity;
    }
  }
예제 #2
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);
  }
예제 #3
0
 protected Table getTable() {
   if (table == null) {
     table = new Table(getSkin());
     table.setFillParent(true);
     if (BeatBlaster.DEV_MODE) {
       table.debug();
     }
     stage.addActor(table);
   }
   return table;
 }
예제 #4
0
  private void drawDebug() {
    if (debugShapes == null) {
      debugShapes = new ShapeRenderer();
      debugShapes.setAutoShapeType(true);
    }

    if (debugUnderMouse || debugParentUnderMouse || debugTableUnderMouse != Debug.none) {
      screenToStageCoordinates(tempCoords.set(Gdx.input.getX(), Gdx.input.getY()));
      Actor actor = hit(tempCoords.x, tempCoords.y, true);
      if (actor == null) return;

      if (debugParentUnderMouse && actor.parent != null) actor = actor.parent;

      if (debugTableUnderMouse == Debug.none) actor.setDebug(true);
      else {
        while (actor != null) {
          if (actor instanceof Table) break;
          actor = actor.parent;
        }
        if (actor == null) return;
        ((Table) actor).debug(debugTableUnderMouse);
      }

      if (debugAll && actor instanceof Group) ((Group) actor).debugAll();

      disableDebug(root, actor);
    } else {
      if (debugAll) root.debugAll();
    }

    Gdx.gl.glEnable(GL20.GL_BLEND);
    debugShapes.setProjectionMatrix(viewport.getCamera().combined);
    debugShapes.begin();
    root.drawDebug(debugShapes);
    debugShapes.end();
  }
예제 #5
0
  public void initTable() {
    table = new Table();
    table.setWidth(getWidth());
    table.setFillParent(true);
    table.center();
    table.debug();

    titleLabel = new TransparentBackgroundLabel(this.game, "", skin, "default_label");
    // Make it bigger
    titleLabel.setFontScale(1.0f);
    titleLabel.setWrap(true);
    titleLabel.setAlignment(Align.center);

    definitionLabel = new TransparentBackgroundLabel(this.game, "", skin, "default_label");
    definitionLabel.setFontScale(0.6f);
    definitionLabel.setWrap(true);
    definitionLabel.setAlignment(Align.center);

    table
        .add(titleLabel)
        .center()
        .expand()
        .width(getWidth() * 0.9f)
        .padTop(70f)
        .height(getHeight() * 0.10f);
    table.row();
    table
        .add(definitionLabel)
        .center()
        .top()
        .expand()
        .width(getWidth() * 0.9f)
        .maxHeight(getHeight() * 0.7f)
        .spaceBottom(150f);
    this.addActor(table);
  }
예제 #6
0
  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()));
  }