Class DraggableCharacter

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

public class DraggableCharacter extends UIComponent
A draggable character UI component that can be moved around the screen. The character can be removed by clicking on it and pressing the 'R' key.
  • Constructor Details

    • DraggableCharacter

      public DraggableCharacter(LevelGameArea area)
  • Method Details

    • create

      public void create()
      Initializes the draggable character by adding the image actor to the stage and setting up the drag-and-drop functionality.
      Overrides:
      create in class UIComponent
    • dispose

      public void dispose()
      Disposes of the character image.
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class RenderComponent
    • draw

      protected void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Draws the character image at the specified offsets.
      Specified by:
      draw in class RenderComponent
      Parameters:
      batch - The SpriteBatch used for drawing.
    • getTexturePath

      public String getTexturePath()
      Gets the current texture path of the character.
      Returns:
      The texture path as a String.
    • getOffsetX

      public float getOffsetX()
      Gets the current X offset of the character image.
      Returns:
      The X offset as a float.
    • getOffsetY

      public float getOffsetY()
      Gets the current Y offset of the character image.
      Returns:
      The Y offset as a float.
    • getScale

      public float getScale()
      Gets the current scale of the character image.
      Returns:
      The scale as a float.
    • update

      public void update()
      A function that checks if the 'R' key is pressed while the mouse is over the character image. If so, it removes the image from the stage and disposes of the entity.
      Overrides:
      update in class Component
    • setTexture

      public void setTexture(String path)
    • setOffsets

      public void setOffsets(float x, float y)
    • setScale

      public void setScale(float scale)