예제 #1
0
 public AssetFonts() {
   // create three fonts using Libgdx's 15px bitmap font
   defaultSmall = new BitmapFont(Gdx.files.internal("font/arial-15.fnt"), false);
   // set font sizes
   defaultSmall.getData().setScale(2.5f);
   // enable linear texture filtering for smooth fonts
   defaultSmall.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
 }
예제 #2
0
파일: HUD.java 프로젝트: Stalf/droid-wars
  public HUD() {

    HUDBatch = new SpriteBatch();
    resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    font = new BitmapFont();
    font.getRegion()
        .getTexture()
        .setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
  }
예제 #3
0
  @Override
  public void show() {
    batch = new SpriteBatch();

    viewport = new FitViewport(Constants.screenWidth, Constants.screenHeight);
    Gdx.input.setInputProcessor(this);

    font = new BitmapFont(Gdx.files.internal("data/modenine.fnt"));
    font.getData().setScale(Constants.DIFFICULTY_LABEL_SCALE);
    font.getRegion()
        .getTexture()
        .setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
  }
예제 #4
0
  public void drawString(String s, float x, float y, float fontSize, boolean centered, Color col) {
    if (s == null) return;
    myTextureChecker.onString(myFont.getRegion().getTexture());
    myFont.setColor(col);
    myFont.getData().setScale(fontSize / myOrigFontHeight);
    if (!centered) {
      myFont.draw(mySpriteBatch, s, x, y);
      return;
    }

    // http://www.badlogicgames.com/wordpress/?p=3658
    layout.reset();
    layout.setText(myFont, s);
    x -= layout.width / 2;
    y -= layout.height / 2;
    myFont.draw(mySpriteBatch, layout, x, y);
  }
예제 #5
0
  public static void createSkin() {
    /// Create a font
    BitmapFont font = new BitmapFont();
    skin = new Skin();
    skin.add("default", font);

    /// Create a texture
    Pixmap pixmap =
        new Pixmap(
            (int) Gdx.graphics.getWidth() / 4,
            (int) Gdx.graphics.getHeight() / 10,
            Pixmap.Format.RGB888);
    pixmap.setColor(Color.RED);
    pixmap.fill();
    skin.add("background", new Texture(pixmap));

    /// Create a button style
    TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
    textButtonStyle.up = skin.newDrawable("background", Color.GRAY);
    textButtonStyle.down = skin.newDrawable("background", Color.DARK_GRAY);
    textButtonStyle.checked = skin.newDrawable("background", Color.DARK_GRAY);
    textButtonStyle.over = skin.newDrawable("background", Color.LIGHT_GRAY);
    textButtonStyle.font = skin.getFont("default");
    skin.add("default", textButtonStyle);

    /// Create Title Style
    Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.fontColor = Color.RED;
    Pixmap titlePixmap =
        new Pixmap(
            (int) Gdx.graphics.getWidth() / 4,
            (int) Gdx.graphics.getHeight() / 10,
            Pixmap.Format.RGB888);
    titlePixmap.setColor(Color.CLEAR);
    titlePixmap.fill();
    skin.add("titleBackground", new Texture(titlePixmap));
    labelStyle.background = skin.newDrawable("titleBackground", Color.CLEAR);
    labelStyle.font = skin.getFont("default");
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Nearest);
    skin.add("default", labelStyle);
  }
예제 #6
0
  /**
   * Creates a new LoadingScreenView.
   *
   * <p><b>Note:</b> This will load textures directly, and it is therefore important to remember to
   * dispose this view!
   */
  public LoadingScreenView() {
    // Background
    screenBgTexture = new Texture(Gdx.files.internal("data/loadingScreenBg.png"));
    Image screenBg = new Image(screenBgTexture);
    screenBg.setFillParent(true);
    addActor(screenBg);

    // The loading bar background
    loadBarBgTexture = new Texture(Gdx.files.internal("data/loadingBarBg.png"));
    loadBarBgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    loadBarBg = new Image(loadBarBgTexture);
    loadBarBg.setY(LOAD_BAR_BOTTOM_MARGIN);
    loadBarBg.setWidth(LOAD_BAR_MAX_WIDTH);
    loadBarBg.setX(1280 / 2 - LOAD_BAR_MAX_WIDTH / 2);
    addActor(loadBarBg);

    // The loading bar
    loadBarTexture = new Texture(Gdx.files.internal("data/loadingBar.png"));
    loadBarTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    loadBar = new Image(loadBarTexture);
    loadBar.setY(LOAD_BAR_BOTTOM_MARGIN);
    loadBar.setX(loadBarBg.getX());
    loadBar.setWidth(LOAD_BAR_MAX_WIDTH);
    addActor(loadBar);

    // Progress label
    progressLabelFont = new BitmapFont(Gdx.files.internal("data/fonts/arial_bold_32.fnt"), false);
    progressLabelFont
        .getRegion()
        .getTexture()
        .setFilter(TextureFilter.Linear, TextureFilter.Linear);
    LabelStyle ls = new LabelStyle(progressLabelFont, Color.BLACK);
    progressLabel = new Label("", ls);
    progressLabel.setY(65);
    addActor(progressLabel);
  }
예제 #7
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();
    // }
  }