class_canvaslayer.rst 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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:`Viewport and canvas transforms <../tutorials/2d/2d_transforms>`
  17. - :doc:`Canvas layers <../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:`Vector2<class_Vector2>` | :ref:`scale<class_CanvasLayer_property_scale>` | ``Vector2(1, 1)`` |
  35. +---------------------------------------+----------------------------------------------------------------------------------+-----------------------------------+
  36. | :ref:`Transform2D<class_Transform2D>` | :ref:`transform<class_CanvasLayer_property_transform>` | ``Transform2D(1, 0, 0, 1, 0, 0)`` |
  37. +---------------------------------------+----------------------------------------------------------------------------------+-----------------------------------+
  38. Methods
  39. -------
  40. +-----------------------+----------------------------------------------------------------------------+
  41. | :ref:`RID<class_RID>` | :ref:`get_canvas<class_CanvasLayer_method_get_canvas>` **(** **)** |const| |
  42. +-----------------------+----------------------------------------------------------------------------+
  43. Property Descriptions
  44. ---------------------
  45. .. _class_CanvasLayer_property_custom_viewport:
  46. - :ref:`Node<class_Node>` **custom_viewport**
  47. +----------+----------------------------+
  48. | *Setter* | set_custom_viewport(value) |
  49. +----------+----------------------------+
  50. | *Getter* | get_custom_viewport() |
  51. +----------+----------------------------+
  52. The custom :ref:`Viewport<class_Viewport>` node assigned to the ``CanvasLayer``. If ``null``, uses the default viewport instead.
  53. ----
  54. .. _class_CanvasLayer_property_follow_viewport_enable:
  55. - :ref:`bool<class_bool>` **follow_viewport_enable**
  56. +-----------+----------------------------+
  57. | *Default* | ``false`` |
  58. +-----------+----------------------------+
  59. | *Setter* | set_follow_viewport(value) |
  60. +-----------+----------------------------+
  61. | *Getter* | is_following_viewport() |
  62. +-----------+----------------------------+
  63. Sets the layer to follow the viewport in order to simulate a pseudo 3D effect.
  64. ----
  65. .. _class_CanvasLayer_property_follow_viewport_scale:
  66. - :ref:`float<class_float>` **follow_viewport_scale**
  67. +-----------+----------------------------------+
  68. | *Default* | ``1.0`` |
  69. +-----------+----------------------------------+
  70. | *Setter* | set_follow_viewport_scale(value) |
  71. +-----------+----------------------------------+
  72. | *Getter* | get_follow_viewport_scale() |
  73. +-----------+----------------------------------+
  74. 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.
  75. ----
  76. .. _class_CanvasLayer_property_layer:
  77. - :ref:`int<class_int>` **layer**
  78. +-----------+------------------+
  79. | *Default* | ``1`` |
  80. +-----------+------------------+
  81. | *Setter* | set_layer(value) |
  82. +-----------+------------------+
  83. | *Getter* | get_layer() |
  84. +-----------+------------------+
  85. Layer index for draw order. Lower values are drawn first.
  86. ----
  87. .. _class_CanvasLayer_property_offset:
  88. - :ref:`Vector2<class_Vector2>` **offset**
  89. +-----------+-------------------+
  90. | *Default* | ``Vector2(0, 0)`` |
  91. +-----------+-------------------+
  92. | *Setter* | set_offset(value) |
  93. +-----------+-------------------+
  94. | *Getter* | get_offset() |
  95. +-----------+-------------------+
  96. The layer's base offset.
  97. ----
  98. .. _class_CanvasLayer_property_rotation:
  99. - :ref:`float<class_float>` **rotation**
  100. +-----------+---------------------+
  101. | *Default* | ``0.0`` |
  102. +-----------+---------------------+
  103. | *Setter* | set_rotation(value) |
  104. +-----------+---------------------+
  105. | *Getter* | get_rotation() |
  106. +-----------+---------------------+
  107. The layer's rotation in radians.
  108. ----
  109. .. _class_CanvasLayer_property_scale:
  110. - :ref:`Vector2<class_Vector2>` **scale**
  111. +-----------+-------------------+
  112. | *Default* | ``Vector2(1, 1)`` |
  113. +-----------+-------------------+
  114. | *Setter* | set_scale(value) |
  115. +-----------+-------------------+
  116. | *Getter* | get_scale() |
  117. +-----------+-------------------+
  118. The layer's scale.
  119. ----
  120. .. _class_CanvasLayer_property_transform:
  121. - :ref:`Transform2D<class_Transform2D>` **transform**
  122. +-----------+-----------------------------------+
  123. | *Default* | ``Transform2D(1, 0, 0, 1, 0, 0)`` |
  124. +-----------+-----------------------------------+
  125. | *Setter* | set_transform(value) |
  126. +-----------+-----------------------------------+
  127. | *Getter* | get_transform() |
  128. +-----------+-----------------------------------+
  129. The layer's transform.
  130. Method Descriptions
  131. -------------------
  132. .. _class_CanvasLayer_method_get_canvas:
  133. - :ref:`RID<class_RID>` **get_canvas** **(** **)** |const|
  134. Returns the RID of the canvas used by this layer.
  135. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  136. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  137. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  138. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  139. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  140. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`