コード例 #1
0
ファイル: RenderingSystem.java プロジェクト: vladsvs/sioncore
  protected void renderParticles() {
    particleFrameBuffer.begin();
    batch.begin();

    Color initialColor = batch.getColor();

    Values<Entity> values = particleEntities.values();

    while (values.hasNext()) {
      Entity entity = values.next();
      ParticleComponent particle = entity.getComponent(ParticleComponent.class);
      ColorComponent color = entity.getComponent(ColorComponent.class);

      if (color != null) {
        batch.setColor(color.color);
      }

      particle.effect.draw(batch);

      batch.setColor(initialColor);
    }

    batch.end();
    particleFrameBuffer.end();

    batch.begin();
    batch.draw(particleRegion, 0.0f, 0.0f);
    batch.end();
  }
コード例 #2
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();
  }
コード例 #3
0
 private void renderGuiExtraLives(SpriteBatch batch) {
   float x = cameraGUI.viewportWidth - 50 - Constants.LIVES_START * 50;
   float y = -15;
   for (int i = 0; i < Constants.LIVES_START; ++i) {
     if (worldController.lives <= i) batch.setColor(0.5f, 0.5f, 0.5f, 0.5f);
     batch.draw(Assets.instance.bunny.head, x + i * 50, y, 50, 50, 120, 100, 0.35f, -0.35f, 0);
     batch.setColor(1, 1, 1, 1);
   }
   if (worldController.lives >= 0 && worldController.livesVisual > worldController.lives) {
     int i = worldController.lives;
     float alphaColor = Math.max(0, worldController.livesVisual - worldController.lives - 0.5f);
     float alphaScale = 0.35f * (2 + worldController.livesVisual - worldController.lives) * 2;
     float alphaRotate = -45 * alphaColor;
     batch.setColor(1.0f, 0.7f, 0.7f, alphaColor);
     batch.draw(
         Assets.instance.bunny.head,
         x + i * 50,
         y,
         50,
         50,
         120,
         100,
         alphaScale,
         -alphaScale,
         alphaRotate);
     batch.setColor(1, 1, 1, 1);
   }
 }
コード例 #4
0
ファイル: Enemy.java プロジェクト: pedja1/SMC-Android
  @Override
  public final void _render(SpriteBatch spriteBatch) {
    if (frozen) {
      // set shader
      float brightness = .5f / (freezeCounterMax / freezeCounter);
      spriteBatch.setShader(Shader.FREEZE_SHADER);
      spriteBatch.getShader().setUniformf("u_contrast", 1.1f);
      spriteBatch.getShader().setUniformf("u_brightness", brightness);

      // set color
      frozenColor.a = FROZEN_COLOR_START_ALPHA / (freezeCounterMax / freezeCounter);
      spriteBatch.setColor(frozenColor);

      // render
      doRender(spriteBatch);

      // reset shader
      spriteBatch.setShader(null);

      // reset color
      spriteBatch.setColor(Color.WHITE);
    } else {
      doRender(spriteBatch);
    }
  }
コード例 #5
0
ファイル: Player.java プロジェクト: ochi12/Not-There-Yet
  public void drawUi(SpriteBatch batch) {
    float x = GameScreen.playerPos.x;
    float y = GameScreen.playerPos.y;

    // Hardcoded UI:
    batch.setColor(1, 0, 0, 1);
    if (hp > 0) batch.draw(Inventory.tex, x + 300, y + 290, 9, 26, 380, 236, 9, 26, false, false);

    batch.draw(
        Inventory.tex,
        x + 309,
        y + 290,
        100 - ((500 - hp) / 5),
        26,
        399,
        262,
        16,
        26,
        false,
        false);

    if (hp >= 500)
      batch.draw(Inventory.tex, x + 409, y + 290, 9, 26, 390, 236, 9, 26, false, false);
    batch.setColor(1, 1, 1, 1);
  }
コード例 #6
0
 public void render(SpriteBatch sb) {
   if (bg != null) {
     sb.setColor(Res.PRIMARY_COLOR);
     sb.draw(bg, x - bwidth / 2, y - bheight / 2);
   }
   sb.setColor(Color.WHITE);
   sb.draw(image, x - width / 2, y - height / 2);
 }
コード例 #7
0
ファイル: Tree.java プロジェクト: Richy19/libgdx
 public void draw(SpriteBatch batch, float parentAlpha) {
   Color color = getColor();
   if (style.background != null) {
     batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
     style.background.draw(batch, getX(), getY(), getWidth(), getHeight());
     batch.setColor(Color.WHITE);
   }
   draw(batch, rootNodes, leftColumnWidth);
   super.draw(batch, parentAlpha); // Draw actors.
 }
コード例 #8
0
 private void renderGuiExtraLive(SpriteBatch batch) {
   float x = cameraGUI.viewportWidth - 50 - Constants.LIVES_START * 50;
   float y = -15;
   for (int i = 0; i < Constants.LIVES_START; i++) {
     if (i >= worldController.lives) {
       batch.setColor(0.5f, 0.5f, 0.5f, 0.5f);
     }
     batch.draw(Assets.instance.bunny.head, x + i * 50, y, 50, 50, 120, 100, 0.35f, -0.35f, 0);
     batch.setColor(1, 1, 1, 1);
   }
 }
コード例 #9
0
 @Override
 public void draw(SpriteBatch batcher, Vector2 offset, int width, int height) {
   Color c = batcher.getColor();
   batcher.setColor(color);
   for (int t = 0; t < outlines.length; t++) {
     if (surrounding[t] == TileBlockState.NONE.getValue()) {
       batcher.draw(outlines[t], offset.x * width, offset.y * height, width, height);
     }
   }
   batcher.setColor(c);
 }
コード例 #10
0
 public void drawMenuBoxSelected(Vector2 position, float menuWidth, float menuHeight) {
   // TODO probably a better way to do this
   Color orgColor =
       new Color(com.nerddaygames.rupert.games.Protect.managers.AssetsManager.menuBox.getColor());
   Color color =
       new Color(com.nerddaygames.rupert.games.Protect.managers.AssetsManager.menuBox.getColor());
   color.a = color.a / 2;
   batch.setColor(color);
   com.nerddaygames.rupert.games.Protect.managers.AssetsManager.menuBox.draw(
       batch, position.x, position.y, menuWidth, menuHeight);
   batch.setColor(orgColor);
 }
コード例 #11
0
ファイル: ASprite.java プロジェクト: xjx0524/Game
 public void draw(SpriteBatch batch, float parentAlpha, Texture tex) {
   doAlter(batch, parentAlpha);
   if (!visibleForPlayer) return;
   batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
   batch.draw(
       tex,
       x,
       y,
       originX,
       originY,
       width,
       height,
       scaleX,
       scaleY,
       rotation,
       0,
       0,
       tex.getWidth(),
       tex.getHeight(),
       false,
       false);
   super.draw(batch, color.a * parentAlpha);
   // Log.i("", "DrawParam:"+ x+","+ y+"," +originX+","+ originY+","+ width+","+ height+","+
   // scaleX+",\n"+
   //	 scaleY+","+ rotation+","+ 0+","+ 0+","+ tex.getWidth()+","+  tex.getHeight()+","+  false+","
   // + false);
 }
コード例 #12
0
ファイル: GameOverlay.java プロジェクト: happypandaface/28in
  public void drawSheepMessage(SheepMessage msg) {
    if (resultTime > resultFadeDelay) {
      resultTime = resultFadeDelay;
      if (!shownBottomMenu) {
        shownBottomMenu = true;
        showSheepMessageButtons();
      }
    }
    // get the alpha based on the time the message has been on the screen
    float alpha = (resultTime / resultFadeDelay) * resultBannerAlpha;
    // set the alpha of the batch
    batch.setColor(1.0f, 1.0f, 1.0f, alpha);

    TextBounds tb = assetHolder.fontWhite.getMultiLineBounds(msg.msg);

    // draw the background for the text with some padding
    Texture tex = assetHolder.redTex;
    if (msg.color.equals("green")) tex = assetHolder.greenTex;
    batch.draw(
        tex,
        assetHolder.getPercentWidth(.45f) - (float) tb.width / 2.0f,
        assetHolder.getPercentHeight(msg.pos - .025f) - (float) tb.height / 2.0f,
        tb.width + assetHolder.getPercentWidth(.1f),
        tb.height + assetHolder.getPercentHeight(.05f));

    // set the alpha of the font
    assetHolder.fontWhite.setColor(1, 1, 1, alpha);
    assetHolder.fontWhite.drawMultiLine(
        batch,
        msg.msg,
        assetHolder.getPercentWidth(.5f) - (float) tb.width / 2.0f,
        assetHolder.getPercentHeight(msg.pos) + (float) tb.height / 2.0f,
        tb.width,
        HAlignment.CENTER);
  }
コード例 #13
0
ファイル: BitmapFont.java プロジェクト: mbakker2000/libgdx
  /**
   * Draws a string, which may contain newlines (\n), at the specified position and alignment. Each
   * line is aligned horizontally within a rectangle of the specified width.
   *
   * @param x The x position for the left most character.
   * @param y The y position for the top of most capital letters in the font (the {@link
   *     #getCapHeight() cap height}).
   * @return The bounds of the rendered string (the height is the distance from y to the baseline of
   *     the last line). Note the same TextBounds instance is used for all methods that return
   *     TextBounds.
   */
  public TextBounds drawMultiLine(
      SpriteBatch spriteBatch,
      CharSequence str,
      float x,
      float y,
      float alignmentWidth,
      HAlignment alignment) {
    float batchColor = spriteBatch.color;
    float down = this.down;
    int start = 0;
    int numLines = 0;
    int length = str.length();
    float maxWidth = 0;
    while (start < length) {
      int lineEnd = indexOf(str, '\n', start);
      float xOffset = 0;
      if (alignment != HAlignment.LEFT) {
        float lineWidth = getBounds(str, start, lineEnd).width;
        xOffset = alignmentWidth - lineWidth;
        if (alignment == HAlignment.CENTER) xOffset = xOffset / 2;
      }
      float lineWidth = draw(spriteBatch, str, x + xOffset, y, start, lineEnd).width;
      maxWidth = Math.max(maxWidth, lineWidth);
      start = lineEnd + 1;
      y += down;
      numLines++;
    }
    spriteBatch.setColor(batchColor);

    textBounds.width = maxWidth;
    textBounds.height = capHeight + (numLines - 1) * lineHeight;
    return textBounds;
  }
コード例 #14
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());
  }
コード例 #15
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(1f, 1f, 1f, 0f);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    batch.setProjectionMatrix(camera.combined);
    // menu goes here
    batch.begin();
    batch.setColor(Color.GREEN);
    batch.draw(continueButton, 0, MyGdxGame.hR * 3 / 4, MyGdxGame.wR, MyGdxGame.hR / 4);
    batch.draw(newGameButton, 0, MyGdxGame.hR / 2, MyGdxGame.wR, MyGdxGame.hR / 4);
    batch.draw(optionsButton, 0, MyGdxGame.hR / 4, MyGdxGame.wR, MyGdxGame.hR / 4);
    batch.draw(exitButton, 0, 0, MyGdxGame.wR, MyGdxGame.hR / 4);

    batch.end();

    if (Gdx.input.justTouched()) {
      Vector3 touchPos = new Vector3();
      touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
      //			camera.unproject(touchPos);
      if (touchPos.y < MyGdxGame.hR / 4) {
        game.setScreen(MyGdxGame.gameScreen);
      }
      if (touchPos.y > MyGdxGame.hR / 4 && touchPos.y < MyGdxGame.hR / 2) {
        MyGdxGame.gameScreen = new GameScreen(game, MyGdxGame.getLandscapeGenerator());
        game.setScreen(MyGdxGame.gameScreen);
      }
      if (touchPos.y < MyGdxGame.hR * 3 / 4 && touchPos.y > MyGdxGame.hR / 2) {
        game.setScreen(MyGdxGame.optionsScreen);
      }
      if (touchPos.y > MyGdxGame.hR * 3 / 4) {
        Gdx.app.exit();
      }
    }
  }
コード例 #16
0
ファイル: Window.java プロジェクト: n8dogger32/libgdx-1
  protected void drawBackground(SpriteBatch batch, float parentAlpha) {
    if (style.stageBackground != null) {
      Color color = getColor();
      batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
      Stage stage = getStage();
      Vector2 position = stageToLocalCoordinates(Vector2.tmp.set(0, 0));
      Vector2 size = stageToLocalCoordinates(Vector2.tmp2.set(stage.getWidth(), stage.getHeight()));
      style.stageBackground.draw(
          batch, getX() + position.x, getY() + position.y, getX() + size.x, getY() + size.y);
    }

    super.drawBackground(batch, parentAlpha);
    // Draw the title without the batch transformed or clipping applied.
    float x = getX(), y = getY() + getHeight();
    TextBounds bounds = titleCache.getBounds();
    if ((titleAlignment & Align.left) != 0) x += getPadLeft();
    else if ((titleAlignment & Align.right) != 0) x += getWidth() - bounds.width - getPadRight();
    else x += (getWidth() - bounds.width) / 2;
    if ((titleAlignment & Align.top) == 0) {
      if ((titleAlignment & Align.bottom) != 0) y -= getPadTop() - bounds.height;
      else y -= (getPadTop() - bounds.height) / 2;
    }
    titleCache.setColor(Color.tmp.set(getColor()).mul(style.titleFontColor));
    titleCache.setPosition((int) x, (int) y);
    titleCache.draw(batch, parentAlpha);
  }
コード例 #17
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;
      }
    }
コード例 #18
0
ファイル: Item.java プロジェクト: TeamSweepy/Greywater
  public void render(SpriteBatch g) {
    if (onGround || thrown || dropped) {
      Point2F p = Globals.toIsoCoord(getX(), getY());
      if (dropped || thrown) {
        p.y += z;
      }

      g.setColor(drawColor);
      groundSprite.render(g, p.x, p.y);
      g.setColor(Color.WHITE);
    } else {
      System.out.println(
          "WARNING "
              + name
              + " is out of state! A inventory item is being drawn like a floor item.");
    }
  }
コード例 #19
0
 public void draw(SpriteBatch spriteBatch) {
   Color oldColor = font.getColor();
   if (down) {
     spriteBatch.setColor(Color.RED);
   } else {
     spriteBatch.setColor(Color.BLUE);
   }
   spriteBatch.draw(Assets.pureWhiteTextureRegion, x, y, w, h);
   spriteBatch.setColor(Color.WHITE);
   if (down) {
     font.setColor(oldColor.r / 2, oldColor.g / 2, oldColor.b / 2, oldColor.a);
   }
   float textX = x;
   float textY = y + h;
   textY -= (h - textHeight) / 2;
   font.drawWrapped(spriteBatch, text, textX, textY, w, alignment);
   font.setColor(oldColor);
 }
コード例 #20
0
 private void renderGuiFeatherPowerUp(SpriteBatch batch) {
   float x = -15;
   float y = 30;
   float timeLeftFeatherPowerUp = worldController.level.bunnyHead.timeLeftFeatherPowerup;
   if (timeLeftFeatherPowerUp > 0) {
     // start icon face in/out if the left power-up time is less than 4 seconds
     // the fade interval is set to 5 changes per second
     if (timeLeftFeatherPowerUp < 4) {
       if (((int) (timeLeftFeatherPowerUp * 5) % 2) != 0) {
         batch.setColor(1, 1, 1, 0.5f);
       }
     }
     batch.draw(Assets.instance.feather.feather, x, y, 50, 50, 100, 100, 0.35f, -0.35f, 0);
     batch.setColor(1, 1, 1, 1);
     Assets.instance.fonts.defaultSmall.draw(
         batch, Integer.toString((int) timeLeftFeatherPowerUp + 1), x + 60, y + 57);
   }
 }
コード例 #21
0
  @Override
  protected void begin() {
    batch.setProjectionMatrix(cameraSystem.camera.combined);
    batch.begin();
    batch.setColor(1f, 1f, 1f, 1f);

    player = tagManager.getEntity("player");
    walletCash = wm.has(player) ? wm.get(player).resources : 0;
  }
コード例 #22
0
 public void render(SpriteBatch batch) {
   float alpha = 1f;
   if (!enabled) alpha = 0.5f;
   batch.setColor(1f, 1f, 1f, alpha);
   batch.draw(
       Assets.manager.get("images/main_menu/btn_back.png", Texture.class),
       x,
       y,
       hRatio * 735,
       hRatio * 110);
   batch.draw(text, x, y, hRatio * 735, hRatio * 110);
   Color c = GameStaticValues.background.getColorBase();
   batch.setColor(c.r, c.g, c.b, alpha);
   if (activated)
     batch.draw(
         Assets.manager.get("images/main_menu/btn_border_pressed.png", Texture.class),
         x,
         y,
         hRatio * 735,
         hRatio * 110);
   else
     batch.draw(
         Assets.manager.get("images/main_menu/btn_border.png", Texture.class),
         x,
         y,
         hRatio * 735,
         hRatio * 110);
   if (inAnimation) {
     if (frameDelay == 0) {
       x += animationStep;
       calculateVertices();
       if (x > 0) {
         x = 0;
         inAnimation = false;
       } else if (x < bottom_limit * hRatio) {
         x = bottom_limit * hRatio;
         inAnimation = false;
       }
     } else frameDelay--;
   }
   batch.setColor(Color.WHITE);
 }
コード例 #23
0
ファイル: AlertDialog.java プロジェクト: Kurukshetran/aXonix
  @Override
  protected void drawBackground(SpriteBatch batch, float parentAlpha) {
    Color color = getColor();
    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    Stage stage = getStage();
    Vector2 position = stageToLocalCoordinates(Vector2.tmp.set(0, 0));
    Vector2 size = stageToLocalCoordinates(Vector2.tmp2.set(stage.getWidth(), stage.getHeight()));
    style.stageBackground.draw(
        batch, getX() + position.x, getY() + position.y, getX() + size.x, getY() + size.y);

    super.drawBackground(batch, parentAlpha);
  }
コード例 #24
0
ファイル: Tree.java プロジェクト: Richy19/libgdx
  /** Draws selection, icons, and expand icons. */
  private void draw(SpriteBatch batch, Array<Node> nodes, float indent) {
    Drawable plus = style.plus, minus = style.minus;
    float x = getX(), y = getY();
    for (int i = 0, n = nodes.size; i < n; i++) {
      Node node = nodes.get(i);
      Actor actor = node.actor;

      if (selectedNodes.contains(node, true) && style.selection != null) {
        style.selection.draw(
            batch, x, y + actor.getY() - ySpacing / 2, getWidth(), node.height + ySpacing);
      } else if (node == overNode && style.over != null) {
        style.over.draw(
            batch, x, y + actor.getY() - ySpacing / 2, getWidth(), node.height + ySpacing);
      }

      if (node.icon != null) {
        float iconY = actor.getY() + Math.round((node.height - node.icon.getMinHeight()) / 2);
        batch.setColor(actor.getColor());
        node.icon.draw(
            batch,
            x + node.actor.getX() - iconSpacing - node.icon.getMinWidth(),
            y + iconY,
            node.icon.getMinWidth(),
            node.icon.getMinHeight());
        batch.setColor(Color.WHITE);
      }

      if (node.children.size == 0) continue;

      Drawable expandIcon = node.expanded ? minus : plus;
      float iconY = actor.getY() + Math.round((node.height - expandIcon.getMinHeight()) / 2);
      expandIcon.draw(
          batch,
          x + indent - iconSpacing,
          y + iconY,
          expandIcon.getMinWidth(),
          expandIcon.getMinHeight());
      if (node.expanded) draw(batch, node.children, indent + indentSpacing);
    }
  }
コード例 #25
0
  @Override
  public void draw(SpriteBatch batch, float parentAlpha) {
    super.draw(batch, parentAlpha);

    batch.setColor(Colors.ICS_BLUE_SEMI_TRANSPARENT);
    batch.draw(whiteSwatch, getX(), getY() - LINE_WIDTH, getWidth(), LINE_WIDTH);
    batch.draw(
        whiteSwatch,
        getX() + getWidth(),
        getY() - LINE_WIDTH,
        LINE_WIDTH,
        getHeight() + LINE_WIDTH * 2);
  }
コード例 #26
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    if (mode != 1) {
      alpha += alphaStep;
      splashSprite.pause();
    }

    if (mode == 2 && alpha < 0)
      ((GameCore) Gdx.app.getApplicationListener()).getGameManager().setMainMenuScreen();

    batch.begin();
    if (alpha > 0) {
      batch.setColor(batchColor.r, batchColor.g, batchColor.b, alpha);
      batch.draw(
          splashSprite.getFrame(delta),
          967 * hRatio,
          620 * vRatio - ratioDifference,
          625 * hRatio,
          493 * hRatio);
      batch.setColor(batchColor);
    }
    batch.end();

    if (mode == 0 && alpha >= 59f / 60f) {
      alpha = 1;
      mode = 1;
      splashSprite.play();
    }

    if (mode == 1 && splashSprite.isFinished()) {
      mode = 2;
      alphaStep = -alphaStep;
    }

    if (mode == 2 && alpha < 0)
      ((GameCore) Gdx.app.getApplicationListener()).getGameManager().setMainMenuScreen();
  }
コード例 #27
0
  /**
   * *********************************************************************************** This
   * renders stuff on the screen
   * ***********************************************************************************
   */
  @Override
  public void draw(SpriteBatch batch, float parentAlpha) {
    final Color c = getColor();
    batch.setColor(c.r, c.g, c.b, c.a * parentAlpha);

    if (texture != null) {
      batch.draw(texture, getX(), getY(), getWidth(), getHeight());
    } else if (region != null) {
      batch.draw(region, getX(), getY(), getWidth(), getHeight());
    }

    super.draw(batch, parentAlpha);
  }
コード例 #28
0
ファイル: BitmapFont.java プロジェクト: mbakker2000/libgdx
 /**
  * Draws a string, which may contain newlines (\n), with the specified position. Each line is
  * automatically wrapped to keep it within a rectangle of the specified width, and aligned
  * horizontally within that rectangle.
  *
  * @param x The x position for the left most character.
  * @param y The y position for the top of most capital letters in the font (the {@link
  *     #getCapHeight() cap height}).
  * @return The bounds of the rendered string (the height is the distance from y to the baseline of
  *     the last line). Note the same TextBounds instance is used for all methods that return
  *     TextBounds.
  */
 public TextBounds drawWrapped(
     SpriteBatch spriteBatch,
     CharSequence str,
     float x,
     float y,
     float wrapWidth,
     HAlignment alignment) {
   float batchColor = spriteBatch.color;
   float down = this.down;
   int start = 0;
   int numLines = 0;
   int length = str.length();
   float maxWidth = 0;
   while (start < length) {
     int lineEnd = start + computeVisibleGlyphs(str, start, indexOf(str, '\n', start), wrapWidth);
     int nextLineStart;
     if (lineEnd < length) {
       int originalLineEnd = lineEnd;
       while (lineEnd > start) {
         char ch = str.charAt(lineEnd);
         if (ch == ' ' || ch == '\n') break;
         lineEnd--;
       }
       if (lineEnd == start) {
         lineEnd = originalLineEnd;
         if (lineEnd == start) lineEnd++;
         nextLineStart = lineEnd;
       } else nextLineStart = lineEnd + 1; // Eat space or newline.
     } else {
       if (lineEnd == start) lineEnd++;
       nextLineStart = length;
     }
     float xOffset = 0;
     if (alignment != HAlignment.LEFT) {
       float lineWidth = getBounds(str, start, lineEnd).width;
       xOffset = wrapWidth - lineWidth;
       if (alignment == HAlignment.CENTER) xOffset /= 2;
     }
     float lineWidth = draw(spriteBatch, str, x + xOffset, y, start, lineEnd).width;
     maxWidth = Math.max(maxWidth, lineWidth);
     start = nextLineStart;
     y += down;
     numLines++;
   }
   spriteBatch.setColor(batchColor);
   textBounds.width = maxWidth;
   textBounds.height = capHeight + (numLines - 1) * lineHeight;
   return textBounds;
 }
コード例 #29
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();
  }
コード例 #30
0
ファイル: GameOver.java プロジェクト: ryoenji/libgdx
  @Override
  public void draw(float delta) {
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    viewMatrix.setToOrtho2D(0, 0, 480, 320);
    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.setTransformMatrix(transformMatrix);
    spriteBatch.begin();
    spriteBatch.disableBlending();
    spriteBatch.setColor(Color.WHITE);
    spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false);
    spriteBatch.enableBlending();
    spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 256, 512, 256, false, false);
    String text = "It is the end my friend.\nTouch to continue!";
    TextBounds bounds = font.getMultiLineBounds(text);
    spriteBatch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);
    font.drawMultiLine(spriteBatch, text, 0, 160 + bounds.height / 2, 480, HAlignment.CENTER);
    spriteBatch.end();
  }