class_canvaslayer.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/CanvasLayer.xml.
  6. .. _class_CanvasLayer:
  7. CanvasLayer
  8. ===========
  9. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`ParallaxBackground<class_ParallaxBackground>`
  11. Canvas drawing layer.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. 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).
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`Viewport and canvas transforms <../tutorials/2d/2d_transforms>`
  20. - :doc:`Canvas layers <../tutorials/2d/canvas_layers>`
  21. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  22. .. rst-class:: classref-reftable-group
  23. Properties
  24. ----------
  25. .. table::
  26. :widths: auto
  27. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  28. | :ref:`Node<class_Node>` | :ref:`custom_viewport<class_CanvasLayer_property_custom_viewport>` | |
  29. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`follow_viewport_enable<class_CanvasLayer_property_follow_viewport_enable>` | ``false`` |
  31. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  32. | :ref:`float<class_float>` | :ref:`follow_viewport_scale<class_CanvasLayer_property_follow_viewport_scale>` | ``1.0`` |
  33. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`layer<class_CanvasLayer_property_layer>` | ``1`` |
  35. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  36. | :ref:`Vector2<class_Vector2>` | :ref:`offset<class_CanvasLayer_property_offset>` | ``Vector2( 0, 0 )`` |
  37. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  38. | :ref:`float<class_float>` | :ref:`rotation<class_CanvasLayer_property_rotation>` | ``0.0`` |
  39. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  40. | :ref:`float<class_float>` | :ref:`rotation_degrees<class_CanvasLayer_property_rotation_degrees>` | ``0.0`` |
  41. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  42. | :ref:`Vector2<class_Vector2>` | :ref:`scale<class_CanvasLayer_property_scale>` | ``Vector2( 1, 1 )`` |
  43. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  44. | :ref:`Transform2D<class_Transform2D>` | :ref:`transform<class_CanvasLayer_property_transform>` | ``Transform2D( 1, 0, 0, 1, 0, 0 )`` |
  45. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  46. | :ref:`bool<class_bool>` | :ref:`visible<class_CanvasLayer_property_visible>` | ``true`` |
  47. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  48. .. rst-class:: classref-reftable-group
  49. Methods
  50. -------
  51. .. table::
  52. :widths: auto
  53. +---------------------------------------+----------------------------------------------------------------------------------------------+
  54. | :ref:`RID<class_RID>` | :ref:`get_canvas<class_CanvasLayer_method_get_canvas>` **(** **)** |const| |
  55. +---------------------------------------+----------------------------------------------------------------------------------------------+
  56. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_final_transform<class_CanvasLayer_method_get_final_transform>` **(** **)** |const| |
  57. +---------------------------------------+----------------------------------------------------------------------------------------------+
  58. | void | :ref:`hide<class_CanvasLayer_method_hide>` **(** **)** |
  59. +---------------------------------------+----------------------------------------------------------------------------------------------+
  60. | void | :ref:`show<class_CanvasLayer_method_show>` **(** **)** |
  61. +---------------------------------------+----------------------------------------------------------------------------------------------+
  62. .. rst-class:: classref-section-separator
  63. ----
  64. .. rst-class:: classref-descriptions-group
  65. Signals
  66. -------
  67. .. _class_CanvasLayer_signal_visibility_changed:
  68. .. rst-class:: classref-signal
  69. **visibility_changed** **(** **)**
  70. Emitted when visibility of the layer is changed. See :ref:`visible<class_CanvasLayer_property_visible>`.
  71. .. rst-class:: classref-section-separator
  72. ----
  73. .. rst-class:: classref-descriptions-group
  74. Property Descriptions
  75. ---------------------
  76. .. _class_CanvasLayer_property_custom_viewport:
  77. .. rst-class:: classref-property
  78. :ref:`Node<class_Node>` **custom_viewport**
  79. .. rst-class:: classref-property-setget
  80. - void **set_custom_viewport** **(** :ref:`Node<class_Node>` value **)**
  81. - :ref:`Node<class_Node>` **get_custom_viewport** **(** **)**
  82. The custom :ref:`Viewport<class_Viewport>` node assigned to the **CanvasLayer**. If ``null``, uses the default viewport instead.
  83. .. rst-class:: classref-item-separator
  84. ----
  85. .. _class_CanvasLayer_property_follow_viewport_enable:
  86. .. rst-class:: classref-property
  87. :ref:`bool<class_bool>` **follow_viewport_enable** = ``false``
  88. .. rst-class:: classref-property-setget
  89. - void **set_follow_viewport** **(** :ref:`bool<class_bool>` value **)**
  90. - :ref:`bool<class_bool>` **is_following_viewport** **(** **)**
  91. 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.
  92. Together with :ref:`follow_viewport_scale<class_CanvasLayer_property_follow_viewport_scale>` it can be used for a pseudo 3D effect.
  93. .. rst-class:: classref-item-separator
  94. ----
  95. .. _class_CanvasLayer_property_follow_viewport_scale:
  96. .. rst-class:: classref-property
  97. :ref:`float<class_float>` **follow_viewport_scale** = ``1.0``
  98. .. rst-class:: classref-property-setget
  99. - void **set_follow_viewport_scale** **(** :ref:`float<class_float>` value **)**
  100. - :ref:`float<class_float>` **get_follow_viewport_scale** **(** **)**
  101. 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.
  102. .. rst-class:: classref-item-separator
  103. ----
  104. .. _class_CanvasLayer_property_layer:
  105. .. rst-class:: classref-property
  106. :ref:`int<class_int>` **layer** = ``1``
  107. .. rst-class:: classref-property-setget
  108. - void **set_layer** **(** :ref:`int<class_int>` value **)**
  109. - :ref:`int<class_int>` **get_layer** **(** **)**
  110. Layer index for draw order. Lower values are drawn behind higher values.
  111. .. rst-class:: classref-item-separator
  112. ----
  113. .. _class_CanvasLayer_property_offset:
  114. .. rst-class:: classref-property
  115. :ref:`Vector2<class_Vector2>` **offset** = ``Vector2( 0, 0 )``
  116. .. rst-class:: classref-property-setget
  117. - void **set_offset** **(** :ref:`Vector2<class_Vector2>` value **)**
  118. - :ref:`Vector2<class_Vector2>` **get_offset** **(** **)**
  119. The layer's base offset.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_CanvasLayer_property_rotation:
  123. .. rst-class:: classref-property
  124. :ref:`float<class_float>` **rotation** = ``0.0``
  125. .. rst-class:: classref-property-setget
  126. - void **set_rotation** **(** :ref:`float<class_float>` value **)**
  127. - :ref:`float<class_float>` **get_rotation** **(** **)**
  128. The layer's rotation in radians.
  129. .. rst-class:: classref-item-separator
  130. ----
  131. .. _class_CanvasLayer_property_rotation_degrees:
  132. .. rst-class:: classref-property
  133. :ref:`float<class_float>` **rotation_degrees** = ``0.0``
  134. .. rst-class:: classref-property-setget
  135. - void **set_rotation_degrees** **(** :ref:`float<class_float>` value **)**
  136. - :ref:`float<class_float>` **get_rotation_degrees** **(** **)**
  137. The layer's rotation in degrees.
  138. .. rst-class:: classref-item-separator
  139. ----
  140. .. _class_CanvasLayer_property_scale:
  141. .. rst-class:: classref-property
  142. :ref:`Vector2<class_Vector2>` **scale** = ``Vector2( 1, 1 )``
  143. .. rst-class:: classref-property-setget
  144. - void **set_scale** **(** :ref:`Vector2<class_Vector2>` value **)**
  145. - :ref:`Vector2<class_Vector2>` **get_scale** **(** **)**
  146. The layer's scale.
  147. .. rst-class:: classref-item-separator
  148. ----
  149. .. _class_CanvasLayer_property_transform:
  150. .. rst-class:: classref-property
  151. :ref:`Transform2D<class_Transform2D>` **transform** = ``Transform2D( 1, 0, 0, 1, 0, 0 )``
  152. .. rst-class:: classref-property-setget
  153. - void **set_transform** **(** :ref:`Transform2D<class_Transform2D>` value **)**
  154. - :ref:`Transform2D<class_Transform2D>` **get_transform** **(** **)**
  155. The layer's transform.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_CanvasLayer_property_visible:
  159. .. rst-class:: classref-property
  160. :ref:`bool<class_bool>` **visible** = ``true``
  161. .. rst-class:: classref-property-setget
  162. - void **set_visible** **(** :ref:`bool<class_bool>` value **)**
  163. - :ref:`bool<class_bool>` **is_visible** **(** **)**
  164. If ``false``, any :ref:`CanvasItem<class_CanvasItem>` under this **CanvasLayer** will be hidden.
  165. Unlike :ref:`CanvasItem.visible<class_CanvasItem_property_visible>`, visibility of a **CanvasLayer** isn't propagated to underlying layers.
  166. .. rst-class:: classref-section-separator
  167. ----
  168. .. rst-class:: classref-descriptions-group
  169. Method Descriptions
  170. -------------------
  171. .. _class_CanvasLayer_method_get_canvas:
  172. .. rst-class:: classref-method
  173. :ref:`RID<class_RID>` **get_canvas** **(** **)** |const|
  174. Returns the RID of the canvas used by this layer.
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. _class_CanvasLayer_method_get_final_transform:
  178. .. rst-class:: classref-method
  179. :ref:`Transform2D<class_Transform2D>` **get_final_transform** **(** **)** |const|
  180. Returns the transform from the **CanvasLayer**\ s coordinate system to the :ref:`Viewport<class_Viewport>`\ s coordinate system.
  181. .. rst-class:: classref-item-separator
  182. ----
  183. .. _class_CanvasLayer_method_hide:
  184. .. rst-class:: classref-method
  185. void **hide** **(** **)**
  186. Hides any :ref:`CanvasItem<class_CanvasItem>` under this **CanvasLayer**. This is equivalent to setting :ref:`visible<class_CanvasLayer_property_visible>` to ``false``.
  187. .. rst-class:: classref-item-separator
  188. ----
  189. .. _class_CanvasLayer_method_show:
  190. .. rst-class:: classref-method
  191. void **show** **(** **)**
  192. Shows any :ref:`CanvasItem<class_CanvasItem>` under this **CanvasLayer**. This is equivalent to setting :ref:`visible<class_CanvasLayer_property_visible>` to ``true``.
  193. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  194. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  195. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  196. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`