public class Camera extends java.lang.Object implements ICamera
ICamera.FocusChangedListener, ICamera.ZoomChangedListener
Constructor and Description |
---|
Camera()
Instantiates a new
Camera instance. |
Modifier and Type | Method and Description |
---|---|
protected java.awt.geom.Point2D |
clampToMap(java.awt.geom.Point2D focus) |
Align |
getClampAlign() |
Valign |
getClampValign() |
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)
Converts a point in screen coordinates into a map location.
|
double |
getPixelOffsetX()
Gets the x coordinate of the viewport's origin.
|
double |
getPixelOffsetY()
Gets the y coordinate of the viewport's origin.
|
java.awt.geom.Rectangle2D |
getViewport()
Gets the camera's viewport region, in screen coordinates.
|
java.awt.geom.Point2D |
getViewportDimensionCenter(IEntity entity)
Gets the center of the entity, in screen coordinates.
|
protected double |
getViewportHeight() |
java.awt.geom.Point2D |
getViewportLocation(double x,
double y)
Converts a location in map coordinates into screen coordinates.
|
protected double |
getViewportWidth() |
float |
getZoom()
The zoom factor of this camera.
|
boolean |
isClampToMap()
Returns whether this camera will clamp the viewport to the bounds of the
map.
|
void |
onFocus(ICamera.FocusChangedListener listener)
Adds the specified focus changed listener to receive events when the focus of this camera changed.
|
void |
onZoom(ICamera.ZoomChangedListener listener)
Adds the specified zoom changed listener to receive events when the zoom of this camera changed.
|
void |
pan(double x,
double y,
int duration)
Pans the camera over the specified duration (in frames) to the target
location, after accounting for modifications such as clamping to the
map.
|
void |
pan(java.awt.geom.Point2D focus,
int duration)
Pans the camera over the specified duration (in frames) to the target
location, after accounting for modifications such as clamping to the
map.
|
protected int |
panTime() |
void |
removeFocusListener(ICamera.FocusChangedListener listener)
Removes the specified focus changed listener.
|
void |
removeZoomListener(ICamera.ZoomChangedListener listener)
Removes the specified zoom changed listener.
|
void |
setClampAlign(Align align,
Valign valign) |
void |
setClampToMap(boolean clampToMap)
Set the camera to clamp the viewport to the bounds of the map.
|
void |
setFocus(double x,
double y)
Focuses the camera on a given point.
|
void |
setFocus(java.awt.geom.Point2D focus)
Focuses the camera on a given point.
|
void |
setZoom(float targetZoom,
int delay)
Changes the camera's zoom over the specified duration (in frames) to the
target zoom.
|
void |
shake(double intensity,
int delay,
int shakeDuration)
Shake the camera for the specified duration (in frames).
|
void |
update()
This method is called by the game loop on all objects that are attached to the loop.
|
void |
updateFocus()
Currently an update function for the shake effect.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getRenderScale, getViewportLocation, getViewportLocation
public java.awt.geom.Point2D getFocus()
ICamera
public java.awt.geom.Point2D getMapLocation(java.awt.geom.Point2D viewPortLocation)
ICamera
getMapLocation
in interface ICamera
viewPortLocation
- the point in screen coordinatespublic double getPixelOffsetX()
ICamera
getPixelOffsetX
in interface ICamera
public double getPixelOffsetY()
ICamera
getPixelOffsetY
in interface ICamera
public java.awt.geom.Rectangle2D getViewport()
ICamera
getViewport
in interface ICamera
public java.awt.geom.Point2D getViewportDimensionCenter(IEntity entity)
ICamera
getViewportDimensionCenter
in interface ICamera
entity
- The entity to retrieve the dimension center for.public java.awt.geom.Point2D getViewportLocation(double x, double y)
ICamera
getViewportLocation
in interface ICamera
x
- The x-coordinate of the viewport location.y
- The y-coordinate of the viewport location.public float getZoom()
ICamera
public void onZoom(ICamera.ZoomChangedListener listener)
ICamera
public void removeZoomListener(ICamera.ZoomChangedListener listener)
ICamera
removeZoomListener
in interface ICamera
listener
- The listener to add.public void onFocus(ICamera.FocusChangedListener listener)
ICamera
public void removeFocusListener(ICamera.FocusChangedListener listener)
ICamera
removeFocusListener
in interface ICamera
listener
- The listener to add.public void setFocus(java.awt.geom.Point2D focus)
ICamera
public void setFocus(double x, double y)
ICamera
public void setZoom(float targetZoom, int delay)
ICamera
public void shake(double intensity, int delay, int shakeDuration)
ICamera
public void update()
IUpdateable
ClientConfiguration
.update
in interface IUpdateable
ClientConfiguration.setMaxFps(int)
public void updateFocus()
ICamera
updateFocus
in interface ICamera
public boolean isClampToMap()
ICamera
isClampToMap
in interface ICamera
public void setClampToMap(boolean clampToMap)
ICamera
setClampToMap
in interface ICamera
clampToMap
- A flag indicating whether the camera viewport should be clamped to the map boundaries.public void setClampAlign(Align align, Valign valign)
setClampAlign
in interface ICamera
public Align getClampAlign()
getClampAlign
in interface ICamera
public Valign getClampValign()
getClampValign
in interface ICamera
public void pan(java.awt.geom.Point2D focus, int duration)
ICamera
public void pan(double x, double y, int duration)
ICamera
protected java.awt.geom.Point2D clampToMap(java.awt.geom.Point2D focus)
protected int panTime()
protected double getViewportWidth()
protected double getViewportHeight()