Class Camera
java.lang.Object
de.gurkenlabs.litiengine.graphics.Camera
- All Implemented Interfaces:
ICamera,IUpdateable
- Direct Known Subclasses:
FreeFlightCamera,PositionLockCamera
public class Camera
extends java.lang.Object
implements ICameraNested Class Summary
Nested classes/interfaces inherited from interface de.gurkenlabs.litiengine.graphics.ICamera
ICamera.FocusChangedListener, ICamera.ZoomChangedListenerConstructor Summary
Constructors Constructor Description Camera()Instantiates a newCamerainstance.Method Summary
Modifier and Type Method Description protected java.awt.geom.Point2DclampToMap(java.awt.geom.Point2D focus)AligngetClampAlign()ValigngetClampValign()java.awt.geom.Point2DgetFocus()Gets the map location that is focused by this camera.java.awt.geom.Point2DgetMapLocation(java.awt.geom.Point2D viewPortLocation)Converts a point in screen coordinates into a map location.doublegetPixelOffsetX()Gets the x coordinate of the viewport's origin.doublegetPixelOffsetY()Gets the y coordinate of the viewport's origin.java.awt.geom.Rectangle2DgetViewport()Gets the camera's viewport region, in screen coordinates.java.awt.geom.Point2DgetViewportDimensionCenter(IEntity entity)Gets the center of the entity, in screen coordinates.protected doublegetViewportHeight()java.awt.geom.Point2DgetViewportLocation(double x, double y)Converts a location in map coordinates into screen coordinates.protected doublegetViewportWidth()floatgetZoom()The zoom factor of this camera.booleanisClampToMap()Returns whether this camera will clamp the viewport to the bounds of the map.voidonFocus(ICamera.FocusChangedListener listener)Adds the specified focus changed listener to receive events when the focus of this camera changed.voidonZoom(ICamera.ZoomChangedListener listener)Adds the specified zoom changed listener to receive events when the zoom of this camera changed.voidpan(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.voidpan(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 intpanTime()voidremoveFocusListener(ICamera.FocusChangedListener listener)Removes the specified focus changed listener.voidremoveZoomListener(ICamera.ZoomChangedListener listener)Removes the specified zoom changed listener.voidsetClampAlign(Align align, Valign valign)voidsetClampToMap(boolean clampToMap)Set the camera to clamp the viewport to the bounds of the map.voidsetFocus(double x, double y)Focuses the camera on a given point.voidsetFocus(java.awt.geom.Point2D focus)Focuses the camera on a given point.voidsetZoom(float targetZoom, int delay)Changes the camera's zoom over the specified duration (in frames) to the target zoom.voidshake(double intensity, int delay, int shakeDuration)Shake the camera for the specified duration (in frames).voidupdate()This method is called by the game loop on all objects that are attached to the loop.voidupdateFocus()Currently an update function for the shake effect.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.gurkenlabs.litiengine.graphics.ICamera
getRenderScale, getViewportLocation, getViewportLocation
Constructor Details
Camera
public Camera()Instantiates a newCamerainstance.
Method Details
getFocus
public java.awt.geom.Point2D getFocus()Description copied from interface:ICameraGets the map location that is focused by this camera.getMapLocation
public java.awt.geom.Point2D getMapLocation(java.awt.geom.Point2D viewPortLocation)Description copied from interface:ICameraConverts a point in screen coordinates into a map location.- Specified by:
getMapLocationin interfaceICamera- Parameters:
viewPortLocation- the point in screen coordinates- Returns:
- the map location
getPixelOffsetX
public double getPixelOffsetX()Description copied from interface:ICameraGets the x coordinate of the viewport's origin.- Specified by:
getPixelOffsetXin interfaceICamera- Returns:
- the offset, in screen coordinates
getPixelOffsetY
public double getPixelOffsetY()Description copied from interface:ICameraGets the y coordinate of the viewport's origin.- Specified by:
getPixelOffsetYin interfaceICamera- Returns:
- the offset, in screen coordinates
getViewport
public java.awt.geom.Rectangle2D getViewport()Description copied from interface:ICameraGets the camera's viewport region, in screen coordinates.- Specified by:
getViewportin interfaceICamera- Returns:
- the viewport region, in screen coordinates
getViewportDimensionCenter
Description copied from interface:ICameraGets the center of the entity, in screen coordinates.- Specified by:
getViewportDimensionCenterin interfaceICamera- Parameters:
entity- The entity to retrieve the dimension center for.- Returns:
- the center, in screen coordinates
getViewportLocation
public java.awt.geom.Point2D getViewportLocation(double x, double y)Description copied from interface:ICameraConverts a location in map coordinates into screen coordinates.- Specified by:
getViewportLocationin interfaceICamera- Parameters:
x- The x-coordinate of the viewport location.y- The y-coordinate of the viewport location.- Returns:
- the screen location
getZoom
public float getZoom()Description copied from interface:ICameraThe zoom factor of this camera.onZoom
Description copied from interface:ICameraAdds the specified zoom changed listener to receive events when the zoom of this camera changed.removeZoomListener
Description copied from interface:ICameraRemoves the specified zoom changed listener.- Specified by:
removeZoomListenerin interfaceICamera- Parameters:
listener- The listener to add.
onFocus
Description copied from interface:ICameraAdds the specified focus changed listener to receive events when the focus of this camera changed.removeFocusListener
Description copied from interface:ICameraRemoves the specified focus changed listener.- Specified by:
removeFocusListenerin interfaceICamera- Parameters:
listener- The listener to add.
setFocus
public void setFocus(java.awt.geom.Point2D focus)Description copied from interface:ICameraFocuses the camera on a given point.setFocus
public void setFocus(double x, double y)Description copied from interface:ICameraFocuses the camera on a given point.setZoom
public void setZoom(float targetZoom, int delay)Description copied from interface:ICameraChanges the camera's zoom over the specified duration (in frames) to the target zoom.shake
public void shake(double intensity, int delay, int shakeDuration)Description copied from interface:ICameraShake the camera for the specified duration (in frames). The way the camera shakes is implementation defined.update
public void update()Description copied from interface:IUpdateableThis method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using theClientConfiguration.- Specified by:
updatein interfaceIUpdateable- See Also:
ClientConfiguration.setMaxFps(int)
updateFocus
public void updateFocus()Description copied from interface:ICameraCurrently an update function for the shake effect.- Specified by:
updateFocusin interfaceICamera
isClampToMap
public boolean isClampToMap()Description copied from interface:ICameraReturns whether this camera will clamp the viewport to the bounds of the map.- Specified by:
isClampToMapin interfaceICamera- Returns:
- True if the camera viewport is currently clamped to the map boundaries; otherwise false.
setClampToMap
public void setClampToMap(boolean clampToMap)Description copied from interface:ICameraSet the camera to clamp the viewport to the bounds of the map.- Specified by:
setClampToMapin interfaceICamera- Parameters:
clampToMap- A flag indicating whether the camera viewport should be clamped to the map boundaries.
setClampAlign
- Specified by:
setClampAlignin interfaceICamera
getClampAlign
- Specified by:
getClampAlignin interfaceICamera
getClampValign
- Specified by:
getClampValignin interfaceICamera
pan
public void pan(java.awt.geom.Point2D focus, int duration)Description copied from interface:ICameraPans the camera over the specified duration (in frames) to the target location, after accounting for modifications such as clamping to the map. Event listeners attached to this camera are notified when the pan completes.pan
public void pan(double x, double y, int duration)Description copied from interface:ICameraPans the camera over the specified duration (in frames) to the target location, after accounting for modifications such as clamping to the map. Event listeners attached to this camera are notified when the pan completes.clampToMap
protected java.awt.geom.Point2D clampToMap(java.awt.geom.Point2D focus)panTime
protected int panTime()getViewportWidth
protected double getViewportWidth()getViewportHeight
protected double getViewportHeight()
