337 lines
13 KiB
ReStructuredText
337 lines
13 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. DO NOT EDIT THIS FILE!!!
|
|
.. Generated automatically from Godot engine sources.
|
|
.. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
|
|
.. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/CanvasLayer.xml.
|
|
|
|
.. _class_CanvasLayer:
|
|
|
|
CanvasLayer
|
|
===========
|
|
|
|
**Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
**Inherited By:** :ref:`ParallaxBackground<class_ParallaxBackground>`
|
|
|
|
Canvas drawing layer.
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
Description
|
|
-----------
|
|
|
|
Canvas drawing layer. :ref:`CanvasItem<class_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).
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
Tutorials
|
|
---------
|
|
|
|
- :doc:`Viewport and canvas transforms <../tutorials/2d/2d_transforms>`
|
|
|
|
- :doc:`Canvas layers <../tutorials/2d/canvas_layers>`
|
|
|
|
- `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
Properties
|
|
----------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
|
|
| :ref:`Node<class_Node>` | :ref:`custom_viewport<class_CanvasLayer_property_custom_viewport>` | |
|
|
+---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`follow_viewport_enable<class_CanvasLayer_property_follow_viewport_enable>` | ``false`` |
|
|
+---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`follow_viewport_scale<class_CanvasLayer_property_follow_viewport_scale>` | ``1.0`` |
|
|
+---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`layer<class_CanvasLayer_property_layer>` | ``1`` |
|
|
+---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`offset<class_CanvasLayer_property_offset>` | ``Vector2( 0, 0 )`` |
|
|
+---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`rotation<class_CanvasLayer_property_rotation>` | ``0.0`` |
|
|
+---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`rotation_degrees<class_CanvasLayer_property_rotation_degrees>` | ``0.0`` |
|
|
+---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`scale<class_CanvasLayer_property_scale>` | ``Vector2( 1, 1 )`` |
|
|
+---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
|
|
| :ref:`Transform2D<class_Transform2D>` | :ref:`transform<class_CanvasLayer_property_transform>` | ``Transform2D( 1, 0, 0, 1, 0, 0 )`` |
|
|
+---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`visible<class_CanvasLayer_property_visible>` | ``true`` |
|
|
+---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
Methods
|
|
-------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------+
|
|
| :ref:`RID<class_RID>` | :ref:`get_canvas<class_CanvasLayer_method_get_canvas>` **(** **)** |const| |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------+
|
|
| :ref:`Transform2D<class_Transform2D>` | :ref:`get_final_transform<class_CanvasLayer_method_get_final_transform>` **(** **)** |const| |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------+
|
|
| void | :ref:`hide<class_CanvasLayer_method_hide>` **(** **)** |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------+
|
|
| void | :ref:`show<class_CanvasLayer_method_show>` **(** **)** |
|
|
+---------------------------------------+----------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Signals
|
|
-------
|
|
|
|
.. _class_CanvasLayer_signal_visibility_changed:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**visibility_changed** **(** **)**
|
|
|
|
Emitted when visibility of the layer is changed. See :ref:`visible<class_CanvasLayer_property_visible>`.
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_CanvasLayer_property_custom_viewport:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Node<class_Node>` **custom_viewport**
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- void **set_custom_viewport** **(** :ref:`Node<class_Node>` value **)**
|
|
- :ref:`Node<class_Node>` **get_custom_viewport** **(** **)**
|
|
|
|
The custom :ref:`Viewport<class_Viewport>` node assigned to the **CanvasLayer**. If ``null``, uses the default viewport instead.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_property_follow_viewport_enable:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **follow_viewport_enable** = ``false``
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- void **set_follow_viewport** **(** :ref:`bool<class_bool>` value **)**
|
|
- :ref:`bool<class_bool>` **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<class_CanvasLayer_property_follow_viewport_scale>` it can be used for a pseudo 3D effect.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_property_follow_viewport_scale:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **follow_viewport_scale** = ``1.0``
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- void **set_follow_viewport_scale** **(** :ref:`float<class_float>` value **)**
|
|
- :ref:`float<class_float>` **get_follow_viewport_scale** **(** **)**
|
|
|
|
Scales the layer when using :ref:`follow_viewport_enable<class_CanvasLayer_property_follow_viewport_enable>`. Layers moving into the foreground should have increasing scales, while layers moving into the background should have decreasing scales.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_property_layer:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`int<class_int>` **layer** = ``1``
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- void **set_layer** **(** :ref:`int<class_int>` value **)**
|
|
- :ref:`int<class_int>` **get_layer** **(** **)**
|
|
|
|
Layer index for draw order. Lower values are drawn behind higher values.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_property_offset:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Vector2<class_Vector2>` **offset** = ``Vector2( 0, 0 )``
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- void **set_offset** **(** :ref:`Vector2<class_Vector2>` value **)**
|
|
- :ref:`Vector2<class_Vector2>` **get_offset** **(** **)**
|
|
|
|
The layer's base offset.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_property_rotation:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **rotation** = ``0.0``
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- void **set_rotation** **(** :ref:`float<class_float>` value **)**
|
|
- :ref:`float<class_float>` **get_rotation** **(** **)**
|
|
|
|
The layer's rotation in radians.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_property_rotation_degrees:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **rotation_degrees** = ``0.0``
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- void **set_rotation_degrees** **(** :ref:`float<class_float>` value **)**
|
|
- :ref:`float<class_float>` **get_rotation_degrees** **(** **)**
|
|
|
|
The layer's rotation in degrees.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_property_scale:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Vector2<class_Vector2>` **scale** = ``Vector2( 1, 1 )``
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- void **set_scale** **(** :ref:`Vector2<class_Vector2>` value **)**
|
|
- :ref:`Vector2<class_Vector2>` **get_scale** **(** **)**
|
|
|
|
The layer's scale.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_property_transform:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **transform** = ``Transform2D( 1, 0, 0, 1, 0, 0 )``
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- void **set_transform** **(** :ref:`Transform2D<class_Transform2D>` value **)**
|
|
- :ref:`Transform2D<class_Transform2D>` **get_transform** **(** **)**
|
|
|
|
The layer's transform.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_property_visible:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **visible** = ``true``
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- void **set_visible** **(** :ref:`bool<class_bool>` value **)**
|
|
- :ref:`bool<class_bool>` **is_visible** **(** **)**
|
|
|
|
If ``false``, any :ref:`CanvasItem<class_CanvasItem>` under this **CanvasLayer** will be hidden.
|
|
|
|
Unlike :ref:`CanvasItem.visible<class_CanvasItem_property_visible>`, visibility of a **CanvasLayer** isn't propagated to underlying layers.
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_CanvasLayer_method_get_canvas:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`RID<class_RID>` **get_canvas** **(** **)** |const|
|
|
|
|
Returns the RID of the canvas used by this layer.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_method_get_final_transform:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Transform2D<class_Transform2D>` **get_final_transform** **(** **)** |const|
|
|
|
|
Returns the transform from the **CanvasLayer**\ s coordinate system to the :ref:`Viewport<class_Viewport>`\ s coordinate system.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_method_hide:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
void **hide** **(** **)**
|
|
|
|
Hides any :ref:`CanvasItem<class_CanvasItem>` under this **CanvasLayer**. This is equivalent to setting :ref:`visible<class_CanvasLayer_property_visible>` to ``false``.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_CanvasLayer_method_show:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
void **show** **(** **)**
|
|
|
|
Shows any :ref:`CanvasItem<class_CanvasItem>` under this **CanvasLayer**. This is equivalent to setting :ref:`visible<class_CanvasLayer_property_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.)`
|
|
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|