Esempio n. 1
0
  public IntroScreen(final DirectedGame game) {
    super(game);

    rootTable = new Table();
    rootTable.setFillParent(true);
    final Actor logo = new Image(Assets.assetsManager.get(Assets.HEADMADE_LOGO, Texture.class));
    // logo.setOrigin(logo.getWidth() / 2, logo.getHeight() / 2);
    // logo.scaleBy(2f);
    logo.setColor(Color.BLACK);

    rootTable.add(logo).center().expand();
    rootTable.row();

    // rootTable.setDebug(true);
    this.stage.addActor(rootTable);

    stage.addListener(
        new InputListener() {

          @Override
          public boolean keyDown(InputEvent event, int keycode) {
            if (keycode == Keys.ESCAPE) {
              Gdx.app.exit();
              return true;
            }
            return super.keyDown(event, keycode);
          }
        });

    Assets.instance.loadAll();
  }
Esempio n. 2
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();
   }
 }
Esempio n. 3
0
  protected void disableActors(SnapshotArray<Actor> actors, boolean disable) {
    Color color = disable ? disableColor : enableColor;
    for (Actor actor : actors) {
      actor.setColor(color);

      if (actor instanceof Group) {
        if (!(actor instanceof CheckBox)) disableActors(((Group) actor).getChildren(), disable);
      }

      if (disable) {
        if (actor instanceof TextField) {
          ((TextField) actor).setText("");
        } else if (actor instanceof CheckBox) {
          CheckBox checkBox = (CheckBox) actor;
          checkBox.setChecked(false);
        }
      }
    }
  }
Esempio n. 4
0
  @Override
  public void render() {
    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (Gdx.input.isTouched()) {
      stage.screenToStageCoordinates(stageCoords.set(Gdx.input.getX(), Gdx.input.getY()));
      Actor actor = stage.hit(stageCoords.x, stageCoords.y, true);
      if (actor != null)
        actor.setColor(
            (float) Math.random(),
            (float) Math.random(),
            (float) Math.random(),
            0.5f + 0.5f * (float) Math.random());
    }

    Array<Actor> actors = stage.getActors();
    int len = actors.size;
    if (rotateSprites) {
      for (int i = 0; i < len; i++) actors.get(i).rotateBy(Gdx.graphics.getDeltaTime() * 10);
    }

    scale += vScale * Gdx.graphics.getDeltaTime();
    if (scale > 1) {
      scale = 1;
      vScale = -vScale;
    }
    if (scale < 0.5f) {
      scale = 0.5f;
      vScale = -vScale;
    }

    len = sprites.size;
    for (int i = 0; i < len; i++) {
      Actor sprite = sprites.get(i);
      if (rotateSprites) sprite.rotateBy(-40 * Gdx.graphics.getDeltaTime());
      else sprite.setRotation(0);

      if (scaleSprites) {
        sprite.setScale(scale);
      } else {
        sprite.setScale(1);
      }
    }

    stage.draw();

    renderer.begin(ShapeType.Point);
    renderer.setColor(1, 0, 0, 1);
    len = actors.size;
    for (int i = 0; i < len; i++) {
      Group group = (Group) actors.get(i);
      renderer.point(group.getX() + group.getOriginX(), group.getY() + group.getOriginY(), 0);
    }
    renderer.end();

    fps.setText(
        "fps: "
            + Gdx.graphics.getFramesPerSecond()
            + ", actors "
            + sprites.size
            + ", groups "
            + sprites.size);
    ui.draw();
  }