class_camera2d.rst 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857
  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/Camera2D.xml.
  6. .. _class_Camera2D:
  7. Camera2D
  8. ========
  9. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Camera node for 2D scenes.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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.
  15. Cameras register themselves in the nearest :ref:`Viewport<class_Viewport>` node (when ascending the tree). Only one camera can be active per viewport. If no viewport is available ascending the tree, the camera will register in the global viewport.
  16. This node is intended to be a simple helper to get things going quickly, but more functionality may be desired to change how the camera works. To make your own custom camera node, inherit it from :ref:`Node2D<class_Node2D>` and change the transform of the canvas by setting :ref:`Viewport.canvas_transform<class_Viewport_property_canvas_transform>` in :ref:`Viewport<class_Viewport>` (you can obtain the current :ref:`Viewport<class_Viewport>` by using :ref:`Node.get_viewport()<class_Node_method_get_viewport>`).
  17. Note that the **Camera2D** node's :ref:`Node2D.global_position<class_Node2D_property_global_position>` doesn't represent the actual position of the screen, which may differ due to applied smoothing or limits. You can use :ref:`get_screen_center_position()<class_Camera2D_method_get_screen_center_position>` to get the real position. Same for the node's :ref:`Node2D.global_rotation<class_Node2D_property_global_rotation>` which may be different due to applied rotation smoothing. You can use :ref:`get_screen_rotation()<class_Camera2D_method_get_screen_rotation>` to get the current rotation of the screen.
  18. .. rst-class:: classref-introduction-group
  19. Tutorials
  20. ---------
  21. - `2D Platformer Demo <https://godotengine.org/asset-library/asset/2727>`__
  22. - `2D Isometric Demo <https://godotengine.org/asset-library/asset/2718>`__
  23. .. rst-class:: classref-reftable-group
  24. Properties
  25. ----------
  26. .. table::
  27. :widths: auto
  28. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  29. | :ref:`AnchorMode<enum_Camera2D_AnchorMode>` | :ref:`anchor_mode<class_Camera2D_property_anchor_mode>` | ``1`` |
  30. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  31. | :ref:`Node<class_Node>` | :ref:`custom_viewport<class_Camera2D_property_custom_viewport>` | |
  32. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  33. | :ref:`float<class_float>` | :ref:`drag_bottom_margin<class_Camera2D_property_drag_bottom_margin>` | ``0.2`` |
  34. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  35. | :ref:`bool<class_bool>` | :ref:`drag_horizontal_enabled<class_Camera2D_property_drag_horizontal_enabled>` | ``false`` |
  36. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  37. | :ref:`float<class_float>` | :ref:`drag_horizontal_offset<class_Camera2D_property_drag_horizontal_offset>` | ``0.0`` |
  38. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  39. | :ref:`float<class_float>` | :ref:`drag_left_margin<class_Camera2D_property_drag_left_margin>` | ``0.2`` |
  40. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  41. | :ref:`float<class_float>` | :ref:`drag_right_margin<class_Camera2D_property_drag_right_margin>` | ``0.2`` |
  42. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  43. | :ref:`float<class_float>` | :ref:`drag_top_margin<class_Camera2D_property_drag_top_margin>` | ``0.2`` |
  44. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  45. | :ref:`bool<class_bool>` | :ref:`drag_vertical_enabled<class_Camera2D_property_drag_vertical_enabled>` | ``false`` |
  46. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  47. | :ref:`float<class_float>` | :ref:`drag_vertical_offset<class_Camera2D_property_drag_vertical_offset>` | ``0.0`` |
  48. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  49. | :ref:`bool<class_bool>` | :ref:`editor_draw_drag_margin<class_Camera2D_property_editor_draw_drag_margin>` | ``false`` |
  50. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  51. | :ref:`bool<class_bool>` | :ref:`editor_draw_limits<class_Camera2D_property_editor_draw_limits>` | ``false`` |
  52. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  53. | :ref:`bool<class_bool>` | :ref:`editor_draw_screen<class_Camera2D_property_editor_draw_screen>` | ``true`` |
  54. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  55. | :ref:`bool<class_bool>` | :ref:`enabled<class_Camera2D_property_enabled>` | ``true`` |
  56. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  57. | :ref:`bool<class_bool>` | :ref:`ignore_rotation<class_Camera2D_property_ignore_rotation>` | ``true`` |
  58. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  59. | :ref:`int<class_int>` | :ref:`limit_bottom<class_Camera2D_property_limit_bottom>` | ``10000000`` |
  60. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  61. | :ref:`bool<class_bool>` | :ref:`limit_enabled<class_Camera2D_property_limit_enabled>` | ``true`` |
  62. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  63. | :ref:`int<class_int>` | :ref:`limit_left<class_Camera2D_property_limit_left>` | ``-10000000`` |
  64. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  65. | :ref:`int<class_int>` | :ref:`limit_right<class_Camera2D_property_limit_right>` | ``10000000`` |
  66. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  67. | :ref:`bool<class_bool>` | :ref:`limit_smoothed<class_Camera2D_property_limit_smoothed>` | ``false`` |
  68. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  69. | :ref:`int<class_int>` | :ref:`limit_top<class_Camera2D_property_limit_top>` | ``-10000000`` |
  70. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  71. | :ref:`Vector2<class_Vector2>` | :ref:`offset<class_Camera2D_property_offset>` | ``Vector2(0, 0)`` |
  72. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  73. | :ref:`bool<class_bool>` | :ref:`position_smoothing_enabled<class_Camera2D_property_position_smoothing_enabled>` | ``false`` |
  74. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  75. | :ref:`float<class_float>` | :ref:`position_smoothing_speed<class_Camera2D_property_position_smoothing_speed>` | ``5.0`` |
  76. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  77. | :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>` | :ref:`process_callback<class_Camera2D_property_process_callback>` | ``1`` |
  78. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  79. | :ref:`bool<class_bool>` | :ref:`rotation_smoothing_enabled<class_Camera2D_property_rotation_smoothing_enabled>` | ``false`` |
  80. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  81. | :ref:`float<class_float>` | :ref:`rotation_smoothing_speed<class_Camera2D_property_rotation_smoothing_speed>` | ``5.0`` |
  82. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  83. | :ref:`Vector2<class_Vector2>` | :ref:`zoom<class_Camera2D_property_zoom>` | ``Vector2(1, 1)`` |
  84. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  85. .. rst-class:: classref-reftable-group
  86. Methods
  87. -------
  88. .. table::
  89. :widths: auto
  90. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | |void| | :ref:`align<class_Camera2D_method_align>`\ (\ ) |
  92. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | |void| | :ref:`force_update_scroll<class_Camera2D_method_force_update_scroll>`\ (\ ) |
  94. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`float<class_float>` | :ref:`get_drag_margin<class_Camera2D_method_get_drag_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
  96. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`int<class_int>` | :ref:`get_limit<class_Camera2D_method_get_limit>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
  98. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`Vector2<class_Vector2>` | :ref:`get_screen_center_position<class_Camera2D_method_get_screen_center_position>`\ (\ ) |const| |
  100. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`float<class_float>` | :ref:`get_screen_rotation<class_Camera2D_method_get_screen_rotation>`\ (\ ) |const| |
  102. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`Vector2<class_Vector2>` | :ref:`get_target_position<class_Camera2D_method_get_target_position>`\ (\ ) |const| |
  104. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`bool<class_bool>` | :ref:`is_current<class_Camera2D_method_is_current>`\ (\ ) |const| |
  106. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | |void| | :ref:`make_current<class_Camera2D_method_make_current>`\ (\ ) |
  108. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | |void| | :ref:`reset_smoothing<class_Camera2D_method_reset_smoothing>`\ (\ ) |
  110. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | |void| | :ref:`set_drag_margin<class_Camera2D_method_set_drag_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, drag_margin\: :ref:`float<class_float>`\ ) |
  112. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | |void| | :ref:`set_limit<class_Camera2D_method_set_limit>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, limit\: :ref:`int<class_int>`\ ) |
  114. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. .. rst-class:: classref-section-separator
  116. ----
  117. .. rst-class:: classref-descriptions-group
  118. Enumerations
  119. ------------
  120. .. _enum_Camera2D_AnchorMode:
  121. .. rst-class:: classref-enumeration
  122. enum **AnchorMode**: :ref:`🔗<enum_Camera2D_AnchorMode>`
  123. .. _class_Camera2D_constant_ANCHOR_MODE_FIXED_TOP_LEFT:
  124. .. rst-class:: classref-enumeration-constant
  125. :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **ANCHOR_MODE_FIXED_TOP_LEFT** = ``0``
  126. The camera's position is fixed so that the top-left corner is always at the origin.
  127. .. _class_Camera2D_constant_ANCHOR_MODE_DRAG_CENTER:
  128. .. rst-class:: classref-enumeration-constant
  129. :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **ANCHOR_MODE_DRAG_CENTER** = ``1``
  130. The camera's position takes into account vertical/horizontal offsets and the screen size.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _enum_Camera2D_Camera2DProcessCallback:
  134. .. rst-class:: classref-enumeration
  135. enum **Camera2DProcessCallback**: :ref:`🔗<enum_Camera2D_Camera2DProcessCallback>`
  136. .. _class_Camera2D_constant_CAMERA2D_PROCESS_PHYSICS:
  137. .. rst-class:: classref-enumeration-constant
  138. :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>` **CAMERA2D_PROCESS_PHYSICS** = ``0``
  139. The camera updates during physics frames (see :ref:`Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS<class_Node_constant_NOTIFICATION_INTERNAL_PHYSICS_PROCESS>`).
  140. .. _class_Camera2D_constant_CAMERA2D_PROCESS_IDLE:
  141. .. rst-class:: classref-enumeration-constant
  142. :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>` **CAMERA2D_PROCESS_IDLE** = ``1``
  143. The camera updates during process frames (see :ref:`Node.NOTIFICATION_INTERNAL_PROCESS<class_Node_constant_NOTIFICATION_INTERNAL_PROCESS>`).
  144. .. rst-class:: classref-section-separator
  145. ----
  146. .. rst-class:: classref-descriptions-group
  147. Property Descriptions
  148. ---------------------
  149. .. _class_Camera2D_property_anchor_mode:
  150. .. rst-class:: classref-property
  151. :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **anchor_mode** = ``1`` :ref:`🔗<class_Camera2D_property_anchor_mode>`
  152. .. rst-class:: classref-property-setget
  153. - |void| **set_anchor_mode**\ (\ value\: :ref:`AnchorMode<enum_Camera2D_AnchorMode>`\ )
  154. - :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **get_anchor_mode**\ (\ )
  155. The Camera2D's anchor point.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_Camera2D_property_custom_viewport:
  159. .. rst-class:: classref-property
  160. :ref:`Node<class_Node>` **custom_viewport** :ref:`🔗<class_Camera2D_property_custom_viewport>`
  161. .. rst-class:: classref-property-setget
  162. - |void| **set_custom_viewport**\ (\ value\: :ref:`Node<class_Node>`\ )
  163. - :ref:`Node<class_Node>` **get_custom_viewport**\ (\ )
  164. The custom :ref:`Viewport<class_Viewport>` node attached to the **Camera2D**. If ``null`` or not a :ref:`Viewport<class_Viewport>`, uses the default viewport instead.
  165. .. rst-class:: classref-item-separator
  166. ----
  167. .. _class_Camera2D_property_drag_bottom_margin:
  168. .. rst-class:: classref-property
  169. :ref:`float<class_float>` **drag_bottom_margin** = ``0.2`` :ref:`🔗<class_Camera2D_property_drag_bottom_margin>`
  170. .. rst-class:: classref-property-setget
  171. - |void| **set_drag_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, drag_margin\: :ref:`float<class_float>`\ )
  172. - :ref:`float<class_float>` **get_drag_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  173. Bottom margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the bottom edge of the screen.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_Camera2D_property_drag_horizontal_enabled:
  177. .. rst-class:: classref-property
  178. :ref:`bool<class_bool>` **drag_horizontal_enabled** = ``false`` :ref:`🔗<class_Camera2D_property_drag_horizontal_enabled>`
  179. .. rst-class:: classref-property-setget
  180. - |void| **set_drag_horizontal_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  181. - :ref:`bool<class_bool>` **is_drag_horizontal_enabled**\ (\ )
  182. If ``true``, the camera only moves when reaching the horizontal (left and right) drag margins. If ``false``, the camera moves horizontally regardless of margins.
  183. .. rst-class:: classref-item-separator
  184. ----
  185. .. _class_Camera2D_property_drag_horizontal_offset:
  186. .. rst-class:: classref-property
  187. :ref:`float<class_float>` **drag_horizontal_offset** = ``0.0`` :ref:`🔗<class_Camera2D_property_drag_horizontal_offset>`
  188. .. rst-class:: classref-property-setget
  189. - |void| **set_drag_horizontal_offset**\ (\ value\: :ref:`float<class_float>`\ )
  190. - :ref:`float<class_float>` **get_drag_horizontal_offset**\ (\ )
  191. The relative horizontal drag offset of the camera between the right (``-1``) and left (``1``) drag margins.
  192. \ **Note:** Used to set the initial horizontal drag offset; determine the current offset; or force the current offset. It's not automatically updated when :ref:`drag_horizontal_enabled<class_Camera2D_property_drag_horizontal_enabled>` is ``true`` or the drag margins are changed.
  193. .. rst-class:: classref-item-separator
  194. ----
  195. .. _class_Camera2D_property_drag_left_margin:
  196. .. rst-class:: classref-property
  197. :ref:`float<class_float>` **drag_left_margin** = ``0.2`` :ref:`🔗<class_Camera2D_property_drag_left_margin>`
  198. .. rst-class:: classref-property-setget
  199. - |void| **set_drag_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, drag_margin\: :ref:`float<class_float>`\ )
  200. - :ref:`float<class_float>` **get_drag_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  201. Left margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the left edge of the screen.
  202. .. rst-class:: classref-item-separator
  203. ----
  204. .. _class_Camera2D_property_drag_right_margin:
  205. .. rst-class:: classref-property
  206. :ref:`float<class_float>` **drag_right_margin** = ``0.2`` :ref:`🔗<class_Camera2D_property_drag_right_margin>`
  207. .. rst-class:: classref-property-setget
  208. - |void| **set_drag_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, drag_margin\: :ref:`float<class_float>`\ )
  209. - :ref:`float<class_float>` **get_drag_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  210. Right margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the right edge of the screen.
  211. .. rst-class:: classref-item-separator
  212. ----
  213. .. _class_Camera2D_property_drag_top_margin:
  214. .. rst-class:: classref-property
  215. :ref:`float<class_float>` **drag_top_margin** = ``0.2`` :ref:`🔗<class_Camera2D_property_drag_top_margin>`
  216. .. rst-class:: classref-property-setget
  217. - |void| **set_drag_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, drag_margin\: :ref:`float<class_float>`\ )
  218. - :ref:`float<class_float>` **get_drag_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  219. Top margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the top edge of the screen.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_Camera2D_property_drag_vertical_enabled:
  223. .. rst-class:: classref-property
  224. :ref:`bool<class_bool>` **drag_vertical_enabled** = ``false`` :ref:`🔗<class_Camera2D_property_drag_vertical_enabled>`
  225. .. rst-class:: classref-property-setget
  226. - |void| **set_drag_vertical_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  227. - :ref:`bool<class_bool>` **is_drag_vertical_enabled**\ (\ )
  228. If ``true``, the camera only moves when reaching the vertical (top and bottom) drag margins. If ``false``, the camera moves vertically regardless of the drag margins.
  229. .. rst-class:: classref-item-separator
  230. ----
  231. .. _class_Camera2D_property_drag_vertical_offset:
  232. .. rst-class:: classref-property
  233. :ref:`float<class_float>` **drag_vertical_offset** = ``0.0`` :ref:`🔗<class_Camera2D_property_drag_vertical_offset>`
  234. .. rst-class:: classref-property-setget
  235. - |void| **set_drag_vertical_offset**\ (\ value\: :ref:`float<class_float>`\ )
  236. - :ref:`float<class_float>` **get_drag_vertical_offset**\ (\ )
  237. The relative vertical drag offset of the camera between the bottom (``-1``) and top (``1``) drag margins.
  238. \ **Note:** Used to set the initial vertical drag offset; determine the current offset; or force the current offset. It's not automatically updated when :ref:`drag_vertical_enabled<class_Camera2D_property_drag_vertical_enabled>` is ``true`` or the drag margins are changed.
  239. .. rst-class:: classref-item-separator
  240. ----
  241. .. _class_Camera2D_property_editor_draw_drag_margin:
  242. .. rst-class:: classref-property
  243. :ref:`bool<class_bool>` **editor_draw_drag_margin** = ``false`` :ref:`🔗<class_Camera2D_property_editor_draw_drag_margin>`
  244. .. rst-class:: classref-property-setget
  245. - |void| **set_margin_drawing_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  246. - :ref:`bool<class_bool>` **is_margin_drawing_enabled**\ (\ )
  247. If ``true``, draws the camera's drag margin rectangle in the editor.
  248. .. rst-class:: classref-item-separator
  249. ----
  250. .. _class_Camera2D_property_editor_draw_limits:
  251. .. rst-class:: classref-property
  252. :ref:`bool<class_bool>` **editor_draw_limits** = ``false`` :ref:`🔗<class_Camera2D_property_editor_draw_limits>`
  253. .. rst-class:: classref-property-setget
  254. - |void| **set_limit_drawing_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  255. - :ref:`bool<class_bool>` **is_limit_drawing_enabled**\ (\ )
  256. If ``true``, draws the camera's limits rectangle in the editor.
  257. .. rst-class:: classref-item-separator
  258. ----
  259. .. _class_Camera2D_property_editor_draw_screen:
  260. .. rst-class:: classref-property
  261. :ref:`bool<class_bool>` **editor_draw_screen** = ``true`` :ref:`🔗<class_Camera2D_property_editor_draw_screen>`
  262. .. rst-class:: classref-property-setget
  263. - |void| **set_screen_drawing_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  264. - :ref:`bool<class_bool>` **is_screen_drawing_enabled**\ (\ )
  265. If ``true``, draws the camera's screen rectangle in the editor.
  266. .. rst-class:: classref-item-separator
  267. ----
  268. .. _class_Camera2D_property_enabled:
  269. .. rst-class:: classref-property
  270. :ref:`bool<class_bool>` **enabled** = ``true`` :ref:`🔗<class_Camera2D_property_enabled>`
  271. .. rst-class:: classref-property-setget
  272. - |void| **set_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  273. - :ref:`bool<class_bool>` **is_enabled**\ (\ )
  274. Controls whether the camera can be active or not. If ``true``, the **Camera2D** will become the main camera when it enters the scene tree and there is no active camera currently (see :ref:`Viewport.get_camera_2d()<class_Viewport_method_get_camera_2d>`).
  275. When the camera is currently active and :ref:`enabled<class_Camera2D_property_enabled>` is set to ``false``, the next enabled **Camera2D** in the scene tree will become active.
  276. .. rst-class:: classref-item-separator
  277. ----
  278. .. _class_Camera2D_property_ignore_rotation:
  279. .. rst-class:: classref-property
  280. :ref:`bool<class_bool>` **ignore_rotation** = ``true`` :ref:`🔗<class_Camera2D_property_ignore_rotation>`
  281. .. rst-class:: classref-property-setget
  282. - |void| **set_ignore_rotation**\ (\ value\: :ref:`bool<class_bool>`\ )
  283. - :ref:`bool<class_bool>` **is_ignoring_rotation**\ (\ )
  284. If ``true``, the camera's rendered view is not affected by its :ref:`Node2D.rotation<class_Node2D_property_rotation>` and :ref:`Node2D.global_rotation<class_Node2D_property_global_rotation>`.
  285. .. rst-class:: classref-item-separator
  286. ----
  287. .. _class_Camera2D_property_limit_bottom:
  288. .. rst-class:: classref-property
  289. :ref:`int<class_int>` **limit_bottom** = ``10000000`` :ref:`🔗<class_Camera2D_property_limit_bottom>`
  290. .. rst-class:: classref-property-setget
  291. - |void| **set_limit**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, limit\: :ref:`int<class_int>`\ )
  292. - :ref:`int<class_int>` **get_limit**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  293. Bottom scroll limit in pixels. The camera stops moving when reaching this value, but :ref:`offset<class_Camera2D_property_offset>` can push the view past the limit.
  294. .. rst-class:: classref-item-separator
  295. ----
  296. .. _class_Camera2D_property_limit_enabled:
  297. .. rst-class:: classref-property
  298. :ref:`bool<class_bool>` **limit_enabled** = ``true`` :ref:`🔗<class_Camera2D_property_limit_enabled>`
  299. .. rst-class:: classref-property-setget
  300. - |void| **set_limit_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  301. - :ref:`bool<class_bool>` **is_limit_enabled**\ (\ )
  302. If ``true``, the limits will be enabled. Disabling this will allow the camera to focus anywhere, when the four ``limit_*`` properties will not work.
  303. .. rst-class:: classref-item-separator
  304. ----
  305. .. _class_Camera2D_property_limit_left:
  306. .. rst-class:: classref-property
  307. :ref:`int<class_int>` **limit_left** = ``-10000000`` :ref:`🔗<class_Camera2D_property_limit_left>`
  308. .. rst-class:: classref-property-setget
  309. - |void| **set_limit**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, limit\: :ref:`int<class_int>`\ )
  310. - :ref:`int<class_int>` **get_limit**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  311. Left scroll limit in pixels. The camera stops moving when reaching this value, but :ref:`offset<class_Camera2D_property_offset>` can push the view past the limit.
  312. .. rst-class:: classref-item-separator
  313. ----
  314. .. _class_Camera2D_property_limit_right:
  315. .. rst-class:: classref-property
  316. :ref:`int<class_int>` **limit_right** = ``10000000`` :ref:`🔗<class_Camera2D_property_limit_right>`
  317. .. rst-class:: classref-property-setget
  318. - |void| **set_limit**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, limit\: :ref:`int<class_int>`\ )
  319. - :ref:`int<class_int>` **get_limit**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  320. Right scroll limit in pixels. The camera stops moving when reaching this value, but :ref:`offset<class_Camera2D_property_offset>` can push the view past the limit.
  321. .. rst-class:: classref-item-separator
  322. ----
  323. .. _class_Camera2D_property_limit_smoothed:
  324. .. rst-class:: classref-property
  325. :ref:`bool<class_bool>` **limit_smoothed** = ``false`` :ref:`🔗<class_Camera2D_property_limit_smoothed>`
  326. .. rst-class:: classref-property-setget
  327. - |void| **set_limit_smoothing_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  328. - :ref:`bool<class_bool>` **is_limit_smoothing_enabled**\ (\ )
  329. If ``true``, the camera smoothly stops when reaches its limits.
  330. This property has no effect if :ref:`position_smoothing_enabled<class_Camera2D_property_position_smoothing_enabled>` is ``false``.
  331. \ **Note:** To immediately update the camera's position to be within limits without smoothing, even with this setting enabled, invoke :ref:`reset_smoothing()<class_Camera2D_method_reset_smoothing>`.
  332. .. rst-class:: classref-item-separator
  333. ----
  334. .. _class_Camera2D_property_limit_top:
  335. .. rst-class:: classref-property
  336. :ref:`int<class_int>` **limit_top** = ``-10000000`` :ref:`🔗<class_Camera2D_property_limit_top>`
  337. .. rst-class:: classref-property-setget
  338. - |void| **set_limit**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, limit\: :ref:`int<class_int>`\ )
  339. - :ref:`int<class_int>` **get_limit**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  340. Top scroll limit in pixels. The camera stops moving when reaching this value, but :ref:`offset<class_Camera2D_property_offset>` can push the view past the limit.
  341. .. rst-class:: classref-item-separator
  342. ----
  343. .. _class_Camera2D_property_offset:
  344. .. rst-class:: classref-property
  345. :ref:`Vector2<class_Vector2>` **offset** = ``Vector2(0, 0)`` :ref:`🔗<class_Camera2D_property_offset>`
  346. .. rst-class:: classref-property-setget
  347. - |void| **set_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  348. - :ref:`Vector2<class_Vector2>` **get_offset**\ (\ )
  349. The camera's relative offset. Useful for looking around or camera shake animations. The offsetted camera can go past the limits defined in :ref:`limit_top<class_Camera2D_property_limit_top>`, :ref:`limit_bottom<class_Camera2D_property_limit_bottom>`, :ref:`limit_left<class_Camera2D_property_limit_left>` and :ref:`limit_right<class_Camera2D_property_limit_right>`.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_Camera2D_property_position_smoothing_enabled:
  353. .. rst-class:: classref-property
  354. :ref:`bool<class_bool>` **position_smoothing_enabled** = ``false`` :ref:`🔗<class_Camera2D_property_position_smoothing_enabled>`
  355. .. rst-class:: classref-property-setget
  356. - |void| **set_position_smoothing_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  357. - :ref:`bool<class_bool>` **is_position_smoothing_enabled**\ (\ )
  358. If ``true``, the camera's view smoothly moves towards its target position at :ref:`position_smoothing_speed<class_Camera2D_property_position_smoothing_speed>`.
  359. .. rst-class:: classref-item-separator
  360. ----
  361. .. _class_Camera2D_property_position_smoothing_speed:
  362. .. rst-class:: classref-property
  363. :ref:`float<class_float>` **position_smoothing_speed** = ``5.0`` :ref:`🔗<class_Camera2D_property_position_smoothing_speed>`
  364. .. rst-class:: classref-property-setget
  365. - |void| **set_position_smoothing_speed**\ (\ value\: :ref:`float<class_float>`\ )
  366. - :ref:`float<class_float>` **get_position_smoothing_speed**\ (\ )
  367. Speed in pixels per second of the camera's smoothing effect when :ref:`position_smoothing_enabled<class_Camera2D_property_position_smoothing_enabled>` is ``true``.
  368. .. rst-class:: classref-item-separator
  369. ----
  370. .. _class_Camera2D_property_process_callback:
  371. .. rst-class:: classref-property
  372. :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>` **process_callback** = ``1`` :ref:`🔗<class_Camera2D_property_process_callback>`
  373. .. rst-class:: classref-property-setget
  374. - |void| **set_process_callback**\ (\ value\: :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>`\ )
  375. - :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>` **get_process_callback**\ (\ )
  376. The camera's process callback.
  377. .. rst-class:: classref-item-separator
  378. ----
  379. .. _class_Camera2D_property_rotation_smoothing_enabled:
  380. .. rst-class:: classref-property
  381. :ref:`bool<class_bool>` **rotation_smoothing_enabled** = ``false`` :ref:`🔗<class_Camera2D_property_rotation_smoothing_enabled>`
  382. .. rst-class:: classref-property-setget
  383. - |void| **set_rotation_smoothing_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  384. - :ref:`bool<class_bool>` **is_rotation_smoothing_enabled**\ (\ )
  385. If ``true``, the camera's view smoothly rotates, via asymptotic smoothing, to align with its target rotation at :ref:`rotation_smoothing_speed<class_Camera2D_property_rotation_smoothing_speed>`.
  386. \ **Note:** This property has no effect if :ref:`ignore_rotation<class_Camera2D_property_ignore_rotation>` is ``true``.
  387. .. rst-class:: classref-item-separator
  388. ----
  389. .. _class_Camera2D_property_rotation_smoothing_speed:
  390. .. rst-class:: classref-property
  391. :ref:`float<class_float>` **rotation_smoothing_speed** = ``5.0`` :ref:`🔗<class_Camera2D_property_rotation_smoothing_speed>`
  392. .. rst-class:: classref-property-setget
  393. - |void| **set_rotation_smoothing_speed**\ (\ value\: :ref:`float<class_float>`\ )
  394. - :ref:`float<class_float>` **get_rotation_smoothing_speed**\ (\ )
  395. The angular, asymptotic speed of the camera's rotation smoothing effect when :ref:`rotation_smoothing_enabled<class_Camera2D_property_rotation_smoothing_enabled>` is ``true``.
  396. .. rst-class:: classref-item-separator
  397. ----
  398. .. _class_Camera2D_property_zoom:
  399. .. rst-class:: classref-property
  400. :ref:`Vector2<class_Vector2>` **zoom** = ``Vector2(1, 1)`` :ref:`🔗<class_Camera2D_property_zoom>`
  401. .. rst-class:: classref-property-setget
  402. - |void| **set_zoom**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  403. - :ref:`Vector2<class_Vector2>` **get_zoom**\ (\ )
  404. The camera's zoom. Higher values are more zoomed in. For example, a zoom of ``Vector2(2.0, 2.0)`` will be twice as zoomed in on each axis (the view covers an area four times smaller). In contrast, a zoom of ``Vector2(0.5, 0.5)`` will be twice as zoomed out on each axis (the view covers an area four times larger). The X and Y components should generally always be set to the same value, unless you wish to stretch the camera view.
  405. \ **Note:** :ref:`FontFile.oversampling<class_FontFile_property_oversampling>` does *not* take **Camera2D** zoom into account. This means that zooming in/out will cause bitmap fonts and rasterized (non-MSDF) dynamic fonts to appear blurry or pixelated unless the font is part of a :ref:`CanvasLayer<class_CanvasLayer>` that makes it ignore camera zoom. To ensure text remains crisp regardless of zoom, you can enable MSDF font rendering by enabling :ref:`ProjectSettings.gui/theme/default_font_multichannel_signed_distance_field<class_ProjectSettings_property_gui/theme/default_font_multichannel_signed_distance_field>` (applies to the default project font only), or enabling **Multichannel Signed Distance Field** in the import options of a DynamicFont for custom fonts. On system fonts, :ref:`SystemFont.multichannel_signed_distance_field<class_SystemFont_property_multichannel_signed_distance_field>` can be enabled in the inspector.
  406. .. rst-class:: classref-section-separator
  407. ----
  408. .. rst-class:: classref-descriptions-group
  409. Method Descriptions
  410. -------------------
  411. .. _class_Camera2D_method_align:
  412. .. rst-class:: classref-method
  413. |void| **align**\ (\ ) :ref:`🔗<class_Camera2D_method_align>`
  414. Aligns the camera to the tracked node.
  415. .. rst-class:: classref-item-separator
  416. ----
  417. .. _class_Camera2D_method_force_update_scroll:
  418. .. rst-class:: classref-method
  419. |void| **force_update_scroll**\ (\ ) :ref:`🔗<class_Camera2D_method_force_update_scroll>`
  420. Forces the camera to update scroll immediately.
  421. .. rst-class:: classref-item-separator
  422. ----
  423. .. _class_Camera2D_method_get_drag_margin:
  424. .. rst-class:: classref-method
  425. :ref:`float<class_float>` **get_drag_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_Camera2D_method_get_drag_margin>`
  426. Returns the specified :ref:`Side<enum_@GlobalScope_Side>`'s margin. See also :ref:`drag_bottom_margin<class_Camera2D_property_drag_bottom_margin>`, :ref:`drag_top_margin<class_Camera2D_property_drag_top_margin>`, :ref:`drag_left_margin<class_Camera2D_property_drag_left_margin>`, and :ref:`drag_right_margin<class_Camera2D_property_drag_right_margin>`.
  427. .. rst-class:: classref-item-separator
  428. ----
  429. .. _class_Camera2D_method_get_limit:
  430. .. rst-class:: classref-method
  431. :ref:`int<class_int>` **get_limit**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_Camera2D_method_get_limit>`
  432. Returns the camera limit for the specified :ref:`Side<enum_@GlobalScope_Side>`. See also :ref:`limit_bottom<class_Camera2D_property_limit_bottom>`, :ref:`limit_top<class_Camera2D_property_limit_top>`, :ref:`limit_left<class_Camera2D_property_limit_left>`, and :ref:`limit_right<class_Camera2D_property_limit_right>`.
  433. .. rst-class:: classref-item-separator
  434. ----
  435. .. _class_Camera2D_method_get_screen_center_position:
  436. .. rst-class:: classref-method
  437. :ref:`Vector2<class_Vector2>` **get_screen_center_position**\ (\ ) |const| :ref:`🔗<class_Camera2D_method_get_screen_center_position>`
  438. Returns the center of the screen from this camera's point of view, in global coordinates.
  439. \ **Note:** The exact targeted position of the camera may be different. See :ref:`get_target_position()<class_Camera2D_method_get_target_position>`.
  440. .. rst-class:: classref-item-separator
  441. ----
  442. .. _class_Camera2D_method_get_screen_rotation:
  443. .. rst-class:: classref-method
  444. :ref:`float<class_float>` **get_screen_rotation**\ (\ ) |const| :ref:`🔗<class_Camera2D_method_get_screen_rotation>`
  445. Returns the current screen rotation from this camera's point of view.
  446. \ **Note:** The screen rotation can be different from :ref:`Node2D.global_rotation<class_Node2D_property_global_rotation>` if the camera is rotating smoothly due to :ref:`rotation_smoothing_enabled<class_Camera2D_property_rotation_smoothing_enabled>`.
  447. .. rst-class:: classref-item-separator
  448. ----
  449. .. _class_Camera2D_method_get_target_position:
  450. .. rst-class:: classref-method
  451. :ref:`Vector2<class_Vector2>` **get_target_position**\ (\ ) |const| :ref:`🔗<class_Camera2D_method_get_target_position>`
  452. Returns this camera's target position, in global coordinates.
  453. \ **Note:** The returned value is not the same as :ref:`Node2D.global_position<class_Node2D_property_global_position>`, as it is affected by the drag properties. It is also not the same as the current position if :ref:`position_smoothing_enabled<class_Camera2D_property_position_smoothing_enabled>` is ``true`` (see :ref:`get_screen_center_position()<class_Camera2D_method_get_screen_center_position>`).
  454. .. rst-class:: classref-item-separator
  455. ----
  456. .. _class_Camera2D_method_is_current:
  457. .. rst-class:: classref-method
  458. :ref:`bool<class_bool>` **is_current**\ (\ ) |const| :ref:`🔗<class_Camera2D_method_is_current>`
  459. Returns ``true`` if this **Camera2D** is the active camera (see :ref:`Viewport.get_camera_2d()<class_Viewport_method_get_camera_2d>`).
  460. .. rst-class:: classref-item-separator
  461. ----
  462. .. _class_Camera2D_method_make_current:
  463. .. rst-class:: classref-method
  464. |void| **make_current**\ (\ ) :ref:`🔗<class_Camera2D_method_make_current>`
  465. Forces this **Camera2D** to become the current active one. :ref:`enabled<class_Camera2D_property_enabled>` must be ``true``.
  466. .. rst-class:: classref-item-separator
  467. ----
  468. .. _class_Camera2D_method_reset_smoothing:
  469. .. rst-class:: classref-method
  470. |void| **reset_smoothing**\ (\ ) :ref:`🔗<class_Camera2D_method_reset_smoothing>`
  471. Sets the camera's position immediately to its current smoothing destination.
  472. This method has no effect if :ref:`position_smoothing_enabled<class_Camera2D_property_position_smoothing_enabled>` is ``false``.
  473. .. rst-class:: classref-item-separator
  474. ----
  475. .. _class_Camera2D_method_set_drag_margin:
  476. .. rst-class:: classref-method
  477. |void| **set_drag_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, drag_margin\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Camera2D_method_set_drag_margin>`
  478. Sets the specified :ref:`Side<enum_@GlobalScope_Side>`'s margin. See also :ref:`drag_bottom_margin<class_Camera2D_property_drag_bottom_margin>`, :ref:`drag_top_margin<class_Camera2D_property_drag_top_margin>`, :ref:`drag_left_margin<class_Camera2D_property_drag_left_margin>`, and :ref:`drag_right_margin<class_Camera2D_property_drag_right_margin>`.
  479. .. rst-class:: classref-item-separator
  480. ----
  481. .. _class_Camera2D_method_set_limit:
  482. .. rst-class:: classref-method
  483. |void| **set_limit**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, limit\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Camera2D_method_set_limit>`
  484. Sets the camera limit for the specified :ref:`Side<enum_@GlobalScope_Side>`. See also :ref:`limit_bottom<class_Camera2D_property_limit_bottom>`, :ref:`limit_top<class_Camera2D_property_limit_top>`, :ref:`limit_left<class_Camera2D_property_limit_left>`, and :ref:`limit_right<class_Camera2D_property_limit_right>`.
  485. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  486. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  487. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  488. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  489. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  490. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  491. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  492. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  493. .. |void| replace:: :abbr:`void (No return value.)`