Пример #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();
 }
Пример #2
0
  public void animate() {
    if (placement.equals(Placement.RELATIVE)) {
      CameraHandler cameraHandler = gui.getApp().getCameraHandler();

      Vector2 targetPosition =
          new Vector2(target.x + target.width / 2, target.y + target.height / 2);
      Vector2 cameraPosition =
          new Vector2(cameraHandler.getCamera().position.x, cameraHandler.getCamera().position.y);

      float time = targetPosition.dst(cameraPosition) / (App.WORLD_SCALE * 10);
      Tween.to(cameraHandler, CameraHandlerAccessor.SET, Math.max(2f, time))
          .target(targetPosition.x, targetPosition.y)
          .ease(TweenEquations.easeOutCubic)
          .start(App.getTweenManager());
      /* Tween.to(cameraHandler, CameraHandlerAccessor.ZOOM, 1).target(cameraHandler.getCamera().zoom / 2).start(
      App.getTweenManager());    */
    }
  }
Пример #3
0
  public Notice(
      Gui gui, Rectangle target, Orientation orientation, String message, Placement placement) {
    super(gui);
    switch (orientation) {
      case TOP_LEFT:
        this.x = target.x + target.width;
        this.y = target.y;
        break;
      case TOP_RIGHT:
        this.x = target.x;
        this.y = target.y;
        break;
      case BOTTOM_LEFT:
        this.x = target.x + target.width;
        this.y = target.y + target.height;
        break;
      case BOTTOM_RIGHT:
        this.x = target.x;
        this.y = target.y + target.height;
        break;
    }
    this.target = target;
    this.orientation = orientation;
    this.message = message;
    this.placement = placement;
    this.maxWidth = Gdx.graphics.getWidth() / 4;
    this.text = new DisplayText(gui, new Rectangle(), gui.getFont(), BitmapFont.HAlignment.CENTER);
    this.backgroud = new GuiBox(gui, new Rectangle());
    arrow =
        new Icon(gui, new Rectangle()) {
          @Override
          public void process(float x, float y) {}
        };
    refresh();

    if (placement.equals(Placement.RELATIVE)) {
      setRenderer(this);
      setRenderer(backgroud);
      setRenderer(text);
      setRenderer(arrow);
    }
  }