CanvasLayer

package
v0.0.0-...-0d6c339 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

graphics.gd/classdb/CanvasItem-derived nodes that are direct or indirect children of a graphics.gd/classdb/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 graphics.gd/classdb/CanvasLayer with index -1 will be drawn below, and a graphics.gd/classdb/CanvasLayer with index 1 will be drawn above. This order will hold regardless of the graphics.gd/classdb/CanvasItem.Instance.ZIndex of the nodes within each layer.

[graphics.gd/classdb/CanvasLayer]s 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 [graphics.gd/classdb/Window]s are placed on layer 1024. [graphics.gd/classdb/CanvasItem]s on layers 1025 and higher appear in front of embedded windows.

Note: Each graphics.gd/classdb/CanvasLayer is drawn on one specific graphics.gd/classdb/Viewport and cannot be shared between multiple [graphics.gd/classdb/Viewport]s, see Instance.CustomViewport. When using multiple [graphics.gd/classdb/Viewport]s, for example in a split-screen game, you need to create an individual graphics.gd/classdb/CanvasLayer for each graphics.gd/classdb/Viewport you want it to be drawn on.

Index

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 Any

type Any interface {
	gd.IsClass
	AsCanvasLayer() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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

func (self *Extension[T]) AsCanvasLayer() Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

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 New

func New() Instance

func (Instance) AsCanvasLayer

func (self Instance) AsCanvasLayer() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) CustomViewport

func (self Instance) CustomViewport() Node.Instance

func (Instance) FollowViewportEnabled

func (self Instance) FollowViewportEnabled() bool

func (Instance) FollowViewportScale

func (self Instance) FollowViewportScale() Float.X

func (Instance) GetCanvas

func (self Instance) GetCanvas() RID.Canvas

Returns the RID of the canvas used by this layer.

func (Instance) GetFinalTransform

func (self Instance) GetFinalTransform() Transform2D.OriginXY

Returns the transform from the [graphics.gd/classdb/CanvasLayer]s coordinate system to the [graphics.gd/classdb/Viewport]s coordinate system.

func (Instance) Hide

func (self Instance) Hide()

Hides any graphics.gd/classdb/CanvasItem under this graphics.gd/classdb/CanvasLayer. This is equivalent to setting Instance.Visible to false.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) Layer

func (self Instance) Layer() int

func (Instance) Offset

func (self Instance) Offset() Vector2.XY

func (Instance) OnVisibilityChanged

func (self Instance) OnVisibilityChanged(cb func(), flags ...Signal.Flags)

func (Instance) Rotation

func (self Instance) Rotation() Angle.Radians

func (Instance) Scale

func (self Instance) Scale() Vector2.XY

func (Instance) SetCustomViewport

func (self Instance) SetCustomViewport(value Node.Instance)

func (Instance) SetFollowViewportEnabled

func (self Instance) SetFollowViewportEnabled(value bool)

func (Instance) SetFollowViewportScale

func (self Instance) SetFollowViewportScale(value Float.X)

func (Instance) SetLayer

func (self Instance) SetLayer(value int)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetOffset

func (self Instance) SetOffset(value Vector2.XY)

func (Instance) SetRotation

func (self Instance) SetRotation(value Angle.Radians)

func (Instance) SetScale

func (self Instance) SetScale(value Vector2.XY)

func (Instance) SetTransform

func (self Instance) SetTransform(value Transform2D.OriginXY)

func (Instance) SetVisible

func (self Instance) SetVisible(value bool)

func (Instance) Show

func (self Instance) Show()

Shows any graphics.gd/classdb/CanvasItem under this graphics.gd/classdb/CanvasLayer. This is equivalent to setting Instance.Visible to true.

func (Instance) Transform

func (self Instance) Transform() Transform2D.OriginXY

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) Visible

func (self Instance) Visible() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL