class_canvaslayer.rst 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the CanvasLayer.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_CanvasLayer:
  6. CanvasLayer
  7. ===========
  8. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`ParallaxBackground<class_ParallaxBackground>`
  10. Canvas drawing layer.
  11. Description
  12. -----------
  13. 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).
  14. Tutorials
  15. ---------
  16. - :doc:`../tutorials/2d/2d_transforms`
  17. - :doc:`../tutorials/2d/canvas_layers`
  18. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  19. Properties
  20. ----------
  21. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  22. | :ref:`Node<class_Node>` | :ref:`custom_viewport<class_CanvasLayer_property_custom_viewport>` | |
  23. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`follow_viewport_enable<class_CanvasLayer_property_follow_viewport_enable>` | ``false`` |
  25. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  26. | :ref:`float<class_float>` | :ref:`follow_viewport_scale<class_CanvasLayer_property_follow_viewport_scale>` | ``1.0`` |
  27. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  28. | :ref:`int<class_int>` | :ref:`layer<class_CanvasLayer_property_layer>` | ``1`` |
  29. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  30. | :ref:`Vector2<class_Vector2>` | :ref:`offset<class_CanvasLayer_property_offset>` | ``Vector2( 0, 0 )`` |
  31. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  32. | :ref:`float<class_float>` | :ref:`rotation<class_CanvasLayer_property_rotation>` | ``0.0`` |
  33. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  34. | :ref:`float<class_float>` | :ref:`rotation_degrees<class_CanvasLayer_property_rotation_degrees>` | ``0.0`` |
  35. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  36. | :ref:`Vector2<class_Vector2>` | :ref:`scale<class_CanvasLayer_property_scale>` | ``Vector2( 1, 1 )`` |
  37. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  38. | :ref:`Transform2D<class_Transform2D>` | :ref:`transform<class_CanvasLayer_property_transform>` | ``Transform2D( 1, 0, 0, 1, 0, 0 )`` |
  39. +---------------------------------------+----------------------------------------------------------------------------------+-------------------------------------+
  40. Methods
  41. -------
  42. +-----------------------+----------------------------------------------------------------------------+
  43. | :ref:`RID<class_RID>` | :ref:`get_canvas<class_CanvasLayer_method_get_canvas>` **(** **)** |const| |
  44. +-----------------------+----------------------------------------------------------------------------+
  45. Property Descriptions
  46. ---------------------
  47. .. _class_CanvasLayer_property_custom_viewport:
  48. - :ref:`Node<class_Node>` **custom_viewport**
  49. +----------+----------------------------+
  50. | *Setter* | set_custom_viewport(value) |
  51. +----------+----------------------------+
  52. | *Getter* | get_custom_viewport() |
  53. +----------+----------------------------+
  54. The custom :ref:`Viewport<class_Viewport>` node assigned to the ``CanvasLayer``. If ``null``, uses the default viewport instead.
  55. ----
  56. .. _class_CanvasLayer_property_follow_viewport_enable:
  57. - :ref:`bool<class_bool>` **follow_viewport_enable**
  58. +-----------+----------------------------+
  59. | *Default* | ``false`` |
  60. +-----------+----------------------------+
  61. | *Setter* | set_follow_viewport(value) |
  62. +-----------+----------------------------+
  63. | *Getter* | is_following_viewport() |
  64. +-----------+----------------------------+
  65. Sets the layer to follow the viewport in order to simulate a pseudo 3D effect.
  66. ----
  67. .. _class_CanvasLayer_property_follow_viewport_scale:
  68. - :ref:`float<class_float>` **follow_viewport_scale**
  69. +-----------+----------------------------------+
  70. | *Default* | ``1.0`` |
  71. +-----------+----------------------------------+
  72. | *Setter* | set_follow_viewport_scale(value) |
  73. +-----------+----------------------------------+
  74. | *Getter* | get_follow_viewport_scale() |
  75. +-----------+----------------------------------+
  76. 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.
  77. ----
  78. .. _class_CanvasLayer_property_layer:
  79. - :ref:`int<class_int>` **layer**
  80. +-----------+------------------+
  81. | *Default* | ``1`` |
  82. +-----------+------------------+
  83. | *Setter* | set_layer(value) |
  84. +-----------+------------------+
  85. | *Getter* | get_layer() |
  86. +-----------+------------------+
  87. Layer index for draw order. Lower values are drawn first.
  88. ----
  89. .. _class_CanvasLayer_property_offset:
  90. - :ref:`Vector2<class_Vector2>` **offset**
  91. +-----------+---------------------+
  92. | *Default* | ``Vector2( 0, 0 )`` |
  93. +-----------+---------------------+
  94. | *Setter* | set_offset(value) |
  95. +-----------+---------------------+
  96. | *Getter* | get_offset() |
  97. +-----------+---------------------+
  98. The layer's base offset.
  99. ----
  100. .. _class_CanvasLayer_property_rotation:
  101. - :ref:`float<class_float>` **rotation**
  102. +-----------+---------------------+
  103. | *Default* | ``0.0`` |
  104. +-----------+---------------------+
  105. | *Setter* | set_rotation(value) |
  106. +-----------+---------------------+
  107. | *Getter* | get_rotation() |
  108. +-----------+---------------------+
  109. The layer's rotation in radians.
  110. ----
  111. .. _class_CanvasLayer_property_rotation_degrees:
  112. - :ref:`float<class_float>` **rotation_degrees**
  113. +-----------+-----------------------------+
  114. | *Default* | ``0.0`` |
  115. +-----------+-----------------------------+
  116. | *Setter* | set_rotation_degrees(value) |
  117. +-----------+-----------------------------+
  118. | *Getter* | get_rotation_degrees() |
  119. +-----------+-----------------------------+
  120. The layer's rotation in degrees.
  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. Method Descriptions
  144. -------------------
  145. .. _class_CanvasLayer_method_get_canvas:
  146. - :ref:`RID<class_RID>` **get_canvas** **(** **)** |const|
  147. Returns the RID of the canvas used by this layer.
  148. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  149. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  150. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`