Class Camera
java.lang.Object
de.gurkenlabs.litiengine.graphics.Camera
- All Implemented Interfaces:
ICamera,IUpdateable
- Direct Known Subclasses:
FreeFlightCamera,LocationLockCamera
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.gurkenlabs.litiengine.graphics.ICamera
ICamera.FocusChangedListener, ICamera.ZoomChangedListener -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Point2DclampToMap(Point2D focus) getFocus()Gets the map location that is focused by this camera.getMapLocation(Point2D viewPortLocation) Converts a point in screen coordinates into a map location.doubleGets the x coordinate of the viewport's origin.doubleGets the y coordinate of the viewport's origin.Gets the camera's viewport region, in screen coordinates.getViewportDimensionCenter(IEntity entity) Gets the center of the entity, in screen coordinates.protected doublegetViewportLocation(double x, double y) Converts a location in map coordinates into screen coordinates.protected doublefloatgetZoom()The zoom factor of this camera.booleanReturns 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.voidPans the camera over the specified duration (in frames) to the target location, after accounting for modifications such as clamping to the map.protected intpanTime()voidRemoves the specified focus changed listener.voidRemoves 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.voidFocuses 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.voidCurrently 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
-
getMapLocation
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
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
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
-
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
-
setFocus
-
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:
-
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
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
-
panTime
protected int panTime() -
getViewportWidth
protected double getViewportWidth() -
getViewportHeight
protected double getViewportHeight()
-