Exemplo n.º 1
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);
  }
Exemplo n.º 2
0
 public void setStringValue(String stringValue) {
   this.stringValue = stringValue;
   bitmapFontCache.setText(glyphLayout, bitmapFontCache.getX(), bitmapFontCache.getY());
 }