예제 #1
0
  @Override
  public void onDraw() {
    super.onDraw();

    J2hGame game = Game.getGame();

    Color color = Color.WHITE;

    topFont.setColor(color);
    botFont.setColor(color);

    String text = "Developer Menu";
    TextBounds bounds = topFont.getBounds(text);

    topFont.setColor(Color.BLACK);
    topFont.draw(game.batch, text, Game.getGame().getWidth() / 2 - bounds.width / 2, 900);

    topFont.setColor(Color.WHITE);
    topFont.draw(game.batch, text, Game.getGame().getWidth() / 2 - bounds.width / 2 - 3, 903);

    text = "-----";
    bounds = botFont.getBounds(text);

    botFont.setColor(Color.BLACK);
    botFont.draw(game.batch, text, Game.getGame().getWidth() / 2 - bounds.width / 2, 820);

    botFont.setColor(Color.WHITE);
    botFont.draw(game.batch, text, Game.getGame().getWidth() / 2 - bounds.width / 2 - 3, 823);
  }
예제 #2
0
  @Override
  public void render(float delta) {
    if (this.handleInput(delta)) {
      myGame.setScreen(BaseGame.screens.get("main"));
      return;
    }

    // Make a black background
    if (Settings.getRetro()) {
      GL10 g1 = Gdx.graphics.getGL10();
      Gdx.gl.glClearColor(0, 0, 0, 1);
      g1.glClear(GL20.GL_COLOR_BUFFER_BIT);
    } else {
      GL10 g1 = Gdx.graphics.getGL10();
      Gdx.gl.glClearColor(.19f, .19f, .19f, 1f);
      g1.glClear(GL20.GL_COLOR_BUFFER_BIT);
    }

    float dpi = Gdx.graphics.getDensity() * 160f;
    float inchHeight = ((float) Gdx.graphics.getHeight()) / dpi;

    spriteBatch.begin();
    font.setScale(2 * dpi * (inchHeight / 22f) / 72f);
    font.draw(spriteBatch, "High Scores", xx * .40f, yy * .98f);
    font.setScale(dpi * (inchHeight / 22f) / 72f);
    for (int i = 0; i < 10; i++) {
      font.draw(spriteBatch, scores[i][0], xx * .05f, yy * (.85f - i * .08f));
      font.draw(spriteBatch, scores[i][1], xx * .20f, yy * (.85f - i * .08f));
      font.draw(spriteBatch, scores[i][2], xx * .70f, yy * (.85f - i * .08f));
    }
    spriteBatch.end();
  }
예제 #3
0
 @Override
 public void render(float delta) {
   if (assets.update()) // Updates assets loading and returns true is finished
   {
     Gdx.app.log("ProjectOne", "All assets loaded successfully ...");
     // game.setScreen(new MainMenu(game, assets)); // Loads main menu screen after loading assets
     game.setScreen(
         new GameScreen(
             game, assets,
             0)); // If anything pressed or touched (android) moves on and it's playtime :) (loads
     // 0 level)
   } else {
     float progress = assets.getProgress() * 100;
     Gdx.gl.glClearColor(0f, 0f, 0f, 1);
     Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
     batch.begin();
     font.draw(
         batch, Float.toString(progress) + " %", 400, 240); // Progress "bar" (percentage for now)
     font.draw(
         batch,
         Integer.toString(assets.getLoadedAssets())
             + " loaded / "
             + Integer.toString(assets.getQueuedAssets())
             + " to go ...",
         360,
         220);
     batch.end();
   }
 }
예제 #4
0
  @Override
  public void render(float delta) {
    update(delta);

    Gdx.gl20.glClear(
        GL20.GL_COLOR_BUFFER_BIT
            | (Gdx.graphics.getBufferFormat().coverageSampling
                ? GL20.GL_COVERAGE_BUFFER_BIT_NV
                : 0));
    Gdx.gl20.glClearColor(0.0f, 0.0f, 0.1f, 1.0f);

    universe.render();

    pauseMenuBatch.begin();
    if (paused) {
      pauseMenuBatch.draw(
          pauseBackground, 0, UltranautGame.HEIGHT / 2 - 200, UltranautGame.WIDTH, 400);
      pauseFont.draw(
          pauseMenuBatch,
          "Stasis",
          UltranautGame.WIDTH / 2 - new GlyphLayout(pauseFont, "Stasis").width / 2,
          UltranautGame.HEIGHT / 2 + 150);
      resume.draw(pauseMenuBatch);
      mainMenu.draw(pauseMenuBatch);
      exit.draw(pauseMenuBatch);
    }

    if (UltranautGame.debug) {
      pauseFont.draw(
          pauseMenuBatch, Gdx.graphics.getFramesPerSecond() + "fps", 5, Gdx.graphics.getHeight());
    }
    pauseMenuBatch.end();
  }
예제 #5
0
  private void renderTextOverlay() {
    fsb.begin();

    String curStr;

    curStr = "Score " + player.score;
    TextBounds txtBounds = bigFont.getBounds(curStr);

    bigFont.setColor(Color.WHITE);
    bigFont.draw(fsb, curStr, 40, Globals.PSCR_H - txtBounds.height);

    curStr = "Shield " + player.shield;
    txtBounds = bigFont.getBounds(curStr);
    bigFont.draw(fsb, curStr, Globals.PSCR_W - 600, Globals.PSCR_H - txtBounds.height);

    curStr = "Health " + player.hp;
    txtBounds = bigFont.getBounds(curStr);
    bigFont.draw(
        fsb, curStr, Globals.PSCR_W - txtBounds.width - 100, Globals.PSCR_H - txtBounds.height);

    curStr = player.alive ? "ALIVE" : "DEAD";
    txtBounds = bigFont.getBounds(curStr);

    bigFont.setColor(player.alive ? Color.GREEN : Color.RED);
    bigFont.draw(fsb, curStr, Globals.PSCR_W - txtBounds.width, txtBounds.height + 40);

    if (player.gameover) {
      txtBounds = hugeFont.getBounds("GAME OVER!");
      float gx = (Globals.PSCR_W - txtBounds.width) / 2.0f;
      float gy = (Globals.PSCR_H - txtBounds.height) / 2.0f;
      hugeFont.draw(fsb, "GAME OVER!", gx, gy);
    }

    fsb.end();
  }
예제 #6
0
  @Override
  public void draw(Player p) {
    cam.setToOrtho(true, HawkthorneGame.WIDTH, HawkthorneGame.HEIGHT);
    cam.zoom = 1f;
    cam.update(true);
    batch.setProjectionMatrix(cam.combined);
    batch.begin();
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    batch.draw(
        this.background,
        cam.viewportWidth / 2 - this.background.getRegionWidth() / 2,
        cam.viewportHeight / 2 - this.background.getRegionHeight() / 2);

    batch.setColor(0, 0, 0, 1);
    BitmapFont font = Assets.getFont();
    font.setScale(0.8f, -0.8f);
    font.draw(batch, "SERVER", 278, 151);
    font.draw(batch, "CLIENT", 278, 181);
    batch.setColor(1, 1, 1, 1);
    batch.draw(this.arrow, 236, 139 + 30 * this.option);
    String back = Keys.toString(KeyMapping.gameKeyToInt(GameKeys.START)) + ": EXIT GAME";
    String howto =
        "<JUMP> OR " + Keys.toString(KeyMapping.gameKeyToInt(GameKeys.JUMP)) + ": SELECT ITEM";
    font.draw(batch, back, 25, 25);
    font.draw(batch, howto, 25, 55);

    font.setColor(Color.RED);
    font.draw(batch, warning, 60, 305);

    font.setColor(Color.WHITE);
    batch.end();
  }
예제 #7
0
  @Override
  public void render(float arg0) {
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    camera.update();
    if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) {
      if (focused) {
        focused = false;
      } else {
        goBack();
      }
    }

    if (focused) {
      shapeRenderer.begin(ShapeType.FilledRectangle);
      Color c = new Color(0.15f, 0.4f, 0.15f, 1f);
      shapeRenderer.setColor(c);
      shapeRenderer.filledRect(focusedBox.x, focusedBox.y, focusedBox.width, focusedBox.height);
      shapeRenderer.end();
    }

    batch.begin();
    ObjectMap.Entries<String, Rectangle> it = bindingButtons.entries();
    // draw back button text
    font.draw(batch, "Back", backButton.x, backButton.y + backButton.height);
    // draw option texts
    while (it.hasNext()) {
      ObjectMap.Entry<String, Rectangle> entry = it.next();
      Rectangle bounds = entry.value;
      font.draw(batch, entry.key, bounds.x, bounds.y + bounds.height);
      Binding binding = game.getBindings().get(entry.key);
      font.draw(batch, binding.character, bounds.x + 200.0f, bounds.y + bounds.height);
    }
    batch.end();
  }
예제 #8
0
 public void drawFont(String text, int x, int y, boolean center) {
   layout.setText(font, text);
   float w = layout.width;
   float h = layout.height;
   if (center) {
     font.draw(batch, text, x - w / 2, y - h / 2);
   } else font.draw(batch, text, x, y);
 }
  /**
   * Helper function to actually render the text.
   *
   * @param batch the spritebatch to use.
   * @param message The string to add.
   * @param x The x location.
   * @param y The y location.
   * @param color The colour to render the text as.
   * @param font The font to use.
   */
  private void renderText(
      SpriteBatch batch, String message, float x, float y, Color color, BitmapFont font) {
    GlyphLayout layout =
        new GlyphLayout(font, message, Color.BLACK, width - paddingX * 2, Align.left, false);

    font.draw(batch, layout, x + paddingX, y + height + paddingY - 2);
    layout.setText(font, message, color, width - paddingX * 2, Align.left, false);
    font.draw(batch, layout, x + paddingX, y + height + paddingY);
  }
예제 #10
0
  public void writeLine(String text, BitmapFont font, float x, float y) {
    TextBounds bounds = font.getBounds(text);

    font.setColor(Color.BLACK);
    font.draw(Game.getGame().batch, text, x - bounds.width / 2 + 3, y);

    font.setColor(Color.WHITE);
    font.draw(Game.getGame().batch, text, x - bounds.width / 2, y + 3);
  }
예제 #11
0
 @Override
 public void render() {
   Gdx.gl.glClearColor(0, 0, 0, 0);
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   gsm.render();
   batch.begin();
   font.draw(batch, Game.allByte + ":" + Game.waitTime + ":" + Game.countPlayer, 10, 25);
   font.draw(batch, "Time remain: " + Game.timeRemain, 10, 45);
   batch.end();
 }
예제 #12
0
  /**
   * @param simulation
   * @param gl
   */
  private void renderHud(GL10 gl) {
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    int width = Gdx.app.getGraphics().getWidth();
    int height = Gdx.app.getGraphics().getHeight();
    // spriteBatch.setProjectionMatrix(viewMatrix);
    // spriteBatch.setTransformMatrix(transformMatrix);

    spriteBatch.begin();
    spriteBatch.enableBlending();
    spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

    /*A minimum of dataset
    B maximum of dataset
    a is from where you would like normalised data set to start
    b is where you would like normalised data set to end
    x is the value you are trying to normalise
    a + (x-A)*(b-a)/(B-A)

    */

    float length = 0 + (progress - 0) * ((Gdx.graphics.getWidth() / 10) * 8 - 0) / (1 - 0);
    spriteBatch.setColor(0, 0, 1, 1);
    spriteBatch.draw(
        progressBarTexture,
        Gdx.graphics.getWidth() / 10,
        110,
        (Gdx.graphics.getWidth() / 10) * 8,
        30);
    spriteBatch.setColor(0, 1, 1, 1);
    spriteBatch.draw(progressBarTexture, (Gdx.graphics.getWidth() / 10) + 2, 112, length, 26);
    spriteBatch.setColor(1, 1, 1, 1);
    font.draw(spriteBatch, "Version:" + BattleBeasties3d.version, 10, 10);
    font.draw(spriteBatch, "Loading " + String.format("%.0f", progress * 100) + "%", 100, 100);
    if (Splash.fadeIn) {
      spriteBatch.setColor(0, 0, 0, Splash.fadeTimer);
      spriteBatch.draw(xfadeTexture, 0, 0, width, height);
    }
    if (Splash.fadeOut) {
      spriteBatch.setColor(1, 1, 1, Splash.fadeTimer);
      spriteBatch.draw(xfadeTexture, 0, 0, width, height);
    }
    spriteBatch.setColor(1, 1, 1, 1);
    if (BattleBeasties3d.Error == BattleBeasties3d.NETWORK_DOWN && netErrorShown == false) {
      stage.addActor(
          Actors.bottomToast(
              "Connection to internet failed, Please check your network is working.", 5, skin));

      netErrorShown = true;
    }

    spriteBatch.end();
  }
예제 #13
0
 public void draw(SpriteBatch batch) {
   if (size == 0) {
     titleFont.setColor(Colors.P_RED);
     titleFont.draw(batch, "Space", x, y);
     titleFont.setColor(Colors.P_YELLOW);
     titleFont.draw(batch, "Race!", x + 54, y - 40);
   } else {
     titleFont.setColor(Colors.P_RED);
     titleFont.draw(batch, "Space", x - 200, y + 50);
     titleFont.setColor(Colors.P_YELLOW);
     titleFont.draw(batch, "Race!", x - 92, y - 30);
   }
 }
예제 #14
0
파일: Maint.java 프로젝트: Dvimer/SeeBatle
 @Override
 public void render() {
   update();
   Gdx.gl.glClearColor(0.9f, 0.8f, 1, 1);
   Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
   batch.begin();
   fnt.draw(batch, gf.setSelCellCoords(), 30, 20);
   fnt.draw(batch, gf2.setSelCellCoords(), 340, 20);
   fnt.draw(batch, "MORSKOY BOY", 40, 400);
   gf.render(batch);
   gf2.render(batch);
   fnt.draw(batch, "Who?", InputHendler.getMouseX(), InputHendler.getMouseY());
   batch.end();
 }
예제 #15
0
파일: Render.java 프로젝트: Komposten/Leap
  // *** Methods for drawing text ***\\
  public static void drawString(
      SpriteBatch batch,
      String string,
      float x,
      float y,
      boolean centered,
      float scale,
      Color color) {
    // Check if the new scale is the same as the current one.
    if (font_.getScaleX() != scale || font_.getScaleY() != scale) font_.setScale(scale);

    // No need to check the colour, as that is done in the BitmapCache in the BitmapFont.
    font_.setColor(color);

    if (centered) {
      TextBounds bounds = font_.getBounds(string);
      float width = bounds.width;
      float height = bounds.height - font_.getAscent();

      x -= (width / 2);
      y -= (height / 2);
    }

    font_.draw(batch, string, x, y);
  }
  private void drawWorld() {
    camera.update();
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    batch.draw(background, camera.position.x - background.getWidth() / 2, 0);
    for (Rock rock : rocks) {
      batch.draw(rock.image, rock.position.x, rock.position.y);
    }
    batch.draw(ground, groundOffsetX, 0);
    batch.draw(ground, groundOffsetX + ground.getRegionWidth(), 0);
    batch.draw(ceiling, groundOffsetX, 480 - ceiling.getRegionHeight());
    batch.draw(ceiling, groundOffsetX + ceiling.getRegionWidth(), 480 - ceiling.getRegionHeight());
    batch.draw(plane.getKeyFrame(planeStateTime), planePosition.x, planePosition.y);
    batch.end();

    batch.setProjectionMatrix(uiCamera.combined);
    batch.begin();
    if (gameState == GameState.Start) {
      batch.draw(
          ready,
          Gdx.graphics.getWidth() / 2 - ready.getRegionWidth() / 2,
          Gdx.graphics.getHeight() / 2 - ready.getRegionHeight() / 2);
    }
    if (gameState == GameState.GameOver) {
      batch.draw(
          gameOver,
          Gdx.graphics.getWidth() / 2 - gameOver.getRegionWidth() / 2,
          Gdx.graphics.getHeight() / 2 - gameOver.getRegionHeight() / 2);
    }
    if (gameState == GameState.GameOver || gameState == GameState.Running) {
      font.draw(batch, "" + score, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() - 60);
    }
    batch.end();
  }
예제 #17
0
  @Override
  public void render(float delta) {
    super.render(delta);
    SpriteBatch batch = new SpriteBatch();

    BitmapFont font = new BitmapFont();
    font.getData().setScale(2f, 2f);
    font.setColor(Color.GREEN);

    batch.begin();
    font.draw(batch, Integer.toString(getGame().getHighScore()), 360, 310);
    font.draw(batch, Integer.toString(getGame().getCurrentScore()), 360, 280);
    batch.end();

    batch.dispose();
  }
  public void update(float delta) {
    Entity playerEntity = player.get(0);

    PlayerSteerableComponent psc = cmpsc.get(playerEntity);

    for (int i = 0; i < entities.size(); i++) {
      Entity entity = entities.get(i);

      TalkComponent tc = cmtc.get(entity);
      NonControllablePersonSteerableComponent ncpstc = cmstc.get(entity);
      if (ncpstc.x - 160 < psc.getPosition().x
          && psc.getPosition().x < ncpstc.x + 160
          && ncpstc.y - 210 < psc.getPosition().y
          && psc.getPosition().y < ncpstc.y + 210) {
        layout.setText(font, tc.textToSay);
        float x = ncpstc.x - (layout.width / 2);
        float y = ncpstc.y + layout.height + 15;
        batch.end();
        shapeRenderer.setProjectionMatrix(TwoD.getMain().camera.combined);
        shapeRenderer.begin(ShapeType.Filled);
        shapeRenderer.setColor(Color.WHITE);
        shapeRenderer.rect(x - 13, y + 2, 26 + layout.width, 26 + layout.height);
        shapeRenderer.setColor(Color.BLACK);
        shapeRenderer.rect(x - 10, y + 5, 20 + layout.width, 20 + layout.height);
        shapeRenderer.end();
        batch.begin();
        font.draw(batch, layout, x, y + 25);
      }
    }
  }
예제 #19
0
파일: GdxFont.java 프로젝트: eerock/libgdx
 public int drawText(AnimationState as, int x, int y, CharSequence str, int start, int end) {
   FontState fontState = evalFontState(as);
   x += fontState.offsetX;
   y += fontState.offsetY + yOffset;
   bitmapFont.setColor(renderer.getColor(fontState.color));
   return bitmapFont.draw(renderer.batch, str, x, y, start, end).width;
 }
예제 #20
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0.39f, 0.58f, 0.92f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Update deltaTime & animationTime
    deltaTime = Gdx.graphics.getDeltaTime();
    animationTime += Gdx.graphics.getDeltaTime();

    // Store Spritesheet to sprite
    sprite = new Sprite(animation.getKeyFrame(animationTime, true));
    sprite.setPosition(xPosition, 0);
    sprite.setScale(1.8f);

    // Set camera to batch and undate camera
    batch.setProjectionMatrix(camera.combined);
    camera.update();

    tiledMapRenderer.setView(camera);
    tiledMapRenderer.render(background);
    tiledMapRenderer.render(foreground);

    // Display on Screen
    batch.begin();
    sprite.draw(batch);
    batch.end();

    // update xPosition
    xPosition = xPosition + (speed * deltaTime);

    HUDBatch.begin();
    font1.draw(HUDBatch, "SCORE:100", 100, 450);
    HUDBatch.end();
  }
예제 #21
0
 @Override
 public void draw(Batch batch, float parentAlpha) {
   batch.draw(texture, this.x, this.y);
   if (hero != null) {
     bitmapFont.draw(batch, hero.name, this.x, this.y + 10);
     int i = 0;
     for (Map.Entry<String, Buff> buffEntry : hero.buffMap.entrySet()) {
       bitmapFont.draw(
           batch,
           String.valueOf(buffEntry.getValue().buffDuration),
           this.x + 2 + i * 16,
           this.y + 92);
       i++;
     }
   }
 }
예제 #22
0
    @Override
    public void draw(SpriteBatch batch, float parentAlpha) {
      final Drawable listBackground = style.listBackground;
      final Drawable listSelection = style.listSelection;
      final BitmapFont font = style.font;
      final Color fontColor = style.fontColor;

      float x = getX();
      float y = getY();
      float width = getWidth();
      float height = getHeight();

      Color color = getColor();
      batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
      listBackground.draw(batch, x, y, width, height);

      width -= listBackground.getLeftWidth() + listBackground.getRightWidth();
      x += listBackground.getLeftWidth();
      float posY = height - listBackground.getTopHeight();
      for (int i = 0; i < items.length; i++) {
        if (listSelectedIndex == i) {
          listSelection.draw(batch, x, y + posY - itemHeight, width, itemHeight);
        }
        font.setColor(fontColor.r, fontColor.g, fontColor.b, color.a * fontColor.a * parentAlpha);
        font.draw(batch, items[i], x + textOffsetX, y + posY - textOffsetY);
        posY -= itemHeight;
      }
    }
예제 #23
0
  public void draw(SpriteBatch batch) {
    batch.draw(
        /*Texture*/ sprite, /*x*/
        x - originX + dOffX, /*y*/
        y - originY + dOffY, /*originX*/
        originX, /*originY*/
        originY, /*width*/
        dWidth, /*height*/
        dHeight, /*scaleX*/
        1, /*scaleY*/
        1, /*rotation*/
        angle, /*uselss shit to the right*/
        0,
        0,
        sprite.getWidth(),
        sprite.getHeight(),
        flipX,
        flipY);

    font.draw(
        batch,
        Integer.toString(effect.getNum()),
        (float) (x + 32 - font.getScaleX() * (Math.floor(Math.log10(effect.getNum())) + 1) * 7) - 4,
        y + font.getScaleY() * 12 + 1);
  }
예제 #24
0
 public void render(SpriteBatch batch) {
   font.draw(
       batch,
       text,
       bounds.getX(),
       bounds.getY() + ((bounds.getHeight() / 2F) + (font.getLineHeight() / 4F)));
 }
예제 #25
0
  @Override
  public void render() {
    // Update
    //		Gdx.graphics.getGL10().glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    world.step(1 / 60f, 10, 10);
    for (int i = 0; i < MAX_BALL_COUNT; i++) {
      Vector2 pos =
          ballModels[i]
              .getPosition()
              .sub(ballSprites[i].getWidth() / 2, ballSprites[i].getHeight() / 2);
      float angleDeg = ballModels[i].getAngle() * MathUtils.radiansToDegrees;

      ballSprites[i].setPosition(pos.x, pos.y);
      ballSprites[i].setRotation(angleDeg);
    }

    // Render
    //		GL10 gl = Gdx.gl10;
    //		gl.glClearColor(1, 1, 1, 1);
    //		gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    spriteBatch.setProjectionMatrix(camera.combined);
    spriteBatch.begin();
    vialSprite.draw(spriteBatch);
    for (int i = 0; i < MAX_BALL_COUNT; i++) ballSprites[i].draw(spriteBatch);
    spriteBatch.end();

    spriteBatch
        .getProjectionMatrix()
        .setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    spriteBatch.begin();
    font.draw(spriteBatch, "Touch the screen to restart", 5, 25);
    spriteBatch.end();
  }
예제 #26
0
    public void draw(SpriteBatch batch, float parentAlpha) {
      super.draw(batch, parentAlpha);

      (selected ? checked : active)
          .draw(batch, getX(), getY(), checked.getMinWidth(), checked.getMinHeight());
      font.draw(batch, text, getX() + checked.getMinWidth() + pad, getY() + font.getCapHeight());
    }
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(Color.BLUE.r, Color.BLUE.g, Color.BLUE.b, Color.BLUE.a);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    camera.update();
    game.batch.setProjectionMatrix(camera.combined);

    batch.begin();
    font.draw(batch, "Loading Game", 32, 32);
    background.draw(batch);
    batch.end();

    if (licenseVerified) {
      if (Gdx.input.isTouched()) {
        Logger.logMsg("transitioning to main menu screen");
        game.setGameScreen(this, game.mainMenuScreen);
        dispose();
      }
    } else {
      Dialog dialog =
          new Dialog("license key invalid", game.uiSkin) {
            protected void result(Object object) {
              Logger.logMsg("exiting");
              Gdx.app.exit();
            }
          };
      dialog.text("Your license key is invalid, exiting...");
      dialog.button("OK", true);
      dialog.show(stage);
    }
  }
예제 #28
0
  @Override
  public void draw(SpriteBatch batch, float parentAlpha) {
    Drawable background;
    if (list != null && list.getParent() != null && style.backgroundOpen != null)
      background = style.backgroundOpen;
    else if (clickListener.isOver() && style.backgroundOver != null)
      background = style.backgroundOver;
    else background = style.background;
    final BitmapFont font = style.font;
    final Color fontColor = style.fontColor;

    Color color = getColor();
    float x = getX();
    float y = getY();
    float width = getWidth();
    float height = getHeight();

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    background.draw(batch, x, y, width, height);
    if (items.length > 0) {
      float availableWidth = width - background.getLeftWidth() - background.getRightWidth();
      int numGlyphs =
          font.computeVisibleGlyphs(
              items[selectedIndex], 0, items[selectedIndex].length(), availableWidth);
      bounds.set(font.getBounds(items[selectedIndex]));
      height -= background.getBottomHeight() + background.getTopHeight();
      float textY = (int) (height / 2 + background.getBottomHeight() + bounds.height / 2);
      font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);
      font.draw(
          batch, items[selectedIndex], x + background.getLeftWidth(), y + textY, 0, numGlyphs);
    }

    // calculate screen coords where list should be displayed
    getStage().toScreenCoordinates(screenCoords.set(x, y), batch.getTransformMatrix());
  }
예제 #29
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);
  }
 public void draw(BitmapFont font, SpriteBatch batch) {
   // Only draw if visible
   if (mVisible) {
     // Draw the texture (all are set), then draw the text over top
     batch.draw(mTexture, mX, mY, mWidth, mHeight);
     font.draw(batch, mText, mX + 10, mY + 25);
   }
 }