:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.5/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/CanvasLayer.xml. .. _class_CanvasLayer: CanvasLayer =========== **Inherits:** :ref:`Node` **<** :ref:`Object` **Inherited By:** :ref:`ParallaxBackground` Canvas drawing layer. Description ----------- Canvas drawing layer. :ref:`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 --------- - :doc:`Viewport and canvas transforms <../tutorials/2d/2d_transforms>` - :doc:`Canvas layers <../tutorials/2d/canvas_layers>` - `2D Dodge The Creeps Demo `__ Properties ---------- +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Node` | :ref:`custom_viewport` | | +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+ | :ref:`bool` | :ref:`follow_viewport_enable` | ``false`` | +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+ | :ref:`float` | :ref:`follow_viewport_scale` | ``1.0`` | +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+ | :ref:`int` | :ref:`layer` | ``1`` | +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Vector2` | :ref:`offset` | ``Vector2( 0, 0 )`` | +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+ | :ref:`float` | :ref:`rotation` | ``0.0`` | +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+ | :ref:`float` | :ref:`rotation_degrees` | ``0.0`` | +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Vector2` | :ref:`scale` | ``Vector2( 1, 1 )`` | +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+ | :ref:`Transform2D` | :ref:`transform` | ``Transform2D( 1, 0, 0, 1, 0, 0 )`` | +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+ | :ref:`bool` | :ref:`visible` | ``true`` | +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+ Methods ------- +-----------------------+----------------------------------------------------------------------------+ | :ref:`RID` | :ref:`get_canvas` **(** **)** |const| | +-----------------------+----------------------------------------------------------------------------+ | void | :ref:`hide` **(** **)** | +-----------------------+----------------------------------------------------------------------------+ | void | :ref:`show` **(** **)** | +-----------------------+----------------------------------------------------------------------------+ Signals ------- .. _class_CanvasLayer_signal_visibility_changed: - **visibility_changed** **(** **)** Emitted when visibility of the layer is changed. See :ref:`visible`. Property Descriptions --------------------- .. _class_CanvasLayer_property_custom_viewport: - :ref:`Node` **custom_viewport** +----------+----------------------------+ | *Setter* | set_custom_viewport(value) | +----------+----------------------------+ | *Getter* | get_custom_viewport() | +----------+----------------------------+ The custom :ref:`Viewport` node assigned to the ``CanvasLayer``. If ``null``, uses the default viewport instead. ---- .. _class_CanvasLayer_property_follow_viewport_enable: - :ref:`bool` **follow_viewport_enable** +-----------+----------------------------+ | *Default* | ``false`` | +-----------+----------------------------+ | *Setter* | set_follow_viewport(value) | +-----------+----------------------------+ | *Getter* | is_following_viewport() | +-----------+----------------------------+ If enabled, the ``CanvasLayer`` will use the viewport's transform, so it will move when camera moves instead of being anchored in a fixed position on the screen. Together with :ref:`follow_viewport_scale` it can be used for a pseudo 3D effect. ---- .. _class_CanvasLayer_property_follow_viewport_scale: - :ref:`float` **follow_viewport_scale** +-----------+----------------------------------+ | *Default* | ``1.0`` | +-----------+----------------------------------+ | *Setter* | set_follow_viewport_scale(value) | +-----------+----------------------------------+ | *Getter* | get_follow_viewport_scale() | +-----------+----------------------------------+ Scales the layer when using :ref:`follow_viewport_enable`. Layers moving into the foreground should have increasing scales, while layers moving into the background should have decreasing scales. ---- .. _class_CanvasLayer_property_layer: - :ref:`int` **layer** +-----------+------------------+ | *Default* | ``1`` | +-----------+------------------+ | *Setter* | set_layer(value) | +-----------+------------------+ | *Getter* | get_layer() | +-----------+------------------+ Layer index for draw order. Lower values are drawn first. ---- .. _class_CanvasLayer_property_offset: - :ref:`Vector2` **offset** +-----------+---------------------+ | *Default* | ``Vector2( 0, 0 )`` | +-----------+---------------------+ | *Setter* | set_offset(value) | +-----------+---------------------+ | *Getter* | get_offset() | +-----------+---------------------+ The layer's base offset. ---- .. _class_CanvasLayer_property_rotation: - :ref:`float` **rotation** +-----------+---------------------+ | *Default* | ``0.0`` | +-----------+---------------------+ | *Setter* | set_rotation(value) | +-----------+---------------------+ | *Getter* | get_rotation() | +-----------+---------------------+ The layer's rotation in radians. ---- .. _class_CanvasLayer_property_rotation_degrees: - :ref:`float` **rotation_degrees** +-----------+-----------------------------+ | *Default* | ``0.0`` | +-----------+-----------------------------+ | *Setter* | set_rotation_degrees(value) | +-----------+-----------------------------+ | *Getter* | get_rotation_degrees() | +-----------+-----------------------------+ The layer's rotation in degrees. ---- .. _class_CanvasLayer_property_scale: - :ref:`Vector2` **scale** +-----------+---------------------+ | *Default* | ``Vector2( 1, 1 )`` | +-----------+---------------------+ | *Setter* | set_scale(value) | +-----------+---------------------+ | *Getter* | get_scale() | +-----------+---------------------+ The layer's scale. ---- .. _class_CanvasLayer_property_transform: - :ref:`Transform2D` **transform** +-----------+-------------------------------------+ | *Default* | ``Transform2D( 1, 0, 0, 1, 0, 0 )`` | +-----------+-------------------------------------+ | *Setter* | set_transform(value) | +-----------+-------------------------------------+ | *Getter* | get_transform() | +-----------+-------------------------------------+ The layer's transform. ---- .. _class_CanvasLayer_property_visible: - :ref:`bool` **visible** +-----------+--------------------+ | *Default* | ``true`` | +-----------+--------------------+ | *Setter* | set_visible(value) | +-----------+--------------------+ | *Getter* | is_visible() | +-----------+--------------------+ If ``false``, any :ref:`CanvasItem` under this ``CanvasLayer`` will be hidden. Unlike :ref:`CanvasItem.visible`, visibility of a ``CanvasLayer`` isn't propagated to underlying layers. Method Descriptions ------------------- .. _class_CanvasLayer_method_get_canvas: - :ref:`RID` **get_canvas** **(** **)** |const| Returns the RID of the canvas used by this layer. ---- .. _class_CanvasLayer_method_hide: - void **hide** **(** **)** Hides any :ref:`CanvasItem` under this ``CanvasLayer``. This is equivalent to setting :ref:`visible` to ``false``. ---- .. _class_CanvasLayer_method_show: - void **show** **(** **)** Shows any :ref:`CanvasItem` under this ``CanvasLayer``. This is equivalent to setting :ref:`visible` to ``true``. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`