Class EditorCanvas

java.lang.Object
de.tum.cit.ase.editor.screens.EditorCanvas
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public class EditorCanvas extends Object implements 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 Details

    • isBigZoom

      public boolean isBigZoom
  • Constructor Details

    • EditorCanvas

      public EditorCanvas(Editor editor)
      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 canvas
      height - 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

      public void loadMap(Map map)
      Loads a Map 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 public boolean processMouseInput(float x, float y, int button)
      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 coordinates
      alwaysGrid - 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-axis
      y - the amount to move the camera in the y-axis
      z - 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

      public Canvas getCanvas()
    • getWidth

      public float getWidth()
    • getHeight

      public float getHeight()
    • getEditor

      public Editor getEditor()
    • dispose

      public void dispose()
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable