class_camera2d.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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:`set_offset<class_Camera2D_set_offset>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  15. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`Vector2<class_vector2>` | :ref:`get_offset<class_Camera2D_get_offset>` **(** **)** const |
  17. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`set_anchor_mode<class_Camera2D_set_anchor_mode>` **(** :ref:`int<class_int>` anchor_mode **)** |
  19. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`int<class_int>` | :ref:`get_anchor_mode<class_Camera2D_get_anchor_mode>` **(** **)** const |
  21. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`set_rotating<class_Camera2D_set_rotating>` **(** :ref:`bool<class_bool>` rotating **)** |
  23. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`is_rotating<class_Camera2D_is_rotating>` **(** **)** const |
  25. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`make_current<class_Camera2D_make_current>` **(** **)** |
  27. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`clear_current<class_Camera2D_clear_current>` **(** **)** |
  29. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`is_current<class_Camera2D_is_current>` **(** **)** const |
  31. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_limit<class_Camera2D_set_limit>` **(** :ref:`int<class_int>` margin, :ref:`int<class_int>` limit **)** |
  33. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`get_limit<class_Camera2D_get_limit>` **(** :ref:`int<class_int>` margin **)** const |
  35. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`set_v_drag_enabled<class_Camera2D_set_v_drag_enabled>` **(** :ref:`bool<class_bool>` enabled **)** |
  37. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`bool<class_bool>` | :ref:`is_v_drag_enabled<class_Camera2D_is_v_drag_enabled>` **(** **)** const |
  39. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`set_h_drag_enabled<class_Camera2D_set_h_drag_enabled>` **(** :ref:`bool<class_bool>` enabled **)** |
  41. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`is_h_drag_enabled<class_Camera2D_is_h_drag_enabled>` **(** **)** const |
  43. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_v_offset<class_Camera2D_set_v_offset>` **(** :ref:`float<class_float>` ofs **)** |
  45. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`get_v_offset<class_Camera2D_get_v_offset>` **(** **)** const |
  47. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_h_offset<class_Camera2D_set_h_offset>` **(** :ref:`float<class_float>` ofs **)** |
  49. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`float<class_float>` | :ref:`get_h_offset<class_Camera2D_get_h_offset>` **(** **)** const |
  51. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_drag_margin<class_Camera2D_set_drag_margin>` **(** :ref:`int<class_int>` margin, :ref:`float<class_float>` drag_margin **)** |
  53. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`float<class_float>` | :ref:`get_drag_margin<class_Camera2D_get_drag_margin>` **(** :ref:`int<class_int>` margin **)** const |
  55. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`Vector2<class_vector2>` | :ref:`get_camera_pos<class_Camera2D_get_camera_pos>` **(** **)** const |
  57. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Vector2<class_vector2>` | :ref:`get_camera_screen_center<class_Camera2D_get_camera_screen_center>` **(** **)** const |
  59. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`set_zoom<class_Camera2D_set_zoom>` **(** :ref:`Vector2<class_vector2>` zoom **)** |
  61. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Vector2<class_vector2>` | :ref:`get_zoom<class_Camera2D_get_zoom>` **(** **)** const |
  63. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`set_follow_smoothing<class_Camera2D_set_follow_smoothing>` **(** :ref:`float<class_float>` follow_smoothing **)** |
  65. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`float<class_float>` | :ref:`get_follow_smoothing<class_Camera2D_get_follow_smoothing>` **(** **)** const |
  67. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`set_enable_follow_smoothing<class_Camera2D_set_enable_follow_smoothing>` **(** :ref:`bool<class_bool>` follow_smoothing **)** |
  69. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`bool<class_bool>` | :ref:`is_follow_smoothing_enabled<class_Camera2D_is_follow_smoothing_enabled>` **(** **)** const |
  71. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`force_update_scroll<class_Camera2D_force_update_scroll>` **(** **)** |
  73. +--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  74. Numeric Constants
  75. -----------------
  76. - **ANCHOR_MODE_DRAG_CENTER** = **1**
  77. - **ANCHOR_MODE_FIXED_TOP_LEFT** = **0**
  78. Description
  79. -----------
  80. 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.
  81. 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>`.
  82. Member Function Description
  83. ---------------------------
  84. .. _class_Camera2D_set_offset:
  85. - void **set_offset** **(** :ref:`Vector2<class_vector2>` offset **)**
  86. Set the scroll offset. Useful for looking around or camera shake animations.
  87. .. _class_Camera2D_get_offset:
  88. - :ref:`Vector2<class_vector2>` **get_offset** **(** **)** const
  89. Return the scroll offset.
  90. .. _class_Camera2D_set_anchor_mode:
  91. - void **set_anchor_mode** **(** :ref:`int<class_int>` anchor_mode **)**
  92. .. _class_Camera2D_get_anchor_mode:
  93. - :ref:`int<class_int>` **get_anchor_mode** **(** **)** const
  94. .. _class_Camera2D_set_rotating:
  95. - void **set_rotating** **(** :ref:`bool<class_bool>` rotating **)**
  96. .. _class_Camera2D_is_rotating:
  97. - :ref:`bool<class_bool>` **is_rotating** **(** **)** const
  98. .. _class_Camera2D_make_current:
  99. - void **make_current** **(** **)**
  100. Make this the current 2D camera for the scene (viewport and layer), in case there's many cameras in the scene.
  101. .. _class_Camera2D_clear_current:
  102. - void **clear_current** **(** **)**
  103. .. _class_Camera2D_is_current:
  104. - :ref:`bool<class_bool>` **is_current** **(** **)** const
  105. Return true of this is the current camera (see :ref:`make_current<class_Camera2D_make_current>`).
  106. .. _class_Camera2D_set_limit:
  107. - void **set_limit** **(** :ref:`int<class_int>` margin, :ref:`int<class_int>` limit **)**
  108. Set the scrolling limit in pixels.
  109. .. _class_Camera2D_get_limit:
  110. - :ref:`int<class_int>` **get_limit** **(** :ref:`int<class_int>` margin **)** const
  111. Return the scrolling limit in pixels.
  112. .. _class_Camera2D_set_v_drag_enabled:
  113. - void **set_v_drag_enabled** **(** :ref:`bool<class_bool>` enabled **)**
  114. .. _class_Camera2D_is_v_drag_enabled:
  115. - :ref:`bool<class_bool>` **is_v_drag_enabled** **(** **)** const
  116. .. _class_Camera2D_set_h_drag_enabled:
  117. - void **set_h_drag_enabled** **(** :ref:`bool<class_bool>` enabled **)**
  118. .. _class_Camera2D_is_h_drag_enabled:
  119. - :ref:`bool<class_bool>` **is_h_drag_enabled** **(** **)** const
  120. .. _class_Camera2D_set_v_offset:
  121. - void **set_v_offset** **(** :ref:`float<class_float>` ofs **)**
  122. .. _class_Camera2D_get_v_offset:
  123. - :ref:`float<class_float>` **get_v_offset** **(** **)** const
  124. .. _class_Camera2D_set_h_offset:
  125. - void **set_h_offset** **(** :ref:`float<class_float>` ofs **)**
  126. .. _class_Camera2D_get_h_offset:
  127. - :ref:`float<class_float>` **get_h_offset** **(** **)** const
  128. .. _class_Camera2D_set_drag_margin:
  129. - void **set_drag_margin** **(** :ref:`int<class_int>` margin, :ref:`float<class_float>` drag_margin **)**
  130. 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.
  131. .. _class_Camera2D_get_drag_margin:
  132. - :ref:`float<class_float>` **get_drag_margin** **(** :ref:`int<class_int>` margin **)** const
  133. Return the margins needed to drag the camera (see :ref:`set_drag_margin<class_Camera2D_set_drag_margin>`).
  134. .. _class_Camera2D_get_camera_pos:
  135. - :ref:`Vector2<class_vector2>` **get_camera_pos** **(** **)** const
  136. Return the camera position.
  137. .. _class_Camera2D_get_camera_screen_center:
  138. - :ref:`Vector2<class_vector2>` **get_camera_screen_center** **(** **)** const
  139. .. _class_Camera2D_set_zoom:
  140. - void **set_zoom** **(** :ref:`Vector2<class_vector2>` zoom **)**
  141. .. _class_Camera2D_get_zoom:
  142. - :ref:`Vector2<class_vector2>` **get_zoom** **(** **)** const
  143. .. _class_Camera2D_set_follow_smoothing:
  144. - void **set_follow_smoothing** **(** :ref:`float<class_float>` follow_smoothing **)**
  145. .. _class_Camera2D_get_follow_smoothing:
  146. - :ref:`float<class_float>` **get_follow_smoothing** **(** **)** const
  147. .. _class_Camera2D_set_enable_follow_smoothing:
  148. - void **set_enable_follow_smoothing** **(** :ref:`bool<class_bool>` follow_smoothing **)**
  149. .. _class_Camera2D_is_follow_smoothing_enabled:
  150. - :ref:`bool<class_bool>` **is_follow_smoothing_enabled** **(** **)** const
  151. .. _class_Camera2D_force_update_scroll:
  152. - void **force_update_scroll** **(** **)**
  153. Force the camera to update scroll immediately.