Class CameraModule
java.lang.Object
com.codingame.gameengine.module.camera.CameraModule
- All Implemented Interfaces:
Module
The CameraModule allow you to have a dynamic camera following a set of objects
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddTrackedEntity(Entity<?> entity) Make the camera include the entity in its field of viewvoidvoidvoidvoidremoveTrackedEntity(Entity<?> entity) Make the camera stop tracking this entityvoidsetCameraOffset(double value) Sets the camera offset to the given value.voidsetContainer(Entity<?> container, int viewerSizeX, int viewerSizeY) Initialize the camera with container which has to contain all the other entities tracked by the camera
-
Method Details
-
onGameInit
public void onGameInit()- Specified by:
onGameInitin interfaceModule
-
onAfterGameTurn
public void onAfterGameTurn()- Specified by:
onAfterGameTurnin interfaceModule
-
onAfterOnEnd
public void onAfterOnEnd()- Specified by:
onAfterOnEndin interfaceModule
-
addTrackedEntity
Make the camera include the entity in its field of view- Parameters:
entity- theEntityto add to the tracked entities
-
isTracked
- Parameters:
entity- theEntitythat you want to know if it's tracked- Returns:
- if the entity is tracked by the camera or not
-
removeTrackedEntity
Make the camera stop tracking this entity- Parameters:
entity- theEntitythat you don't want to be tracked anymore
-
setCameraOffset
public void setCameraOffset(double value) Sets the camera offset to the given value. It's the length in pixel between the edge of the screen and the closest to border entity- Parameters:
value- the new camera offset, a positive double
-
setContainer
Initialize the camera with container which has to contain all the other entities tracked by the camera- Parameters:
container- theEntityto set as the containerviewerSizeX- the x size (in pixel) in the viewer of the smallest rectangle that could include your container if the scale is 1viewerSizeY- the y size (in pixel) in the viewer of the smallest rectangle that could include your container if the scale is 1
-