void setAnimation() {
   if (ui.animationList.getSelected() == null) return;
   int track = ui.trackButtons.getCheckedIndex();
   TrackEntry current = state.getCurrent(track);
   TrackEntry entry;
   if (current == null) {
     state.setEmptyAnimation(track, 0);
     entry =
         state.addAnimation(track, ui.animationList.getSelected(), ui.loopCheckbox.isChecked(), 0);
     entry.setMixDuration(ui.mixSlider.getValue());
   } else {
     entry =
         state.setAnimation(track, ui.animationList.getSelected(), ui.loopCheckbox.isChecked());
   }
   entry.setAlpha(ui.alphaSlider.getValue());
 }
Exemple #2
0
  public Gamescreen(Jamwteatrze game) {

    this.game = game;

    // set game state

    currentState = GameState.TITLE;
    // currentState = GameState.MAP;
    // currentState = GameState.ARENA;

    batch = new SpriteBatch();
    camera = new OrthographicCamera(1280, 720);
    camera.position.set(camera.viewportWidth / 2f, camera.viewportHeight / 2f, 0);
    viewport = new FitViewport(1280, 720, camera);
    camera.update();

    // spine

    sr = new SkeletonRenderer();
    dr = new SkeletonRendererDebug();
    dr.setBoundingBoxes(false);
    dr.setRegionAttachments(false);

    // stage

    stage = new Stage(viewport, batch);
    stageCharacters = new Stage(viewport, batch);

    Gdx.input.setInputProcessor(stage);

    // ----------------- DEKLARACJE

    playerIcon = new SpineActor(batch, sr, shpr, "characters/goral", true, game.player.playerHp);

    playerIcon.setPosition(-400, 180);
    stageCharacters.addActor(playerIcon);

    generujEnemys();

    // atakuj button

    atakujTex = Assets.manager.get(Assets.atakuj, Texture.class);
    atakujTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    atakujButton = new ImageButton(new SpriteDrawable(new Sprite(atakujTex)));
    atakujButton.setPosition(565, -200);
    atakujButton.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (pulaGracza > 0 && !atakowanie) {
              atakowanie = true;
              System.out.println("atakuj button pressed");
              atakuj();
            }
            return true;
          }
        });

    stage.addActor(atakujButton);

    // gui

    font = Assets.manager.get(Assets.myFont, BitmapFont.class);
    font.getData().setScale(0.7f);
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
    scena = Assets.manager.get(Assets.scena, Texture.class);
    scena.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    panel = Assets.manager.get(Assets.panel, Texture.class);
    panel.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    // tla

    swiat00tlo = Assets.manager.get(Assets.swiat00tlo, Texture.class);
    swiat00tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    swiat01tlo = Assets.manager.get(Assets.swiat01tlo, Texture.class);
    swiat01tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    swiat02tlo = Assets.manager.get(Assets.swiat02tlo, Texture.class);
    swiat02tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    swiat03tlo = Assets.manager.get(Assets.swiat03tlo, Texture.class);
    swiat03tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    kowadloTex = Assets.manager.get(Assets.kowadloTex, Texture.class);
    kowadloTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    // kowadlo = new Sprite(kowadloTex);
    // kowadlo.setPosition(100, 100);

    // DICES

    heroDices = new Array<Dice>();
    enemyDices = new Array<Dice>();

    // ------ generate hero dieces
    heroDices.add(new Dice(this, true));
    heroDices.add(new Dice(this, true));
    // heroDices.add(new Dice(this));

    numberHeroDieces = heroDices.size;
    baseHeroDieces = numberHeroDieces;

    for (Dice dice : heroDices) {
      // dice.debug();
      dice.setTouchable(Touchable.disabled);
      dice.setVisible(false);
      stage.addActor(dice);
    }

    // ------ generate enemy dieces

    enemyDices.add(new Dice(this, false));
    enemyDices.add(new Dice(this, false));

    numberEnemyDieces = enemyDices.size;
    baseEnemyDieces = numberEnemyDieces;

    for (int i = 0; i < enemyDices.size; i++) {
      enemyDices.get(i).setPosition(725 + (i * 133), -150);
      if (!heroTurn) {
        enemyDices.get(i).addAction(moveTo(725 + (i * 133), 37, 1.0f, Interpolation.bounceOut));
      }
    }

    for (Dice dice : enemyDices) {
      // dice.debug();
      stage.addActor(dice);
    }

    // kotara

    kotaraAtlas = new TextureAtlas(Gdx.files.internal("gui/kotara.atlas"));
    kotaraJson = new SkeletonJson(kotaraAtlas);
    kotaraSkeletonData = kotaraJson.readSkeletonData(Gdx.files.internal("gui/kotara.json"));
    kotaraSkeleton = new Skeleton(kotaraSkeletonData);
    kotaraIdleAnimation = kotaraSkeletonData.findAnimation("idle");
    AnimationStateData stateData = new AnimationStateData(kotaraSkeletonData);
    kotaraState = new AnimationState(stateData);
    kotaraState.addAnimation(0, "idle", true, 0);
    kotaraSkeleton.setPosition(-200, -150);

    // title

    title = new SpineButton(batch, sr, "gui/title", "idle", 100, 0, 800, 600);
    // title.debug();
    title.setClicked(false);

    if (currentState == GameState.TITLE) {
      resetTitle();
    }

    // title listeners

    title.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (!title.isClicked() && title.getY() <= 20) {
              title.setClicked(true);
              fadeOutTitle(Gdx.graphics.getDeltaTime());
            }
            return true;
          }
        });

    stage.addActor(title);

    // mapa

    mapa = new SpineButton(batch, sr, "gui/mapa", "show0", 100, 0, 800, 600);
    mapa.setPosition(mapaX, -900);
    // mapa.debug();
    mapa.setClicked(false);

    // mapa listeners TODO!

    mapa.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            fadeOutMapa(Gdx.graphics.getDeltaTime());
            return true;
          }
        });

    stage.addActor(mapa);

    // if (currentState == GameState.ARENA) {
    // resetArena();
    // }
  }