class_canvaslayer.rst 11 KB

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