Package de.tum.cit.ase.editor.screens
Class EditorCanvas
java.lang.Object
de.tum.cit.ase.editor.screens.EditorCanvas
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
The EditorCanvas class represents a canvas for editing game maps.
It provides methods for rendering and updating the canvas, as well as handling user input.
The canvas is responsible for displaying the grid and tiles of the map.
The EditorCanvas class implements the Disposable interface, allowing it to be disposed when it is no longer needed.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
com.badlogic.gdx.math.Vector2
com.badlogic.gdx.scenes.scene2d.ui.Image
getGrid()
float
com.badlogic.gdx.math.GridPoint2
getMouseGridPosition
(com.badlogic.gdx.math.Vector2 position, boolean alwaysGrid) Retrieves the grid position of the mouse.com.badlogic.gdx.math.Vector2
float
com.badlogic.gdx.utils.viewport.ScreenViewport
float
getWidth()
void
Loads aMap
into the editor canvas.void
move
(float x, float y, float z) Moves the camera in the editor canvas.boolean
processMouseInput
(float x, float y, int button) Deprecated.void
render
(float dt) Renders the canvas by applying the viewport and drawing the stage.void
resize
(int width, int height) void
resizeCanvas
(float size) void
resizeCanvas
(float width, float height) Resizes the canvas to the specified width and height.void
update
(float dt) Updates the canvas and stage.
-
Field Details
-
isBigZoom
public boolean isBigZoom
-
-
Constructor Details
-
EditorCanvas
Creates an instance of EditorCanvas.- Parameters:
editor
- The Editor instance.
-
-
Method Details
-
resizeCanvas
public void resizeCanvas(float size) -
resizeCanvas
public void resizeCanvas(float width, float height) Resizes the canvas to the specified width and height.- Parameters:
width
- the new width of the canvasheight
- the new height of the canvas
-
render
public void render(float dt) Renders the canvas by applying the viewport and drawing the stage. Also renders the grid and the selected tool on the canvas.- Parameters:
dt
- the time elapsed since the last frame
-
getGrid
public com.badlogic.gdx.scenes.scene2d.ui.Image getGrid() -
update
public void update(float dt) Updates the canvas and stage.- Parameters:
dt
- the time difference between the current frame and the previous frame
-
loadMap
Loads aMap
into the editor canvas.- Parameters:
map
- the Map object representing the map to be loaded
-
resize
public void resize(int width, int height) -
processMouseInput
Deprecated. -
getMouseGridPosition
public com.badlogic.gdx.math.GridPoint2 getMouseGridPosition(com.badlogic.gdx.math.Vector2 position, boolean alwaysGrid) Retrieves the grid position of the mouse.- Parameters:
position
- the mouse position in world coordinatesalwaysGrid
- specifies whether the mouse position should always be restricted to the grid- Returns:
- the grid position of the mouse as a GridPoint2 object, or null if the mouse position is outside the grid
-
getViewport
public com.badlogic.gdx.utils.viewport.ScreenViewport getViewport() -
move
public void move(float x, float y, float z) Moves the camera in the editor canvas.- Parameters:
x
- the amount to move the camera in the x-axisy
- the amount to move the camera in the y-axisz
- the amount to zoom the camera
-
getMousePosition
public com.badlogic.gdx.math.Vector2 getMousePosition() -
getCameraPosition
public com.badlogic.gdx.math.Vector2 getCameraPosition() -
getTileSize
public float getTileSize() -
getCanvas
-
getWidth
public float getWidth() -
getHeight
public float getHeight() -
getEditor
-
dispose
public void dispose()- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
-