class_canvaslayer.rst 13 KB

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