Package com.csse3200.game.components
Class CameraComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.CameraComponent
Component that manages camera positioning and rendering for an entity.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a camera component with a default orthographic camera.CameraComponent
(com.badlogic.gdx.graphics.Camera camera) Creates a camera component with the specified camera. -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.graphics.Camera
Gets the camera instance.com.badlogic.gdx.math.Matrix4
Gets the projection matrix of the camera.void
resize
(int screenWidth, int screenHeight, float gameWidth) Resizes the camera viewport based on screen dimensions.void
update()
Called once per frame of the game, and should be used for most component logic.Methods inherited from class com.csse3200.game.components.Component
create, dispose, earlyUpdate, getEntity, getPriority, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
CameraComponent
public CameraComponent()Creates a camera component with a default orthographic camera. -
CameraComponent
public CameraComponent(com.badlogic.gdx.graphics.Camera camera) Creates a camera component with the specified camera.- Parameters:
camera
- the camera to use
-
-
Method Details
-
update
public void update()Description copied from class:Component
Called once per frame of the game, and should be used for most component logic. Not called if component is disabled. -
getProjectionMatrix
public com.badlogic.gdx.math.Matrix4 getProjectionMatrix()Gets the projection matrix of the camera.- Returns:
- the combined projection matrix
-
getCamera
public com.badlogic.gdx.graphics.Camera getCamera()Gets the camera instance.- Returns:
- the camera
-
resize
public void resize(int screenWidth, int screenHeight, float gameWidth) Resizes the camera viewport based on screen dimensions.- Parameters:
screenWidth
- the screen widthscreenHeight
- the screen heightgameWidth
- the desired game width
-