Class DragOverlay

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, Renderable, Comparable<Renderable>

public class DragOverlay extends UIComponent
A simple overlay image that follows the cursor while dragging. When the cursor clicks on a tile, the drag is cancelled.
  • Constructor Details

    • DragOverlay

      public DragOverlay(AreaAPI area)
      Create a drag overlay for the given area.
      Parameters:
      area - Area to place units in.
  • Method Details

    • create

      public void create()
      Creates the drag overlay image actor and adds it to the stage.
      Overrides:
      create in class UIComponent
    • begin

      public void begin(com.badlogic.gdx.graphics.Texture texture)
      Start a drag with the given texture.
      Parameters:
      texture - Texture to show while dragging.
    • cancel

      public void cancel()
      Stop the drag without placing.
    • draw

      protected void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Renders the drag image if active.
      Specified by:
      draw in class RenderComponent
      Parameters:
      batch - Batch to render to.
    • setImageScale

      public void setImageScale(float scale)
      Sets the scale of the drag image.
      Parameters:
      scale -
    • update

      public void update()
      Updates the position of the drag image to follow the cursor.
      Overrides:
      update in class Component
    • dispose

      public void dispose()
      Cancels a drag in progress.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class RenderComponent