CanvasLayer

Inherits: Node < Object Inherited By: ParallaxBackground Canvas drawing layer.

Description

CanvasItem 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 one with index 1 will be drawn above. This is very useful for HUDs (in layer 1+ or above), or backgrounds (in layer -1 or below).

Tutorials

  • Viewport and canvas transforms
  • Canvas layers
  • 2D Dodge The Creeps Demo

    Properties

    Methods

    Signals

  • visibility_changed ( ) visible.

    Property Descriptions

  • Node custom_viewport Viewport node assigned to the CanvasLayer. If null, uses the default viewport instead.

  • bool follow_viewport_enable Sets the layer to follow the viewport in order to simulate a pseudo 3D effect.

  • float follow_viewport_scale follow_viewport_enable. Layers moving into the foreground should have increasing scales, while layers moving into the background should have decreasing scales.

  • int layer Layer index for draw order. Lower values are drawn first.

  • Vector2 offset The layer’s base offset.

  • float rotation The layer’s rotation in radians.

  • float rotation_degrees The layer’s rotation in degrees.

  • Vector2 scale The layer’s scale.

  • Transform2D transform The layer’s transform.

  • bool visible false, any CanvasItem under this CanvasLayer will be hidden. CanvasItem.visible, visibility of a CanvasLayer isn’t propagated to underlying layers.

    Method Descriptions

  • RID get_canvas ( ) const Returns the RID of the canvas used by this layer.

  • hide ( ) CanvasItem under this CanvasLayer. This is equivalent to setting visible to false.

  • show ( ) CanvasItem under this CanvasLayer. This is equivalent to setting visible to true.