Struct Camera2D
Camera node for 2D scenes.
struct Camera2D
;
It forces the screen (current layer) to scroll following this node. This makes it easier (and faster) to program scrollable scenes than manually changing the position of CanvasItem
-based nodes.
This node is intended to be a simple helper to get things going quickly and it may happen that more functionality is desired to change how the camera works. To make your own custom camera node, simply inherit from Node2D
and change the transform of the canvas by calling get_viewport().set_canvas_transform(m) in Viewport
.
Properties
Name | Type | Description |
---|---|---|
anchorMode [get, set]
|
Camera2D | The Camera2D's anchor point. See anchormode constants.
|
current [get, set]
|
bool | If true , the camera is the active camera for the current scene. Only one camera can be current, so setting a different camera current will disable this one.
|
customViewport [get, set]
|
Node | The custom Viewport node attached to the Camera2D . If null or not a Viewport , uses the default viewport instead.
|
dragMarginBottom [get, set]
|
double | Bottom margin needed to drag the camera. A value of 1 makes the camera move only when reaching the edge of the screen.
|
dragMarginHEnabled [get, set]
|
bool | If true , the camera only moves when reaching the horizontal drag margins. If false , the camera moves horizontally regardless of margins.
|
dragMarginLeft [get, set]
|
double | Left margin needed to drag the camera. A value of 1 makes the camera move only when reaching the edge of the screen.
|
dragMarginRight [get, set]
|
double | Right margin needed to drag the camera. A value of 1 makes the camera move only when reaching the edge of the screen.
|
dragMarginTop [get, set]
|
double | Top margin needed to drag the camera. A value of 1 makes the camera move only when reaching the edge of the screen.
|
dragMarginVEnabled [get, set]
|
bool | If true , the camera only moves when reaching the vertical drag margins. If false , the camera moves vertically regardless of margins.
|
editorDrawDragMargin [get, set]
|
bool | If true , draws the camera's drag margin rectangle in the editor.
|
editorDrawLimits [get, set]
|
bool | If true , draws the camera's limits rectangle in the editor.
|
editorDrawScreen [get, set]
|
bool | If true , draws the camera's screen rectangle in the editor.
|
limitBottom [get, set]
|
long | Bottom scroll limit in pixels. The camera stops moving when reaching this value. |
limitLeft [get, set]
|
long | Left scroll limit in pixels. The camera stops moving when reaching this value. |
limitRight [get, set]
|
long | Right scroll limit in pixels. The camera stops moving when reaching this value. |
limitSmoothed [get, set]
|
bool | If true , the camera smoothly stops when reaches its limits.
|
limitTop [get, set]
|
long | Top scroll limit in pixels. The camera stops moving when reaching this value. |
offset [get, set]
|
Vector2 | The camera's offset, useful for looking around or camera shake animations. |
offsetH [get, set]
|
double | The horizontal offset of the camera, relative to the drag margins. Note: Offset H is used only to force offset relative to margins. It's not updated in any way if drag margins are enabled and can be used to set initial offset. |
offsetV [get, set]
|
double | The vertical offset of the camera, relative to the drag margins.
Note: Used the same as offsetH .
|
processMode [get, set]
|
Camera2D | The camera's process callback. See camera2dprocessmode .
|
rotating [get, set]
|
bool | If true , the camera rotates with the target.
|
smoothingEnabled [get, set]
|
bool | If true , the camera smoothly moves towards the target at smoothingSpeed .
|
smoothingSpeed [get, set]
|
double | Speed in pixels per second of the camera's smoothing effect when smoothingEnabled is true .
|
zoom [get, set]
|
Vector2 | The camera's zoom relative to the viewport. Values larger than Vector2(1, 1) zoom out and smaller values zoom in. For an example, use Vector2(0.5, 0.5) for a 2× zoom-in, and Vector2(4, 4) for a 4× zoom-out.
|
Methods
Enums
Name | Description |
---|---|
AnchorMode
|
|
Camera2DProcessMode
|
|
Constants
|