private void renderCachedScaled() {
    cacheScaled5.setColors(red);
    cacheScaled5.draw(spriteBatch);

    cacheScaled1.draw(spriteBatch);

    if (red.a > 0.6f) return;

    cacheScaled2.draw(spriteBatch);
    cacheScaled3.draw(spriteBatch);
    cacheScaled4.draw(spriteBatch);
  }
  private void renderCached() {
    cache5.setColors(red);
    cache5.draw(spriteBatch);

    cache1.draw(spriteBatch);

    if (red.a > 0.6f) return;

    cache2.draw(spriteBatch);
    cache3.draw(spriteBatch);
    cache4.draw(spriteBatch);
  }
示例#3
0
  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);
  }
示例#4
0
  @Override
  public void draw() {
    if (_flickerTimer != 0) {
      _flicker = !_flicker;
      if (_flicker) return;
    }

    FlxCamera camera = FlxG._activeCamera;

    if (cameras == null) cameras = FlxG.cameras;

    if (!cameras.contains(camera, true)) return;

    if (!onScreen(camera)) return;

    _point.x = x - (camera.scroll.x * scrollFactor.x) - offset.x;
    _point.y = y - (camera.scroll.y * scrollFactor.y) - offset.y;
    _point.x += (_point.x > 0) ? 0.0000001f : -0.0000001f;
    _point.y += (_point.y > 0) ? 0.0000001f : -0.0000001f;

    // scaling
    BitmapFont font = _textField.getFont();
    if (scale.x != font.getScaleX() || scale.y != font.getScaleY()) {
      _textField.getFont().setScale(scale.x, scale.y);
      calcFrame();
    }

    // position
    _textField.setPosition(_point.x, _point.y);

    // rotation
    if (angle != 0) {
      _matrix = FlxG.batch.getTransformMatrix().cpy();

      Matrix4 rotationMatrix = FlxG.batch.getTransformMatrix();
      rotationMatrix.translate(
          _textField.getX() + (width / 2), _textField.getY() + (height / 2), 0);
      rotationMatrix.rotate(0, 0, 1, angle);
      rotationMatrix.translate(
          -(_textField.getX() + (width / 2)), -(_textField.getY() + (height / 2)), 0);

      FlxG.batch.setTransformMatrix(rotationMatrix);
    }

    // blending
    if (blend != null && currentBlend != blend) {
      int[] blendFunc = BlendMode.getOpenGLBlendMode(blend);
      FlxG.batch.setBlendFunction(blendFunc[0], blendFunc[1]);
    } else if (Gdx.graphics.isGL20Available() && (FlxG.batchShader == null || ignoreBatchShader)) {
      // OpenGL ES 2.0 shader render
      renderShader();
      // OpenGL ES 2.0 blend mode render
      renderBlend();
    }

    // Render shadow behind the text
    if (_shadow != 0) {
      // tinting
      int tintColor = FlxU.multiplyColors(_shadow, camera.getColor());
      _textField.setColor(
          ((tintColor >> 16) & 0xFF) * 0.00392f,
          ((tintColor >> 8) & 0xFF) * 0.00392f,
          (tintColor & 0xFF) * 0.00392f,
          ((_shadow >> 24) & 0xFF) * _alpha * 0.00392f);
      _textField.translate(_shadowX, _shadowY);
      _textField.draw(FlxG.batch);
      _textField.translate(-_shadowX, -_shadowY);
    }

    // tinting
    int tintColor = FlxU.multiplyColors(_color, camera.getColor());
    _textField.setColor(
        ((tintColor >> 16) & 0xFF) * 0.00392f,
        ((tintColor >> 8) & 0xFF) * 0.00392f,
        (tintColor & 0xFF) * 0.00392f,
        _alpha);

    _textField.draw(FlxG.batch);

    // rotation
    if (angle != 0) FlxG.batch.setTransformMatrix(_matrix);

    _VISIBLECOUNT++;

    if (FlxG.visualDebug && !ignoreDrawDebug) drawDebug(camera);
  }
示例#5
0
 public void render() {
   bitmapFontCache.draw(batch);
 }