Documentation
¶
Overview ¶
Camera node for 2D scenes. 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 graphics.gd/classdb/CanvasItem-based nodes.
Cameras register themselves in the nearest graphics.gd/classdb/Viewport node (when ascending the tree). Only one camera can be active per viewport. If no viewport is available ascending the tree, the camera will register in the global viewport.
This node is intended to be a simple helper to get things going quickly, but more functionality may be desired to change how the camera works. To make your own custom camera node, inherit it from graphics.gd/classdb/Node2D and change the transform of the canvas by setting graphics.gd/classdb/Viewport.Instance.CanvasTransform in graphics.gd/classdb/Viewport (you can obtain the current graphics.gd/classdb/Viewport by using graphics.gd/classdb/Node.Instance.GetViewport).
Note that the graphics.gd/classdb/Camera2D node's graphics.gd/classdb/Node2D.Instance.GlobalPosition doesn't represent the actual position of the screen, which may differ due to applied smoothing or limits. You can use Instance.GetScreenCenterPosition to get the real position. Same for the node's graphics.gd/classdb/Node2D.Instance.GlobalRotation which may be different due to applied rotation smoothing. You can use Instance.GetScreenRotation to get the current rotation of the screen.
Index ¶
- type Advanced
- type AnchorMode
- type Any
- type Camera2DProcessCallback
- type Extension
- type ID
- type Instance
- func (self Instance) Align()
- func (self Instance) AnchorMode() AnchorMode
- func (self Instance) AsCamera2D() Instance
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode2D() Node2D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) CustomViewport() Node.Instance
- func (self Instance) DragBottomMargin() Float.X
- func (self Instance) DragHorizontalEnabled() bool
- func (self Instance) DragHorizontalOffset() Float.X
- func (self Instance) DragLeftMargin() Float.X
- func (self Instance) DragRightMargin() Float.X
- func (self Instance) DragTopMargin() Float.X
- func (self Instance) DragVerticalEnabled() bool
- func (self Instance) DragVerticalOffset() Float.X
- func (self Instance) EditorDrawDragMargin() bool
- func (self Instance) EditorDrawLimits() bool
- func (self Instance) EditorDrawScreen() bool
- func (self Instance) Enabled() bool
- func (self Instance) ForceUpdateScroll()
- func (self Instance) GetScreenCenterPosition() Vector2.XY
- func (self Instance) GetScreenRotation() Float.X
- func (self Instance) GetTargetPosition() Vector2.XY
- func (self Instance) ID() ID
- func (self Instance) IgnoreRotation() bool
- func (self Instance) IsCurrent() bool
- func (self Instance) LimitBottom() int
- func (self Instance) LimitEnabled() bool
- func (self Instance) LimitLeft() int
- func (self Instance) LimitRight() int
- func (self Instance) LimitSmoothed() bool
- func (self Instance) LimitTop() int
- func (self Instance) MakeCurrent()
- func (self Instance) Offset() Vector2.XY
- func (self Instance) PositionSmoothingEnabled() bool
- func (self Instance) PositionSmoothingSpeed() Float.X
- func (self Instance) ProcessCallback() Camera2DProcessCallback
- func (self Instance) ResetSmoothing()
- func (self Instance) RotationSmoothingEnabled() bool
- func (self Instance) RotationSmoothingSpeed() Float.X
- func (self Instance) SetAnchorMode(value AnchorMode)
- func (self Instance) SetCustomViewport(value Node.Instance)
- func (self Instance) SetDragBottomMargin(value Float.X)
- func (self Instance) SetDragHorizontalEnabled(value bool)
- func (self Instance) SetDragHorizontalOffset(value Float.X)
- func (self Instance) SetDragLeftMargin(value Float.X)
- func (self Instance) SetDragRightMargin(value Float.X)
- func (self Instance) SetDragTopMargin(value Float.X)
- func (self Instance) SetDragVerticalEnabled(value bool)
- func (self Instance) SetDragVerticalOffset(value Float.X)
- func (self Instance) SetEditorDrawDragMargin(value bool)
- func (self Instance) SetEditorDrawLimits(value bool)
- func (self Instance) SetEditorDrawScreen(value bool)
- func (self Instance) SetEnabled(value bool)
- func (self Instance) SetIgnoreRotation(value bool)
- func (self Instance) SetLimitBottom(value int)
- func (self Instance) SetLimitEnabled(value bool)
- func (self Instance) SetLimitLeft(value int)
- func (self Instance) SetLimitRight(value int)
- func (self Instance) SetLimitSmoothed(value bool)
- func (self Instance) SetLimitTop(value int)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetOffset(value Vector2.XY)
- func (self Instance) SetPositionSmoothingEnabled(value bool)
- func (self Instance) SetPositionSmoothingSpeed(value Float.X)
- func (self Instance) SetProcessCallback(value Camera2DProcessCallback)
- func (self Instance) SetRotationSmoothingEnabled(value bool)
- func (self Instance) SetRotationSmoothingSpeed(value Float.X)
- func (self Instance) SetZoom(value Vector2.XY)
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) Zoom() Vector2.XY
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type AnchorMode ¶
type AnchorMode int //gd:Camera2D.AnchorMode
const ( // The camera's position is fixed so that the top-left corner is always at the origin. AnchorModeFixedTopLeft AnchorMode = 0 // The camera's position takes into account vertical/horizontal offsets and the screen size. AnchorModeDragCenter AnchorMode = 1 )
type Camera2DProcessCallback ¶
type Camera2DProcessCallback int //gd:Camera2D.Camera2DProcessCallback
const ( // The camera updates during physics frames (see [Node.NotificationInternalPhysicsProcess]). Camera2dProcessPhysics Camera2DProcessCallback = 0 // The camera updates during process frames (see [Node.NotificationInternalProcess]). Camera2dProcessIdle Camera2DProcessCallback = 1 )
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsCamera2D ¶
func (*Extension[T]) AsCanvasItem ¶
func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AnchorMode ¶
func (self Instance) AnchorMode() AnchorMode
func (Instance) AsCamera2D ¶
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) CustomViewport ¶
func (Instance) DragBottomMargin ¶
func (Instance) DragHorizontalEnabled ¶
func (Instance) DragHorizontalOffset ¶
func (Instance) DragLeftMargin ¶
func (Instance) DragRightMargin ¶
func (Instance) DragTopMargin ¶
func (Instance) DragVerticalEnabled ¶
func (Instance) DragVerticalOffset ¶
func (Instance) EditorDrawDragMargin ¶
func (Instance) EditorDrawLimits ¶
func (Instance) EditorDrawScreen ¶
func (Instance) ForceUpdateScroll ¶
func (self Instance) ForceUpdateScroll()
Forces the camera to update scroll immediately.
func (Instance) GetScreenCenterPosition ¶
Returns the center of the screen from this camera's point of view, in global coordinates.
Note: The exact targeted position of the camera may be different. See Instance.GetTargetPosition.
func (Instance) GetScreenRotation ¶
Returns the current screen rotation from this camera's point of view.
Note: The screen rotation can be different from graphics.gd/classdb/Node2D.Instance.GlobalRotation if the camera is rotating smoothly due to Instance.RotationSmoothingEnabled.
func (Instance) GetTargetPosition ¶
Returns this camera's target position, in global coordinates.
Note: The returned value is not the same as graphics.gd/classdb/Node2D.Instance.GlobalPosition, as it is affected by the drag properties. It is also not the same as the current position if Instance.PositionSmoothingEnabled is true (see Instance.GetScreenCenterPosition).
func (Instance) IgnoreRotation ¶
func (Instance) IsCurrent ¶
Returns true if this graphics.gd/classdb/Camera2D is the active camera (see graphics.gd/classdb/Viewport.Instance.GetCamera2d).
func (Instance) LimitBottom ¶
func (Instance) LimitEnabled ¶
func (Instance) LimitRight ¶
func (Instance) LimitSmoothed ¶
func (Instance) MakeCurrent ¶
func (self Instance) MakeCurrent()
Forces this graphics.gd/classdb/Camera2D to become the current active one. Instance.Enabled must be true.
func (Instance) PositionSmoothingEnabled ¶
func (Instance) PositionSmoothingSpeed ¶
func (Instance) ProcessCallback ¶
func (self Instance) ProcessCallback() Camera2DProcessCallback
func (Instance) ResetSmoothing ¶
func (self Instance) ResetSmoothing()
Sets the camera's position immediately to its current smoothing destination.
This method has no effect if Instance.PositionSmoothingEnabled is false.
func (Instance) RotationSmoothingEnabled ¶
func (Instance) RotationSmoothingSpeed ¶
func (Instance) SetAnchorMode ¶
func (self Instance) SetAnchorMode(value AnchorMode)
func (Instance) SetCustomViewport ¶
func (Instance) SetDragBottomMargin ¶
func (Instance) SetDragHorizontalEnabled ¶
func (Instance) SetDragHorizontalOffset ¶
func (Instance) SetDragLeftMargin ¶
func (Instance) SetDragRightMargin ¶
func (Instance) SetDragTopMargin ¶
func (Instance) SetDragVerticalEnabled ¶
func (Instance) SetDragVerticalOffset ¶
func (Instance) SetEditorDrawDragMargin ¶
func (Instance) SetEditorDrawLimits ¶
func (Instance) SetEditorDrawScreen ¶
func (Instance) SetEnabled ¶
func (Instance) SetIgnoreRotation ¶
func (Instance) SetLimitBottom ¶
func (Instance) SetLimitEnabled ¶
func (Instance) SetLimitLeft ¶
func (Instance) SetLimitRight ¶
func (Instance) SetLimitSmoothed ¶
func (Instance) SetLimitTop ¶
func (Instance) SetPositionSmoothingEnabled ¶
func (Instance) SetPositionSmoothingSpeed ¶
func (Instance) SetProcessCallback ¶
func (self Instance) SetProcessCallback(value Camera2DProcessCallback)