public class Camera extends java.lang.Object implements ICamera
| Modifier and Type | Field and Description |
|---|---|
protected java.awt.geom.Point2D |
focus
Provides the center location for the viewport.
|
| Constructor and Description |
|---|
Camera()
Instantiates a new camera.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.awt.geom.Point2D |
clampToMap(java.awt.geom.Point2D focus) |
java.awt.geom.Point2D |
getFocus()
Gets the map location that is focused by this camera.
|
java.awt.geom.Point2D |
getMapLocation(java.awt.geom.Point2D viewPortLocation)
Gets the map location.
|
double |
getPixelOffsetX()
Gets the pixel offset x.
|
double |
getPixelOffsetY()
Gets the pixel offset y.
|
float |
getRenderScale() |
java.awt.geom.Rectangle2D |
getViewPort()
Gets the camera region.
|
java.awt.geom.Point2D |
getViewPortDimensionCenter(IEntity entity) |
java.awt.geom.Point2D |
getViewPortLocation(double x,
double y)
Gets the render location.
|
java.awt.geom.Point2D |
getViewPortLocation(IEntity entity)
This method calculates to location for the specified entity in relation to
the focus map location of the camera.
|
java.awt.geom.Point2D |
getViewPortLocation(java.awt.geom.Point2D mapLocation)
This method calculates to location for the specified point in relation to
the focus map location of the camera.
|
float |
getZoom() |
boolean |
isClampToMap() |
void |
onFocusChanged(java.util.function.Consumer<java.awt.geom.Point2D> focusCons) |
void |
onZoomChanged(java.util.function.Consumer<java.lang.Float> zoomCons) |
void |
setClampToMap(boolean clampToMap) |
void |
setFocus(double x,
double y) |
void |
setFocus(java.awt.geom.Point2D focus) |
void |
setZoom(float targetZoom,
int delay) |
void |
shake(double intensity,
int delay,
int shakeDuration) |
void |
update()
This method is called by the game loop on all objects that need to update
their attributes.
|
void |
updateFocus() |
protected java.awt.geom.Point2D focus
public java.awt.geom.Point2D getFocus()
ICamerapublic java.awt.geom.Point2D getMapLocation(java.awt.geom.Point2D viewPortLocation)
ICameragetMapLocation in interface ICameraviewPortLocation - the pointpublic double getPixelOffsetX()
ICameragetPixelOffsetX in interface ICamerapublic double getPixelOffsetY()
ICameragetPixelOffsetY in interface ICamerapublic java.awt.geom.Rectangle2D getViewPort()
ICameragetViewPort in interface ICamerapublic java.awt.geom.Point2D getViewPortDimensionCenter(IEntity entity)
getViewPortDimensionCenter in interface ICamerapublic java.awt.geom.Point2D getViewPortLocation(double x,
double y)
ICameragetViewPortLocation in interface ICamerax - the xy - the ypublic java.awt.geom.Point2D getViewPortLocation(IEntity entity)
ICameragetViewPortLocation in interface ICameraentity - the entitypublic java.awt.geom.Point2D getViewPortLocation(java.awt.geom.Point2D mapLocation)
ICameragetViewPortLocation in interface ICameramapLocation - the pointpublic float getRenderScale()
getRenderScale in interface ICamerapublic void onZoomChanged(java.util.function.Consumer<java.lang.Float> zoomCons)
onZoomChanged in interface ICamerapublic void onFocusChanged(java.util.function.Consumer<java.awt.geom.Point2D> focusCons)
onFocusChanged in interface ICamerapublic void setFocus(java.awt.geom.Point2D focus)
public void shake(double intensity,
int delay,
int shakeDuration)
public void update()
IUpdateableupdate in interface IUpdateablepublic void updateFocus()
updateFocus in interface ICamerapublic boolean isClampToMap()
isClampToMap in interface ICamerapublic void setClampToMap(boolean clampToMap)
setClampToMap in interface ICameraprotected java.awt.geom.Point2D clampToMap(java.awt.geom.Point2D focus)