Package com.csse3200.game.ui
Class DragOverlay
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.ui.UIComponent
com.csse3200.game.ui.DragOverlay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,Renderable
,Comparable<Renderable>
A simple overlay image that follows the cursor while dragging. When the cursor clicks on a tile,
the drag is cancelled.
-
Field Summary
Fields inherited from class com.csse3200.game.ui.UIComponent
skin, stage
Fields inherited from class com.csse3200.game.rendering.RenderComponent
colour
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
begin
(com.badlogic.gdx.graphics.Texture texture) Start a drag with the given texture.void
cancel()
Stop the drag without placing.void
create()
Creates the drag overlay image actor and adds it to the stage.void
dispose()
Cancels a drag in progress.protected void
draw
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Renders the drag image if active.void
setImageScale
(float scale) Sets the scale of the drag image.void
update()
Updates the position of the drag image to follow the cursor.Methods inherited from class com.csse3200.game.ui.UIComponent
getLayer, getZIndex
Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, getColour, render, setColour
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, getPriority, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
DragOverlay
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 classUIComponent
-
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 classRenderComponent
- 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. -
dispose
public void dispose()Cancels a drag in progress.- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
- Overrides:
dispose
in classRenderComponent
-