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 viewvoidCalled by the game manager after calling theReferee's gameTurn method.voidCalled by the game manager after calling theReferee's onEnd method.voidCalled by the game manager after calling theReferee's init method.voidremoveTrackedEntity(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()Description copied from interface:ModuleCalled by the game manager after calling theReferee's init method. The module must be registered to the game manager.- Specified by:
onGameInitin interfaceModule
-
onAfterGameTurn
public void onAfterGameTurn()Description copied from interface:ModuleCalled by the game manager after calling theReferee's gameTurn method. The module must be registered to the game manager.- Specified by:
onAfterGameTurnin interfaceModule
-
onAfterOnEnd
public void onAfterOnEnd()Description copied from interface:ModuleCalled by the game manager after calling theReferee's onEnd method. The module must be registered to the game manager.- 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
-