Documentation
¶
Overview ¶
CanvasItem-derived nodes that are direct or indirect children of a CanvasLayer will be drawn in that layer. The layer is a numeric index that defines the draw order. The default 2D scene renders with index 0, so a CanvasLayer with index -1 will be drawn below, and a CanvasLayer with index 1 will be drawn above. This order will hold regardless of the CanvasItem.ZIndex of the nodes within each layer.
CanvasLayers can be hidden and they can also optionally follow the viewport. This makes them useful for HUDs like health bar overlays (on layers 1 and higher) or backgrounds (on layers -1 and lower).
Note: Embedded Windows are placed on layer 1024. CanvasItems on layers 1025 and higher appear in front of embedded windows.
Note: Each CanvasLayer is drawn on one specific Viewport and cannot be shared between multiple Viewports, see CustomViewport. When using multiple Viewports, for example in a split-screen game, you need to create an individual CanvasLayer for each Viewport you want it to be drawn on.
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Instance
- func (self Instance) AsCanvasLayer() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) CustomViewport() Node.Instance
- func (self Instance) FollowViewportEnabled() bool
- func (self Instance) FollowViewportScale() Float.X
- func (self Instance) GetCanvas() RID.Canvas
- func (self Instance) GetFinalTransform() Transform2D.OriginXY
- func (self Instance) Hide()
- func (self Instance) ID() ID
- func (self Instance) Layer() int
- func (self Instance) Offset() Vector2.XY
- func (self Instance) OnVisibilityChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) Rotation() Angle.Radians
- func (self Instance) Scale() Vector2.XY
- func (self Instance) SetCustomViewport(value Node.Instance)
- func (self Instance) SetFollowViewportEnabled(value bool)
- func (self Instance) SetFollowViewportScale(value Float.X)
- func (self Instance) SetLayer(value int)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetOffset(value Vector2.XY)
- func (self Instance) SetRotation(value Angle.Radians)
- func (self Instance) SetScale(value Vector2.XY)
- func (self Instance) SetTransform(value Transform2D.OriginXY)
- func (self Instance) SetVisible(value bool)
- func (self Instance) Show()
- func (self Instance) Transform() Transform2D.OriginXY
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) Visible() bool
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 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]) AsCanvasLayer ¶
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 ¶
type Instance [1]gdclass.CanvasLayer
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) AsCanvasLayer ¶
func (Instance) CustomViewport ¶
The custom Viewport node assigned to the CanvasLayer. If null, uses the default viewport instead.
func (Instance) FollowViewportEnabled ¶
If enabled, the CanvasLayer maintains its position in world space. If disabled, the CanvasLayer stays in a fixed position on the screen.
Together with FollowViewportScale, this can be used for a pseudo-3D effect.
func (Instance) FollowViewportScale ¶
Scales the layer when using FollowViewportEnabled. Layers moving into the foreground should have increasing scales, while layers moving into the background should have decreasing scales.
func (Instance) GetFinalTransform ¶
func (self Instance) GetFinalTransform() Transform2D.OriginXY
Returns the transform from the CanvasLayers coordinate system to the Viewports coordinate system.
func (Instance) Hide ¶
func (self Instance) Hide()
Hides any CanvasItem under this CanvasLayer. This is equivalent to setting Visible to false.
func (Instance) Layer ¶
Layer index for draw order. Lower values are drawn behind higher values.
Note: If multiple CanvasLayers have the same layer index, CanvasItem children of one CanvasLayer are drawn behind the CanvasItem children of the other CanvasLayer. Which CanvasLayer is drawn in front is non-deterministic.
Note: The layer index should be between [Renderingserver.CanvasLayerMin] and [Renderingserver.CanvasLayerMax] (inclusive). Any other value will wrap around.
func (Instance) OnVisibilityChanged ¶
Emitted when visibility of the layer is changed. See Visible.
func (Instance) SetCustomViewport ¶
SetCustomViewport sets the property returned by [GetCustomViewport].
func (Instance) SetFollowViewportEnabled ¶
SetFollowViewportEnabled sets the property returned by [IsFollowingViewport].
func (Instance) SetFollowViewportScale ¶
SetFollowViewportScale sets the property returned by [GetFollowViewportScale].
func (Instance) SetRotation ¶
SetRotation sets the property returned by [GetRotation].
func (Instance) SetTransform ¶
func (self Instance) SetTransform(value Transform2D.OriginXY)
SetTransform sets the property returned by [GetTransform].
func (Instance) SetVisible ¶
SetVisible sets the property returned by [IsVisible].
func (Instance) Show ¶
func (self Instance) Show()
Shows any CanvasItem under this CanvasLayer. This is equivalent to setting Visible to true.
func (Instance) Transform ¶
func (self Instance) Transform() Transform2D.OriginXY
The layer's transform.
func (Instance) Visible ¶
If false, any CanvasItem under this CanvasLayer will be hidden.
Unlike CanvasItem.Visible, visibility of a CanvasLayer isn't propagated to underlying layers.