Class CameraModule

java.lang.Object
com.codingame.gameengine.module.camera.CameraModule
All Implemented Interfaces:
Module

public class CameraModule extends Object implements Module
The CameraModule allow you to have a dynamic camera following a set of objects
  • Method Details

    • onGameInit

      public void onGameInit()
      Description copied from interface: Module
      Called by the game manager after calling the Referee's init method. The module must be registered to the game manager.
      Specified by:
      onGameInit in interface Module
    • onAfterGameTurn

      public void onAfterGameTurn()
      Description copied from interface: Module
      Called by the game manager after calling the Referee's gameTurn method. The module must be registered to the game manager.
      Specified by:
      onAfterGameTurn in interface Module
    • onAfterOnEnd

      public void onAfterOnEnd()
      Description copied from interface: Module
      Called by the game manager after calling the Referee's onEnd method. The module must be registered to the game manager.
      Specified by:
      onAfterOnEnd in interface Module
    • addTrackedEntity

      public void addTrackedEntity(Entity<?> entity)
      Make the camera include the entity in its field of view
      Parameters:
      entity - the Entity to add to the tracked entities
    • isTracked

      public Boolean isTracked(Entity<?> entity)
      Parameters:
      entity - the Entity that you want to know if it's tracked
      Returns:
      if the entity is tracked by the camera or not
    • removeTrackedEntity

      public void removeTrackedEntity(Entity<?> entity)
      Make the camera stop tracking this entity
      Parameters:
      entity - the Entity 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

      public 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
      Parameters:
      container - the Entity to set as the container
      viewerSizeX - the x size (in pixel) in the viewer of the smallest rectangle that could include your container if the scale is 1
      viewerSizeY - the y size (in pixel) in the viewer of the smallest rectangle that could include your container if the scale is 1