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 TypeMethodDescriptionvoid
addTrackedEntity
(Entity<?> entity) Make the camera include the entity in its field of viewvoid
Called by the game manager after calling theReferee
's gameTurn method.void
Called by the game manager after calling theReferee
's onEnd method.void
Called by the game manager after calling theReferee
's init method.void
removeTrackedEntity
(Entity<?> entity) Make the camera stop tracking this entityvoid
setCameraOffset
(double value) Sets the camera offset to the given value.void
setContainer
(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:Module
Called by the game manager after calling theReferee
's init method. The module must be registered to the game manager.- Specified by:
onGameInit
in interfaceModule
-
onAfterGameTurn
public void onAfterGameTurn()Description copied from interface:Module
Called by the game manager after calling theReferee
's gameTurn method. The module must be registered to the game manager.- Specified by:
onAfterGameTurn
in interfaceModule
-
onAfterOnEnd
public void onAfterOnEnd()Description copied from interface:Module
Called by the game manager after calling theReferee
's onEnd method. The module must be registered to the game manager.- Specified by:
onAfterOnEnd
in interfaceModule
-
addTrackedEntity
Make the camera include the entity in its field of view- Parameters:
entity
- theEntity
to add to the tracked entities
-
isTracked
- Parameters:
entity
- theEntity
that 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
- theEntity
that 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
- theEntity
to 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
-