class_camera2d.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Camera2D:
  4. Camera2D
  5. ========
  6. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Camera node for 2D scenes.
  11. Member Functions
  12. ----------------
  13. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  14. | void | :ref:`align<class_Camera2D_align>` **(** **)** |
  15. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`clear_current<class_Camera2D_clear_current>` **(** **)** |
  17. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`force_update_scroll<class_Camera2D_force_update_scroll>` **(** **)** |
  19. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`int<class_int>` | :ref:`get_anchor_mode<class_Camera2D_get_anchor_mode>` **(** **)** const |
  21. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`Vector2<class_vector2>` | :ref:`get_camera_pos<class_Camera2D_get_camera_pos>` **(** **)** const |
  23. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`Vector2<class_vector2>` | :ref:`get_camera_screen_center<class_Camera2D_get_camera_screen_center>` **(** **)** const |
  25. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Viewport<class_viewport>` | :ref:`get_custom_viewport<class_Camera2D_get_custom_viewport>` **(** **)** const |
  27. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`float<class_float>` | :ref:`get_drag_margin<class_Camera2D_get_drag_margin>` **(** :ref:`int<class_int>` margin **)** const |
  29. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`float<class_float>` | :ref:`get_follow_smoothing<class_Camera2D_get_follow_smoothing>` **(** **)** const |
  31. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`float<class_float>` | :ref:`get_h_offset<class_Camera2D_get_h_offset>` **(** **)** const |
  33. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`get_limit<class_Camera2D_get_limit>` **(** :ref:`int<class_int>` margin **)** const |
  35. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Vector2<class_vector2>` | :ref:`get_offset<class_Camera2D_get_offset>` **(** **)** const |
  37. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`float<class_float>` | :ref:`get_v_offset<class_Camera2D_get_v_offset>` **(** **)** const |
  39. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Vector2<class_vector2>` | :ref:`get_zoom<class_Camera2D_get_zoom>` **(** **)** const |
  41. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`is_current<class_Camera2D_is_current>` **(** **)** const |
  43. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`is_follow_smoothing_enabled<class_Camera2D_is_follow_smoothing_enabled>` **(** **)** const |
  45. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`bool<class_bool>` | :ref:`is_h_drag_enabled<class_Camera2D_is_h_drag_enabled>` **(** **)** const |
  47. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`bool<class_bool>` | :ref:`is_rotating<class_Camera2D_is_rotating>` **(** **)** const |
  49. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`bool<class_bool>` | :ref:`is_v_drag_enabled<class_Camera2D_is_v_drag_enabled>` **(** **)** const |
  51. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`make_current<class_Camera2D_make_current>` **(** **)** |
  53. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`reset_smoothing<class_Camera2D_reset_smoothing>` **(** **)** |
  55. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_anchor_mode<class_Camera2D_set_anchor_mode>` **(** :ref:`int<class_int>` anchor_mode **)** |
  57. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_custom_viewport<class_Camera2D_set_custom_viewport>` **(** :ref:`Viewport<class_viewport>` viewport **)** |
  59. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`set_drag_margin<class_Camera2D_set_drag_margin>` **(** :ref:`int<class_int>` margin, :ref:`float<class_float>` drag_margin **)** |
  61. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`set_enable_follow_smoothing<class_Camera2D_set_enable_follow_smoothing>` **(** :ref:`bool<class_bool>` follow_smoothing **)** |
  63. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`set_follow_smoothing<class_Camera2D_set_follow_smoothing>` **(** :ref:`float<class_float>` follow_smoothing **)** |
  65. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`set_h_drag_enabled<class_Camera2D_set_h_drag_enabled>` **(** :ref:`bool<class_bool>` enabled **)** |
  67. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`set_h_offset<class_Camera2D_set_h_offset>` **(** :ref:`float<class_float>` ofs **)** |
  69. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`set_limit<class_Camera2D_set_limit>` **(** :ref:`int<class_int>` margin, :ref:`int<class_int>` limit **)** |
  71. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`set_offset<class_Camera2D_set_offset>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  73. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`set_rotating<class_Camera2D_set_rotating>` **(** :ref:`bool<class_bool>` rotating **)** |
  75. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`set_v_drag_enabled<class_Camera2D_set_v_drag_enabled>` **(** :ref:`bool<class_bool>` enabled **)** |
  77. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`set_v_offset<class_Camera2D_set_v_offset>` **(** :ref:`float<class_float>` ofs **)** |
  79. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`set_zoom<class_Camera2D_set_zoom>` **(** :ref:`Vector2<class_vector2>` zoom **)** |
  81. +----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  82. Numeric Constants
  83. -----------------
  84. - **ANCHOR_MODE_DRAG_CENTER** = **1**
  85. - **ANCHOR_MODE_FIXED_TOP_LEFT** = **0**
  86. Description
  87. -----------
  88. Camera node for 2D scenes. It forces the screen (current layer) to scroll following this node. This makes it easier (and faster) to program scrollable scenes than manually changing the position of :ref:`CanvasItem<class_canvasitem>` based nodes.
  89. This node is intended to be a simple helper get get things going quickly and it may happen often that more functionality is desired to change how the camera works. To make your own custom camera node, simply inherit from :ref:`Node2D<class_node2d>` and change the transform of the canvas by calling get_viewport().set_canvas_transform(m) in :ref:`Viewport<class_viewport>`.
  90. Member Function Description
  91. ---------------------------
  92. .. _class_Camera2D_align:
  93. - void **align** **(** **)**
  94. Align the camera to the tracked node
  95. .. _class_Camera2D_clear_current:
  96. - void **clear_current** **(** **)**
  97. .. _class_Camera2D_force_update_scroll:
  98. - void **force_update_scroll** **(** **)**
  99. Force the camera to update scroll immediately.
  100. .. _class_Camera2D_get_anchor_mode:
  101. - :ref:`int<class_int>` **get_anchor_mode** **(** **)** const
  102. .. _class_Camera2D_get_camera_pos:
  103. - :ref:`Vector2<class_vector2>` **get_camera_pos** **(** **)** const
  104. Return the camera position.
  105. .. _class_Camera2D_get_camera_screen_center:
  106. - :ref:`Vector2<class_vector2>` **get_camera_screen_center** **(** **)** const
  107. .. _class_Camera2D_get_custom_viewport:
  108. - :ref:`Viewport<class_viewport>` **get_custom_viewport** **(** **)** const
  109. Return the viewport RID for this layer.
  110. .. _class_Camera2D_get_drag_margin:
  111. - :ref:`float<class_float>` **get_drag_margin** **(** :ref:`int<class_int>` margin **)** const
  112. Return the margins needed to drag the camera (see :ref:`set_drag_margin<class_Camera2D_set_drag_margin>`).
  113. .. _class_Camera2D_get_follow_smoothing:
  114. - :ref:`float<class_float>` **get_follow_smoothing** **(** **)** const
  115. .. _class_Camera2D_get_h_offset:
  116. - :ref:`float<class_float>` **get_h_offset** **(** **)** const
  117. .. _class_Camera2D_get_limit:
  118. - :ref:`int<class_int>` **get_limit** **(** :ref:`int<class_int>` margin **)** const
  119. Return the scrolling limit in pixels.
  120. .. _class_Camera2D_get_offset:
  121. - :ref:`Vector2<class_vector2>` **get_offset** **(** **)** const
  122. Return the scroll offset.
  123. .. _class_Camera2D_get_v_offset:
  124. - :ref:`float<class_float>` **get_v_offset** **(** **)** const
  125. .. _class_Camera2D_get_zoom:
  126. - :ref:`Vector2<class_vector2>` **get_zoom** **(** **)** const
  127. .. _class_Camera2D_is_current:
  128. - :ref:`bool<class_bool>` **is_current** **(** **)** const
  129. Return true of this is the current camera (see :ref:`make_current<class_Camera2D_make_current>`).
  130. .. _class_Camera2D_is_follow_smoothing_enabled:
  131. - :ref:`bool<class_bool>` **is_follow_smoothing_enabled** **(** **)** const
  132. .. _class_Camera2D_is_h_drag_enabled:
  133. - :ref:`bool<class_bool>` **is_h_drag_enabled** **(** **)** const
  134. .. _class_Camera2D_is_rotating:
  135. - :ref:`bool<class_bool>` **is_rotating** **(** **)** const
  136. .. _class_Camera2D_is_v_drag_enabled:
  137. - :ref:`bool<class_bool>` **is_v_drag_enabled** **(** **)** const
  138. .. _class_Camera2D_make_current:
  139. - void **make_current** **(** **)**
  140. Make this the current 2D camera for the scene (viewport and layer), in case there's many cameras in the scene.
  141. .. _class_Camera2D_reset_smoothing:
  142. - void **reset_smoothing** **(** **)**
  143. Set the camera's position immediately to its current smoothing destination.
  144. This has no effect if smoothing is disabled.
  145. .. _class_Camera2D_set_anchor_mode:
  146. - void **set_anchor_mode** **(** :ref:`int<class_int>` anchor_mode **)**
  147. .. _class_Camera2D_set_custom_viewport:
  148. - void **set_custom_viewport** **(** :ref:`Viewport<class_viewport>` viewport **)**
  149. .. _class_Camera2D_set_drag_margin:
  150. - void **set_drag_margin** **(** :ref:`int<class_int>` margin, :ref:`float<class_float>` drag_margin **)**
  151. Set the margins needed to drag the camera (relative to the screen size). Margin uses the MARGIN\_\* enum. Drag margins of 0,0,0,0 will keep the camera at the center of the screen, while drag margins of 1,1,1,1 will only move when the camera is at the edges.
  152. .. _class_Camera2D_set_enable_follow_smoothing:
  153. - void **set_enable_follow_smoothing** **(** :ref:`bool<class_bool>` follow_smoothing **)**
  154. .. _class_Camera2D_set_follow_smoothing:
  155. - void **set_follow_smoothing** **(** :ref:`float<class_float>` follow_smoothing **)**
  156. .. _class_Camera2D_set_h_drag_enabled:
  157. - void **set_h_drag_enabled** **(** :ref:`bool<class_bool>` enabled **)**
  158. .. _class_Camera2D_set_h_offset:
  159. - void **set_h_offset** **(** :ref:`float<class_float>` ofs **)**
  160. .. _class_Camera2D_set_limit:
  161. - void **set_limit** **(** :ref:`int<class_int>` margin, :ref:`int<class_int>` limit **)**
  162. Set the scrolling limit in pixels.
  163. .. _class_Camera2D_set_offset:
  164. - void **set_offset** **(** :ref:`Vector2<class_vector2>` offset **)**
  165. Set the scroll offset. Useful for looking around or camera shake animations.
  166. .. _class_Camera2D_set_rotating:
  167. - void **set_rotating** **(** :ref:`bool<class_bool>` rotating **)**
  168. .. _class_Camera2D_set_v_drag_enabled:
  169. - void **set_v_drag_enabled** **(** :ref:`bool<class_bool>` enabled **)**
  170. .. _class_Camera2D_set_v_offset:
  171. - void **set_v_offset** **(** :ref:`float<class_float>` ofs **)**
  172. .. _class_Camera2D_set_zoom:
  173. - void **set_zoom** **(** :ref:`Vector2<class_vector2>` zoom **)**