Beispiel #1
0
 @Override
 public void refresh() {
   float ingameSize = App.WORLD_SCALE / 2;
   float inguiSize = gui.getSquareSize() / 4;
   float compensatingRatio = ingameSize / inguiSize;
   int arrowSize = (int) (placement.equals(Placement.RELATIVE) ? ingameSize : inguiSize);
   Vector2 offset = new Vector2();
   float textOffset = 0;
   switch (orientation) {
     case TOP_LEFT:
       offset.y = -1;
       textOffset = 1;
       break;
     case TOP_RIGHT:
       offset.y = -1;
       offset.x = -1;
       textOffset = -1;
       break;
     case BOTTOM_LEFT:
       textOffset = 1;
       break;
     case BOTTOM_RIGHT:
       offset.x = -1;
       textOffset = -1;
       break;
   }
   arrow.set(x + offset.x * arrowSize, y + offset.y * arrowSize, arrowSize, arrowSize);
   Vector2 textSize =
       new Vector2(text.getTextWidth() + arrowSize, Math.max(text.getTextHeight(), arrowSize));
   text.set(
       x + textOffset * arrowSize + offset.x * textSize.x,
       y + offset.y * textSize.y,
       textSize.x,
       textSize.y);
   if (placement.equals(Placement.RELATIVE)) {
     text.setScale(compensatingRatio);
   }
   backgroud.set(text);
   text.refresh();
 }
Beispiel #2
0
  @Override
  public void render() {
    super.render();
    backgroud.render();
    text.render(message);
    arrow.render(
        gui.getApp()
            .getAssets()
            .getTexture(("arrow_" + orientation).toLowerCase().replaceAll("_", "")),
        "");

    this.shapeRenderer.setColor(Color.WHITE);
    this.shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
    this.shapeRenderer.rect(target.x, target.y, target.width, target.height);
    this.shapeRenderer.end();

    if (firstRender) {
      refresh();
      firstRender = false;
    }
  }