class_camera2d.rst 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  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 ``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.
  18. .. rst-class:: classref-introduction-group
  19. Tutorials
  20. ---------
  21. - `2D Platformer Demo <https://godotengine.org/asset-library/asset/120>`__
  22. - `2D Isometric Demo <https://godotengine.org/asset-library/asset/112>`__
  23. - `2D HDR Demo <https://godotengine.org/asset-library/asset/110>`__
  24. .. rst-class:: classref-reftable-group
  25. Properties
  26. ----------
  27. .. table::
  28. :widths: auto
  29. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  30. | :ref:`AnchorMode<enum_Camera2D_AnchorMode>` | :ref:`anchor_mode<class_Camera2D_property_anchor_mode>` | ``1`` |
  31. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  32. | :ref:`bool<class_bool>` | :ref:`current<class_Camera2D_property_current>` | ``false`` |
  33. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  34. | :ref:`Node<class_Node>` | :ref:`custom_viewport<class_Camera2D_property_custom_viewport>` | |
  35. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  36. | :ref:`float<class_float>` | :ref:`drag_bottom_margin<class_Camera2D_property_drag_bottom_margin>` | ``0.2`` |
  37. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  38. | :ref:`bool<class_bool>` | :ref:`drag_horizontal_enabled<class_Camera2D_property_drag_horizontal_enabled>` | ``false`` |
  39. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  40. | :ref:`float<class_float>` | :ref:`drag_horizontal_offset<class_Camera2D_property_drag_horizontal_offset>` | ``0.0`` |
  41. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  42. | :ref:`float<class_float>` | :ref:`drag_left_margin<class_Camera2D_property_drag_left_margin>` | ``0.2`` |
  43. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  44. | :ref:`float<class_float>` | :ref:`drag_right_margin<class_Camera2D_property_drag_right_margin>` | ``0.2`` |
  45. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  46. | :ref:`float<class_float>` | :ref:`drag_top_margin<class_Camera2D_property_drag_top_margin>` | ``0.2`` |
  47. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  48. | :ref:`bool<class_bool>` | :ref:`drag_vertical_enabled<class_Camera2D_property_drag_vertical_enabled>` | ``false`` |
  49. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  50. | :ref:`float<class_float>` | :ref:`drag_vertical_offset<class_Camera2D_property_drag_vertical_offset>` | ``0.0`` |
  51. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  52. | :ref:`bool<class_bool>` | :ref:`editor_draw_drag_margin<class_Camera2D_property_editor_draw_drag_margin>` | ``false`` |
  53. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  54. | :ref:`bool<class_bool>` | :ref:`editor_draw_limits<class_Camera2D_property_editor_draw_limits>` | ``false`` |
  55. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  56. | :ref:`bool<class_bool>` | :ref:`editor_draw_screen<class_Camera2D_property_editor_draw_screen>` | ``true`` |
  57. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  58. | :ref:`bool<class_bool>` | :ref:`ignore_rotation<class_Camera2D_property_ignore_rotation>` | ``true`` |
  59. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  60. | :ref:`int<class_int>` | :ref:`limit_bottom<class_Camera2D_property_limit_bottom>` | ``10000000`` |
  61. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  62. | :ref:`int<class_int>` | :ref:`limit_left<class_Camera2D_property_limit_left>` | ``-10000000`` |
  63. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  64. | :ref:`int<class_int>` | :ref:`limit_right<class_Camera2D_property_limit_right>` | ``10000000`` |
  65. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  66. | :ref:`bool<class_bool>` | :ref:`limit_smoothed<class_Camera2D_property_limit_smoothed>` | ``false`` |
  67. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  68. | :ref:`int<class_int>` | :ref:`limit_top<class_Camera2D_property_limit_top>` | ``-10000000`` |
  69. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  70. | :ref:`Vector2<class_Vector2>` | :ref:`offset<class_Camera2D_property_offset>` | ``Vector2(0, 0)`` |
  71. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  72. | :ref:`bool<class_bool>` | :ref:`position_smoothing_enabled<class_Camera2D_property_position_smoothing_enabled>` | ``false`` |
  73. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  74. | :ref:`float<class_float>` | :ref:`position_smoothing_speed<class_Camera2D_property_position_smoothing_speed>` | ``5.0`` |
  75. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  76. | :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>` | :ref:`process_callback<class_Camera2D_property_process_callback>` | ``1`` |
  77. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  78. | :ref:`bool<class_bool>` | :ref:`rotation_smoothing_enabled<class_Camera2D_property_rotation_smoothing_enabled>` | ``false`` |
  79. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  80. | :ref:`float<class_float>` | :ref:`rotation_smoothing_speed<class_Camera2D_property_rotation_smoothing_speed>` | ``5.0`` |
  81. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  82. | :ref:`Vector2<class_Vector2>` | :ref:`zoom<class_Camera2D_property_zoom>` | ``Vector2(1, 1)`` |
  83. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  84. .. rst-class:: classref-reftable-group
  85. Methods
  86. -------
  87. .. table::
  88. :widths: auto
  89. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | void | :ref:`align<class_Camera2D_method_align>` **(** **)** |
  91. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | void | :ref:`force_update_scroll<class_Camera2D_method_force_update_scroll>` **(** **)** |
  93. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`float<class_float>` | :ref:`get_drag_margin<class_Camera2D_method_get_drag_margin>` **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const| |
  95. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`int<class_int>` | :ref:`get_limit<class_Camera2D_method_get_limit>` **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const| |
  97. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`Vector2<class_Vector2>` | :ref:`get_screen_center_position<class_Camera2D_method_get_screen_center_position>` **(** **)** |const| |
  99. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`Vector2<class_Vector2>` | :ref:`get_target_position<class_Camera2D_method_get_target_position>` **(** **)** |const| |
  101. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | void | :ref:`reset_smoothing<class_Camera2D_method_reset_smoothing>` **(** **)** |
  103. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | void | :ref:`set_drag_margin<class_Camera2D_method_set_drag_margin>` **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`float<class_float>` drag_margin **)** |
  105. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | void | :ref:`set_limit<class_Camera2D_method_set_limit>` **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`int<class_int>` limit **)** |
  107. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. .. rst-class:: classref-section-separator
  109. ----
  110. .. rst-class:: classref-descriptions-group
  111. Enumerations
  112. ------------
  113. .. _enum_Camera2D_AnchorMode:
  114. .. rst-class:: classref-enumeration
  115. enum **AnchorMode**:
  116. .. _class_Camera2D_constant_ANCHOR_MODE_FIXED_TOP_LEFT:
  117. .. rst-class:: classref-enumeration-constant
  118. :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **ANCHOR_MODE_FIXED_TOP_LEFT** = ``0``
  119. The camera's position is fixed so that the top-left corner is always at the origin.
  120. .. _class_Camera2D_constant_ANCHOR_MODE_DRAG_CENTER:
  121. .. rst-class:: classref-enumeration-constant
  122. :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **ANCHOR_MODE_DRAG_CENTER** = ``1``
  123. The camera's position takes into account vertical/horizontal offsets and the screen size.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _enum_Camera2D_Camera2DProcessCallback:
  127. .. rst-class:: classref-enumeration
  128. enum **Camera2DProcessCallback**:
  129. .. _class_Camera2D_constant_CAMERA2D_PROCESS_PHYSICS:
  130. .. rst-class:: classref-enumeration-constant
  131. :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>` **CAMERA2D_PROCESS_PHYSICS** = ``0``
  132. The camera updates with the ``_physics_process`` callback.
  133. .. _class_Camera2D_constant_CAMERA2D_PROCESS_IDLE:
  134. .. rst-class:: classref-enumeration-constant
  135. :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>` **CAMERA2D_PROCESS_IDLE** = ``1``
  136. The camera updates with the ``_process`` callback.
  137. .. rst-class:: classref-section-separator
  138. ----
  139. .. rst-class:: classref-descriptions-group
  140. Property Descriptions
  141. ---------------------
  142. .. _class_Camera2D_property_anchor_mode:
  143. .. rst-class:: classref-property
  144. :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **anchor_mode** = ``1``
  145. .. rst-class:: classref-property-setget
  146. - void **set_anchor_mode** **(** :ref:`AnchorMode<enum_Camera2D_AnchorMode>` value **)**
  147. - :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **get_anchor_mode** **(** **)**
  148. The Camera2D's anchor point. See :ref:`AnchorMode<enum_Camera2D_AnchorMode>` constants.
  149. .. rst-class:: classref-item-separator
  150. ----
  151. .. _class_Camera2D_property_current:
  152. .. rst-class:: classref-property
  153. :ref:`bool<class_bool>` **current** = ``false``
  154. .. rst-class:: classref-property-setget
  155. - void **set_current** **(** :ref:`bool<class_bool>` value **)**
  156. - :ref:`bool<class_bool>` **is_current** **(** **)**
  157. If ``true``, the camera acts as the active camera for its :ref:`Viewport<class_Viewport>` ancestor. Only one camera can be current in a given viewport, so setting a different camera in the same viewport ``current`` will disable whatever camera was already active in that viewport.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_Camera2D_property_custom_viewport:
  161. .. rst-class:: classref-property
  162. :ref:`Node<class_Node>` **custom_viewport**
  163. .. rst-class:: classref-property-setget
  164. - void **set_custom_viewport** **(** :ref:`Node<class_Node>` value **)**
  165. - :ref:`Node<class_Node>` **get_custom_viewport** **(** **)**
  166. 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.
  167. .. rst-class:: classref-item-separator
  168. ----
  169. .. _class_Camera2D_property_drag_bottom_margin:
  170. .. rst-class:: classref-property
  171. :ref:`float<class_float>` **drag_bottom_margin** = ``0.2``
  172. .. rst-class:: classref-property-setget
  173. - void **set_drag_margin** **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`float<class_float>` drag_margin **)**
  174. - :ref:`float<class_float>` **get_drag_margin** **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const|
  175. Bottom margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the bottom edge of the screen.
  176. .. rst-class:: classref-item-separator
  177. ----
  178. .. _class_Camera2D_property_drag_horizontal_enabled:
  179. .. rst-class:: classref-property
  180. :ref:`bool<class_bool>` **drag_horizontal_enabled** = ``false``
  181. .. rst-class:: classref-property-setget
  182. - void **set_drag_horizontal_enabled** **(** :ref:`bool<class_bool>` value **)**
  183. - :ref:`bool<class_bool>` **is_drag_horizontal_enabled** **(** **)**
  184. If ``true``, the camera only moves when reaching the horizontal (left and right) drag margins. If ``false``, the camera moves horizontally regardless of margins.
  185. .. rst-class:: classref-item-separator
  186. ----
  187. .. _class_Camera2D_property_drag_horizontal_offset:
  188. .. rst-class:: classref-property
  189. :ref:`float<class_float>` **drag_horizontal_offset** = ``0.0``
  190. .. rst-class:: classref-property-setget
  191. - void **set_drag_horizontal_offset** **(** :ref:`float<class_float>` value **)**
  192. - :ref:`float<class_float>` **get_drag_horizontal_offset** **(** **)**
  193. The relative horizontal drag offset of the camera between the right (``-1``) and left (``1``) drag margins.
  194. \ **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.
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _class_Camera2D_property_drag_left_margin:
  198. .. rst-class:: classref-property
  199. :ref:`float<class_float>` **drag_left_margin** = ``0.2``
  200. .. rst-class:: classref-property-setget
  201. - void **set_drag_margin** **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`float<class_float>` drag_margin **)**
  202. - :ref:`float<class_float>` **get_drag_margin** **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const|
  203. Left margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the left edge of the screen.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_Camera2D_property_drag_right_margin:
  207. .. rst-class:: classref-property
  208. :ref:`float<class_float>` **drag_right_margin** = ``0.2``
  209. .. rst-class:: classref-property-setget
  210. - void **set_drag_margin** **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`float<class_float>` drag_margin **)**
  211. - :ref:`float<class_float>` **get_drag_margin** **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const|
  212. Right margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the right edge of the screen.
  213. .. rst-class:: classref-item-separator
  214. ----
  215. .. _class_Camera2D_property_drag_top_margin:
  216. .. rst-class:: classref-property
  217. :ref:`float<class_float>` **drag_top_margin** = ``0.2``
  218. .. rst-class:: classref-property-setget
  219. - void **set_drag_margin** **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`float<class_float>` drag_margin **)**
  220. - :ref:`float<class_float>` **get_drag_margin** **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const|
  221. Top margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the top edge of the screen.
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _class_Camera2D_property_drag_vertical_enabled:
  225. .. rst-class:: classref-property
  226. :ref:`bool<class_bool>` **drag_vertical_enabled** = ``false``
  227. .. rst-class:: classref-property-setget
  228. - void **set_drag_vertical_enabled** **(** :ref:`bool<class_bool>` value **)**
  229. - :ref:`bool<class_bool>` **is_drag_vertical_enabled** **(** **)**
  230. 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.
  231. .. rst-class:: classref-item-separator
  232. ----
  233. .. _class_Camera2D_property_drag_vertical_offset:
  234. .. rst-class:: classref-property
  235. :ref:`float<class_float>` **drag_vertical_offset** = ``0.0``
  236. .. rst-class:: classref-property-setget
  237. - void **set_drag_vertical_offset** **(** :ref:`float<class_float>` value **)**
  238. - :ref:`float<class_float>` **get_drag_vertical_offset** **(** **)**
  239. The relative vertical drag offset of the camera between the bottom (``-1``) and top (``1``) drag margins.
  240. \ **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.
  241. .. rst-class:: classref-item-separator
  242. ----
  243. .. _class_Camera2D_property_editor_draw_drag_margin:
  244. .. rst-class:: classref-property
  245. :ref:`bool<class_bool>` **editor_draw_drag_margin** = ``false``
  246. .. rst-class:: classref-property-setget
  247. - void **set_margin_drawing_enabled** **(** :ref:`bool<class_bool>` value **)**
  248. - :ref:`bool<class_bool>` **is_margin_drawing_enabled** **(** **)**
  249. If ``true``, draws the camera's drag margin rectangle in the editor.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_Camera2D_property_editor_draw_limits:
  253. .. rst-class:: classref-property
  254. :ref:`bool<class_bool>` **editor_draw_limits** = ``false``
  255. .. rst-class:: classref-property-setget
  256. - void **set_limit_drawing_enabled** **(** :ref:`bool<class_bool>` value **)**
  257. - :ref:`bool<class_bool>` **is_limit_drawing_enabled** **(** **)**
  258. If ``true``, draws the camera's limits rectangle in the editor.
  259. .. rst-class:: classref-item-separator
  260. ----
  261. .. _class_Camera2D_property_editor_draw_screen:
  262. .. rst-class:: classref-property
  263. :ref:`bool<class_bool>` **editor_draw_screen** = ``true``
  264. .. rst-class:: classref-property-setget
  265. - void **set_screen_drawing_enabled** **(** :ref:`bool<class_bool>` value **)**
  266. - :ref:`bool<class_bool>` **is_screen_drawing_enabled** **(** **)**
  267. If ``true``, draws the camera's screen rectangle in the editor.
  268. .. rst-class:: classref-item-separator
  269. ----
  270. .. _class_Camera2D_property_ignore_rotation:
  271. .. rst-class:: classref-property
  272. :ref:`bool<class_bool>` **ignore_rotation** = ``true``
  273. .. rst-class:: classref-property-setget
  274. - void **set_ignore_rotation** **(** :ref:`bool<class_bool>` value **)**
  275. - :ref:`bool<class_bool>` **is_ignoring_rotation** **(** **)**
  276. 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>`.
  277. .. rst-class:: classref-item-separator
  278. ----
  279. .. _class_Camera2D_property_limit_bottom:
  280. .. rst-class:: classref-property
  281. :ref:`int<class_int>` **limit_bottom** = ``10000000``
  282. .. rst-class:: classref-property-setget
  283. - void **set_limit** **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`int<class_int>` limit **)**
  284. - :ref:`int<class_int>` **get_limit** **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const|
  285. 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.
  286. .. rst-class:: classref-item-separator
  287. ----
  288. .. _class_Camera2D_property_limit_left:
  289. .. rst-class:: classref-property
  290. :ref:`int<class_int>` **limit_left** = ``-10000000``
  291. .. rst-class:: classref-property-setget
  292. - void **set_limit** **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`int<class_int>` limit **)**
  293. - :ref:`int<class_int>` **get_limit** **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const|
  294. 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.
  295. .. rst-class:: classref-item-separator
  296. ----
  297. .. _class_Camera2D_property_limit_right:
  298. .. rst-class:: classref-property
  299. :ref:`int<class_int>` **limit_right** = ``10000000``
  300. .. rst-class:: classref-property-setget
  301. - void **set_limit** **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`int<class_int>` limit **)**
  302. - :ref:`int<class_int>` **get_limit** **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const|
  303. 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.
  304. .. rst-class:: classref-item-separator
  305. ----
  306. .. _class_Camera2D_property_limit_smoothed:
  307. .. rst-class:: classref-property
  308. :ref:`bool<class_bool>` **limit_smoothed** = ``false``
  309. .. rst-class:: classref-property-setget
  310. - void **set_limit_smoothing_enabled** **(** :ref:`bool<class_bool>` value **)**
  311. - :ref:`bool<class_bool>` **is_limit_smoothing_enabled** **(** **)**
  312. If ``true``, the camera smoothly stops when reaches its limits.
  313. This property has no effect if :ref:`position_smoothing_enabled<class_Camera2D_property_position_smoothing_enabled>` is ``false``.
  314. \ **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>`.
  315. .. rst-class:: classref-item-separator
  316. ----
  317. .. _class_Camera2D_property_limit_top:
  318. .. rst-class:: classref-property
  319. :ref:`int<class_int>` **limit_top** = ``-10000000``
  320. .. rst-class:: classref-property-setget
  321. - void **set_limit** **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`int<class_int>` limit **)**
  322. - :ref:`int<class_int>` **get_limit** **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const|
  323. 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.
  324. .. rst-class:: classref-item-separator
  325. ----
  326. .. _class_Camera2D_property_offset:
  327. .. rst-class:: classref-property
  328. :ref:`Vector2<class_Vector2>` **offset** = ``Vector2(0, 0)``
  329. .. rst-class:: classref-property-setget
  330. - void **set_offset** **(** :ref:`Vector2<class_Vector2>` value **)**
  331. - :ref:`Vector2<class_Vector2>` **get_offset** **(** **)**
  332. 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>`.
  333. .. rst-class:: classref-item-separator
  334. ----
  335. .. _class_Camera2D_property_position_smoothing_enabled:
  336. .. rst-class:: classref-property
  337. :ref:`bool<class_bool>` **position_smoothing_enabled** = ``false``
  338. .. rst-class:: classref-property-setget
  339. - void **set_position_smoothing_enabled** **(** :ref:`bool<class_bool>` value **)**
  340. - :ref:`bool<class_bool>` **is_position_smoothing_enabled** **(** **)**
  341. If ``true``, the camera's view smoothly moves towards its target position at :ref:`position_smoothing_speed<class_Camera2D_property_position_smoothing_speed>`.
  342. .. rst-class:: classref-item-separator
  343. ----
  344. .. _class_Camera2D_property_position_smoothing_speed:
  345. .. rst-class:: classref-property
  346. :ref:`float<class_float>` **position_smoothing_speed** = ``5.0``
  347. .. rst-class:: classref-property-setget
  348. - void **set_position_smoothing_speed** **(** :ref:`float<class_float>` value **)**
  349. - :ref:`float<class_float>` **get_position_smoothing_speed** **(** **)**
  350. Speed in pixels per second of the camera's smoothing effect when :ref:`position_smoothing_enabled<class_Camera2D_property_position_smoothing_enabled>` is ``true``.
  351. .. rst-class:: classref-item-separator
  352. ----
  353. .. _class_Camera2D_property_process_callback:
  354. .. rst-class:: classref-property
  355. :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>` **process_callback** = ``1``
  356. .. rst-class:: classref-property-setget
  357. - void **set_process_callback** **(** :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>` value **)**
  358. - :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>` **get_process_callback** **(** **)**
  359. The camera's process callback. See :ref:`Camera2DProcessCallback<enum_Camera2D_Camera2DProcessCallback>`.
  360. .. rst-class:: classref-item-separator
  361. ----
  362. .. _class_Camera2D_property_rotation_smoothing_enabled:
  363. .. rst-class:: classref-property
  364. :ref:`bool<class_bool>` **rotation_smoothing_enabled** = ``false``
  365. .. rst-class:: classref-property-setget
  366. - void **set_rotation_smoothing_enabled** **(** :ref:`bool<class_bool>` value **)**
  367. - :ref:`bool<class_bool>` **is_rotation_smoothing_enabled** **(** **)**
  368. 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>`.
  369. \ **Note:** This property has no effect if :ref:`ignore_rotation<class_Camera2D_property_ignore_rotation>` is ``true``.
  370. .. rst-class:: classref-item-separator
  371. ----
  372. .. _class_Camera2D_property_rotation_smoothing_speed:
  373. .. rst-class:: classref-property
  374. :ref:`float<class_float>` **rotation_smoothing_speed** = ``5.0``
  375. .. rst-class:: classref-property-setget
  376. - void **set_rotation_smoothing_speed** **(** :ref:`float<class_float>` value **)**
  377. - :ref:`float<class_float>` **get_rotation_smoothing_speed** **(** **)**
  378. The angular, asymptotic speed of the camera's rotation smoothing effect when :ref:`rotation_smoothing_enabled<class_Camera2D_property_rotation_smoothing_enabled>` is ``true``.
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_Camera2D_property_zoom:
  382. .. rst-class:: classref-property
  383. :ref:`Vector2<class_Vector2>` **zoom** = ``Vector2(1, 1)``
  384. .. rst-class:: classref-property-setget
  385. - void **set_zoom** **(** :ref:`Vector2<class_Vector2>` value **)**
  386. - :ref:`Vector2<class_Vector2>` **get_zoom** **(** **)**
  387. The camera's zoom. A zoom of ``Vector(2, 2)`` doubles the size seen in the viewport. A zoom of ``Vector(0.5, 0.5)`` halves the size seen in the viewport.
  388. .. rst-class:: classref-section-separator
  389. ----
  390. .. rst-class:: classref-descriptions-group
  391. Method Descriptions
  392. -------------------
  393. .. _class_Camera2D_method_align:
  394. .. rst-class:: classref-method
  395. void **align** **(** **)**
  396. Aligns the camera to the tracked node.
  397. .. rst-class:: classref-item-separator
  398. ----
  399. .. _class_Camera2D_method_force_update_scroll:
  400. .. rst-class:: classref-method
  401. void **force_update_scroll** **(** **)**
  402. Forces the camera to update scroll immediately.
  403. .. rst-class:: classref-item-separator
  404. ----
  405. .. _class_Camera2D_method_get_drag_margin:
  406. .. rst-class:: classref-method
  407. :ref:`float<class_float>` **get_drag_margin** **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const|
  408. 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>`.
  409. .. rst-class:: classref-item-separator
  410. ----
  411. .. _class_Camera2D_method_get_limit:
  412. .. rst-class:: classref-method
  413. :ref:`int<class_int>` **get_limit** **(** :ref:`Side<enum_@GlobalScope_Side>` margin **)** |const|
  414. 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>`.
  415. .. rst-class:: classref-item-separator
  416. ----
  417. .. _class_Camera2D_method_get_screen_center_position:
  418. .. rst-class:: classref-method
  419. :ref:`Vector2<class_Vector2>` **get_screen_center_position** **(** **)** |const|
  420. Returns the center of the screen from this camera's point of view, in global coordinates.
  421. \ **Note:** The exact targeted position of the camera may be different. See :ref:`get_target_position<class_Camera2D_method_get_target_position>`.
  422. .. rst-class:: classref-item-separator
  423. ----
  424. .. _class_Camera2D_method_get_target_position:
  425. .. rst-class:: classref-method
  426. :ref:`Vector2<class_Vector2>` **get_target_position** **(** **)** |const|
  427. Returns this camera's target position, in global coordinates.
  428. \ **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>`).
  429. .. rst-class:: classref-item-separator
  430. ----
  431. .. _class_Camera2D_method_reset_smoothing:
  432. .. rst-class:: classref-method
  433. void **reset_smoothing** **(** **)**
  434. Sets the camera's position immediately to its current smoothing destination.
  435. This method has no effect if :ref:`position_smoothing_enabled<class_Camera2D_property_position_smoothing_enabled>` is ``false``.
  436. .. rst-class:: classref-item-separator
  437. ----
  438. .. _class_Camera2D_method_set_drag_margin:
  439. .. rst-class:: classref-method
  440. void **set_drag_margin** **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`float<class_float>` drag_margin **)**
  441. 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>`.
  442. .. rst-class:: classref-item-separator
  443. ----
  444. .. _class_Camera2D_method_set_limit:
  445. .. rst-class:: classref-method
  446. void **set_limit** **(** :ref:`Side<enum_@GlobalScope_Side>` margin, :ref:`int<class_int>` limit **)**
  447. 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>`.
  448. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  449. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  450. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  451. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  452. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  453. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`