Package com.csse3200.game.ui
Class PixelPerfectPlacer
java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.Group
com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
com.badlogic.gdx.scenes.scene2d.ui.Stack
com.csse3200.game.ui.PixelPerfectPlacer
- All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Cullable
,com.badlogic.gdx.scenes.scene2d.utils.Layout
public class PixelPerfectPlacer
extends com.badlogic.gdx.scenes.scene2d.ui.Stack
A layout component that allows placing actors at precise pixel coordinates relative to a background image.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Helper record to store the actor's pixel-based layout constraints. -
Constructor Summary
ConstructorsConstructorDescriptionPixelPerfectPlacer
(com.badlogic.gdx.graphics.Texture texture) Creates a new PixelPerfectPlacer with a specified background image. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOverlay
(com.badlogic.gdx.scenes.scene2d.Actor actor, PixelPerfectPlacer.Rect rect) Adds an actor to be placed on top of the background image.void
layout()
This method is called by Scene2D's layout manager whenever the table's size or children change.Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Stack
add, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, invalidate
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
childrenChanged, draw, hit, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged, validate
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, applyTransform, clear, clear, clearChildren, clearChildren, computeTransform, debugAll, drawChildren, drawDebug, drawDebugChildren, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, removeActor, removeActor, removeActorAt, resetTransform, resetTransform, setCullingArea, setDebug, setStage, setTransform, swapActor, swapActor, toString
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
-
Constructor Details
-
PixelPerfectPlacer
public PixelPerfectPlacer(com.badlogic.gdx.graphics.Texture texture) Creates a new PixelPerfectPlacer with a specified background image.- Parameters:
texture
- The background texture to use.
-
-
Method Details
-
addOverlay
Adds an actor to be placed on top of the background image.- Parameters:
actor
- The actor to place (e.g., a Table, Button, etc.).rect
- the box with x,y corresponding to top left corner of the box taken from the top left corner of the image (using gimp) and its width and height
-
layout
public void layout()This method is called by Scene2D's layout manager whenever the table's size or children change. It calculates and applies the correct on-screen positions and sizes for all overlaid actors.- Specified by:
layout
in interfacecom.badlogic.gdx.scenes.scene2d.utils.Layout
- Overrides:
layout
in classcom.badlogic.gdx.scenes.scene2d.ui.Stack
-