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()); */ } }
@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(); }