class_camera2d.rst 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/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. 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>`).
  16. 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_camera_screen_center<class_Camera2D_method_get_camera_screen_center>` to get the real position.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - `2D Platformer Demo <https://godotengine.org/asset-library/asset/120>`__
  21. - `2D Isometric Demo <https://godotengine.org/asset-library/asset/112>`__
  22. - `2D HDR Demo <https://godotengine.org/asset-library/asset/110>`__
  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:`bool<class_bool>` | :ref:`current<class_Camera2D_property_current>` | ``false`` |
  32. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  33. | :ref:`Node<class_Node>` | :ref:`custom_viewport<class_Camera2D_property_custom_viewport>` | |
  34. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  35. | :ref:`float<class_float>` | :ref:`drag_margin_bottom<class_Camera2D_property_drag_margin_bottom>` | ``0.2`` |
  36. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  37. | :ref:`bool<class_bool>` | :ref:`drag_margin_h_enabled<class_Camera2D_property_drag_margin_h_enabled>` | ``false`` |
  38. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  39. | :ref:`float<class_float>` | :ref:`drag_margin_left<class_Camera2D_property_drag_margin_left>` | ``0.2`` |
  40. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  41. | :ref:`float<class_float>` | :ref:`drag_margin_right<class_Camera2D_property_drag_margin_right>` | ``0.2`` |
  42. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  43. | :ref:`float<class_float>` | :ref:`drag_margin_top<class_Camera2D_property_drag_margin_top>` | ``0.2`` |
  44. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  45. | :ref:`bool<class_bool>` | :ref:`drag_margin_v_enabled<class_Camera2D_property_drag_margin_v_enabled>` | ``false`` |
  46. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  47. | :ref:`bool<class_bool>` | :ref:`editor_draw_drag_margin<class_Camera2D_property_editor_draw_drag_margin>` | ``false`` |
  48. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  49. | :ref:`bool<class_bool>` | :ref:`editor_draw_limits<class_Camera2D_property_editor_draw_limits>` | ``false`` |
  50. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  51. | :ref:`bool<class_bool>` | :ref:`editor_draw_screen<class_Camera2D_property_editor_draw_screen>` | ``true`` |
  52. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  53. | :ref:`int<class_int>` | :ref:`limit_bottom<class_Camera2D_property_limit_bottom>` | ``10000000`` |
  54. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  55. | :ref:`int<class_int>` | :ref:`limit_left<class_Camera2D_property_limit_left>` | ``-10000000`` |
  56. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  57. | :ref:`int<class_int>` | :ref:`limit_right<class_Camera2D_property_limit_right>` | ``10000000`` |
  58. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  59. | :ref:`bool<class_bool>` | :ref:`limit_smoothed<class_Camera2D_property_limit_smoothed>` | ``false`` |
  60. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  61. | :ref:`int<class_int>` | :ref:`limit_top<class_Camera2D_property_limit_top>` | ``-10000000`` |
  62. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  63. | :ref:`Vector2<class_Vector2>` | :ref:`offset<class_Camera2D_property_offset>` | ``Vector2( 0, 0 )`` |
  64. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  65. | :ref:`float<class_float>` | :ref:`offset_h<class_Camera2D_property_offset_h>` | ``0.0`` |
  66. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  67. | :ref:`float<class_float>` | :ref:`offset_v<class_Camera2D_property_offset_v>` | ``0.0`` |
  68. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  69. | :ref:`Camera2DProcessMode<enum_Camera2D_Camera2DProcessMode>` | :ref:`process_mode<class_Camera2D_property_process_mode>` | ``1`` |
  70. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  71. | :ref:`bool<class_bool>` | :ref:`rotating<class_Camera2D_property_rotating>` | ``false`` |
  72. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  73. | :ref:`bool<class_bool>` | :ref:`smoothing_enabled<class_Camera2D_property_smoothing_enabled>` | ``false`` |
  74. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  75. | :ref:`float<class_float>` | :ref:`smoothing_speed<class_Camera2D_property_smoothing_speed>` | ``5.0`` |
  76. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  77. | :ref:`Vector2<class_Vector2>` | :ref:`zoom<class_Camera2D_property_zoom>` | ``Vector2( 1, 1 )`` |
  78. +---------------------------------------------------------------+---------------------------------------------------------------------------------+---------------------+
  79. .. rst-class:: classref-reftable-group
  80. Methods
  81. -------
  82. .. table::
  83. :widths: auto
  84. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`align<class_Camera2D_method_align>` **(** **)** |
  86. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`clear_current<class_Camera2D_method_clear_current>` **(** **)** |
  88. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`force_update_scroll<class_Camera2D_method_force_update_scroll>` **(** **)** |
  90. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`Vector2<class_Vector2>` | :ref:`get_camera_position<class_Camera2D_method_get_camera_position>` **(** **)** |const| |
  92. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`Vector2<class_Vector2>` | :ref:`get_camera_screen_center<class_Camera2D_method_get_camera_screen_center>` **(** **)** |const| |
  94. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`float<class_float>` | :ref:`get_drag_margin<class_Camera2D_method_get_drag_margin>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const| |
  96. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`int<class_int>` | :ref:`get_limit<class_Camera2D_method_get_limit>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const| |
  98. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`make_current<class_Camera2D_method_make_current>` **(** **)** |
  100. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`reset_smoothing<class_Camera2D_method_reset_smoothing>` **(** **)** |
  102. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`set_drag_margin<class_Camera2D_method_set_drag_margin>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` drag_margin **)** |
  104. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`set_limit<class_Camera2D_method_set_limit>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` limit **)** |
  106. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. .. rst-class:: classref-section-separator
  108. ----
  109. .. rst-class:: classref-descriptions-group
  110. Enumerations
  111. ------------
  112. .. _enum_Camera2D_AnchorMode:
  113. .. rst-class:: classref-enumeration
  114. enum **AnchorMode**:
  115. .. _class_Camera2D_constant_ANCHOR_MODE_FIXED_TOP_LEFT:
  116. .. rst-class:: classref-enumeration-constant
  117. :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **ANCHOR_MODE_FIXED_TOP_LEFT** = ``0``
  118. The camera's position is fixed so that the top-left corner is always at the origin.
  119. .. _class_Camera2D_constant_ANCHOR_MODE_DRAG_CENTER:
  120. .. rst-class:: classref-enumeration-constant
  121. :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **ANCHOR_MODE_DRAG_CENTER** = ``1``
  122. The camera's position takes into account vertical/horizontal offsets and the screen size.
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _enum_Camera2D_Camera2DProcessMode:
  126. .. rst-class:: classref-enumeration
  127. enum **Camera2DProcessMode**:
  128. .. _class_Camera2D_constant_CAMERA2D_PROCESS_PHYSICS:
  129. .. rst-class:: classref-enumeration-constant
  130. :ref:`Camera2DProcessMode<enum_Camera2D_Camera2DProcessMode>` **CAMERA2D_PROCESS_PHYSICS** = ``0``
  131. The camera updates with the ``_physics_process`` callback.
  132. .. _class_Camera2D_constant_CAMERA2D_PROCESS_IDLE:
  133. .. rst-class:: classref-enumeration-constant
  134. :ref:`Camera2DProcessMode<enum_Camera2D_Camera2DProcessMode>` **CAMERA2D_PROCESS_IDLE** = ``1``
  135. The camera updates with the ``_process`` callback.
  136. .. rst-class:: classref-section-separator
  137. ----
  138. .. rst-class:: classref-descriptions-group
  139. Property Descriptions
  140. ---------------------
  141. .. _class_Camera2D_property_anchor_mode:
  142. .. rst-class:: classref-property
  143. :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **anchor_mode** = ``1``
  144. .. rst-class:: classref-property-setget
  145. - void **set_anchor_mode** **(** :ref:`AnchorMode<enum_Camera2D_AnchorMode>` value **)**
  146. - :ref:`AnchorMode<enum_Camera2D_AnchorMode>` **get_anchor_mode** **(** **)**
  147. The Camera2D's anchor point. See :ref:`AnchorMode<enum_Camera2D_AnchorMode>` constants.
  148. .. rst-class:: classref-item-separator
  149. ----
  150. .. _class_Camera2D_property_current:
  151. .. rst-class:: classref-property
  152. :ref:`bool<class_bool>` **current** = ``false``
  153. .. rst-class:: classref-property-setget
  154. - :ref:`bool<class_bool>` **is_current** **(** **)**
  155. If ``true``, the camera is the active camera for the current scene. Only one camera can be current, so setting a different camera ``current`` will disable this one.
  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**
  161. .. rst-class:: classref-property-setget
  162. - void **set_custom_viewport** **(** :ref:`Node<class_Node>` value **)**
  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_margin_bottom:
  168. .. rst-class:: classref-property
  169. :ref:`float<class_float>` **drag_margin_bottom** = ``0.2``
  170. .. rst-class:: classref-property-setget
  171. - void **set_drag_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` drag_margin **)**
  172. - :ref:`float<class_float>` **get_drag_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  173. Bottom margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the edge of the screen.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_Camera2D_property_drag_margin_h_enabled:
  177. .. rst-class:: classref-property
  178. :ref:`bool<class_bool>` **drag_margin_h_enabled** = ``false``
  179. .. rst-class:: classref-property-setget
  180. - void **set_h_drag_enabled** **(** :ref:`bool<class_bool>` value **)**
  181. - :ref:`bool<class_bool>` **is_h_drag_enabled** **(** **)**
  182. If ``true``, the camera only moves when reaching the horizontal drag margins. If ``false``, the camera moves horizontally regardless of margins.
  183. .. rst-class:: classref-item-separator
  184. ----
  185. .. _class_Camera2D_property_drag_margin_left:
  186. .. rst-class:: classref-property
  187. :ref:`float<class_float>` **drag_margin_left** = ``0.2``
  188. .. rst-class:: classref-property-setget
  189. - void **set_drag_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` drag_margin **)**
  190. - :ref:`float<class_float>` **get_drag_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  191. Left margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the edge of the screen.
  192. .. rst-class:: classref-item-separator
  193. ----
  194. .. _class_Camera2D_property_drag_margin_right:
  195. .. rst-class:: classref-property
  196. :ref:`float<class_float>` **drag_margin_right** = ``0.2``
  197. .. rst-class:: classref-property-setget
  198. - void **set_drag_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` drag_margin **)**
  199. - :ref:`float<class_float>` **get_drag_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  200. Right margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the edge of the screen.
  201. .. rst-class:: classref-item-separator
  202. ----
  203. .. _class_Camera2D_property_drag_margin_top:
  204. .. rst-class:: classref-property
  205. :ref:`float<class_float>` **drag_margin_top** = ``0.2``
  206. .. rst-class:: classref-property-setget
  207. - void **set_drag_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` drag_margin **)**
  208. - :ref:`float<class_float>` **get_drag_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  209. Top margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the edge of the screen.
  210. .. rst-class:: classref-item-separator
  211. ----
  212. .. _class_Camera2D_property_drag_margin_v_enabled:
  213. .. rst-class:: classref-property
  214. :ref:`bool<class_bool>` **drag_margin_v_enabled** = ``false``
  215. .. rst-class:: classref-property-setget
  216. - void **set_v_drag_enabled** **(** :ref:`bool<class_bool>` value **)**
  217. - :ref:`bool<class_bool>` **is_v_drag_enabled** **(** **)**
  218. If ``true``, the camera only moves when reaching the vertical drag margins. If ``false``, the camera moves vertically regardless of margins.
  219. .. rst-class:: classref-item-separator
  220. ----
  221. .. _class_Camera2D_property_editor_draw_drag_margin:
  222. .. rst-class:: classref-property
  223. :ref:`bool<class_bool>` **editor_draw_drag_margin** = ``false``
  224. .. rst-class:: classref-property-setget
  225. - void **set_margin_drawing_enabled** **(** :ref:`bool<class_bool>` value **)**
  226. - :ref:`bool<class_bool>` **is_margin_drawing_enabled** **(** **)**
  227. If ``true``, draws the camera's drag margin rectangle in the editor.
  228. .. rst-class:: classref-item-separator
  229. ----
  230. .. _class_Camera2D_property_editor_draw_limits:
  231. .. rst-class:: classref-property
  232. :ref:`bool<class_bool>` **editor_draw_limits** = ``false``
  233. .. rst-class:: classref-property-setget
  234. - void **set_limit_drawing_enabled** **(** :ref:`bool<class_bool>` value **)**
  235. - :ref:`bool<class_bool>` **is_limit_drawing_enabled** **(** **)**
  236. If ``true``, draws the camera's limits rectangle in the editor.
  237. .. rst-class:: classref-item-separator
  238. ----
  239. .. _class_Camera2D_property_editor_draw_screen:
  240. .. rst-class:: classref-property
  241. :ref:`bool<class_bool>` **editor_draw_screen** = ``true``
  242. .. rst-class:: classref-property-setget
  243. - void **set_screen_drawing_enabled** **(** :ref:`bool<class_bool>` value **)**
  244. - :ref:`bool<class_bool>` **is_screen_drawing_enabled** **(** **)**
  245. If ``true``, draws the camera's screen rectangle in the editor.
  246. .. rst-class:: classref-item-separator
  247. ----
  248. .. _class_Camera2D_property_limit_bottom:
  249. .. rst-class:: classref-property
  250. :ref:`int<class_int>` **limit_bottom** = ``10000000``
  251. .. rst-class:: classref-property-setget
  252. - void **set_limit** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` limit **)**
  253. - :ref:`int<class_int>` **get_limit** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  254. Bottom scroll limit in pixels. The camera stops moving when reaching this value.
  255. .. rst-class:: classref-item-separator
  256. ----
  257. .. _class_Camera2D_property_limit_left:
  258. .. rst-class:: classref-property
  259. :ref:`int<class_int>` **limit_left** = ``-10000000``
  260. .. rst-class:: classref-property-setget
  261. - void **set_limit** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` limit **)**
  262. - :ref:`int<class_int>` **get_limit** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  263. Left scroll limit in pixels. The camera stops moving when reaching this value.
  264. .. rst-class:: classref-item-separator
  265. ----
  266. .. _class_Camera2D_property_limit_right:
  267. .. rst-class:: classref-property
  268. :ref:`int<class_int>` **limit_right** = ``10000000``
  269. .. rst-class:: classref-property-setget
  270. - void **set_limit** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` limit **)**
  271. - :ref:`int<class_int>` **get_limit** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  272. Right scroll limit in pixels. The camera stops moving when reaching this value.
  273. .. rst-class:: classref-item-separator
  274. ----
  275. .. _class_Camera2D_property_limit_smoothed:
  276. .. rst-class:: classref-property
  277. :ref:`bool<class_bool>` **limit_smoothed** = ``false``
  278. .. rst-class:: classref-property-setget
  279. - void **set_limit_smoothing_enabled** **(** :ref:`bool<class_bool>` value **)**
  280. - :ref:`bool<class_bool>` **is_limit_smoothing_enabled** **(** **)**
  281. If ``true``, the camera smoothly stops when reaches its limits.
  282. This property has no effect if :ref:`smoothing_enabled<class_Camera2D_property_smoothing_enabled>` is ``false``.
  283. \ **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>`.
  284. .. rst-class:: classref-item-separator
  285. ----
  286. .. _class_Camera2D_property_limit_top:
  287. .. rst-class:: classref-property
  288. :ref:`int<class_int>` **limit_top** = ``-10000000``
  289. .. rst-class:: classref-property-setget
  290. - void **set_limit** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` limit **)**
  291. - :ref:`int<class_int>` **get_limit** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  292. Top scroll limit in pixels. The camera stops moving when reaching this value.
  293. .. rst-class:: classref-item-separator
  294. ----
  295. .. _class_Camera2D_property_offset:
  296. .. rst-class:: classref-property
  297. :ref:`Vector2<class_Vector2>` **offset** = ``Vector2( 0, 0 )``
  298. .. rst-class:: classref-property-setget
  299. - void **set_offset** **(** :ref:`Vector2<class_Vector2>` value **)**
  300. - :ref:`Vector2<class_Vector2>` **get_offset** **(** **)**
  301. The camera's offset, useful for looking around or camera shake animations.
  302. .. rst-class:: classref-item-separator
  303. ----
  304. .. _class_Camera2D_property_offset_h:
  305. .. rst-class:: classref-property
  306. :ref:`float<class_float>` **offset_h** = ``0.0``
  307. .. rst-class:: classref-property-setget
  308. - void **set_h_offset** **(** :ref:`float<class_float>` value **)**
  309. - :ref:`float<class_float>` **get_h_offset** **(** **)**
  310. The horizontal offset of the camera, relative to the drag margins.
  311. \ **Note:** Offset H is used only to force offset relative to margins. It's not updated in any way if drag margins are enabled and can be used to set initial offset.
  312. .. rst-class:: classref-item-separator
  313. ----
  314. .. _class_Camera2D_property_offset_v:
  315. .. rst-class:: classref-property
  316. :ref:`float<class_float>` **offset_v** = ``0.0``
  317. .. rst-class:: classref-property-setget
  318. - void **set_v_offset** **(** :ref:`float<class_float>` value **)**
  319. - :ref:`float<class_float>` **get_v_offset** **(** **)**
  320. The vertical offset of the camera, relative to the drag margins.
  321. \ **Note:** Used the same as :ref:`offset_h<class_Camera2D_property_offset_h>`.
  322. .. rst-class:: classref-item-separator
  323. ----
  324. .. _class_Camera2D_property_process_mode:
  325. .. rst-class:: classref-property
  326. :ref:`Camera2DProcessMode<enum_Camera2D_Camera2DProcessMode>` **process_mode** = ``1``
  327. .. rst-class:: classref-property-setget
  328. - void **set_process_mode** **(** :ref:`Camera2DProcessMode<enum_Camera2D_Camera2DProcessMode>` value **)**
  329. - :ref:`Camera2DProcessMode<enum_Camera2D_Camera2DProcessMode>` **get_process_mode** **(** **)**
  330. The camera's process callback. See :ref:`Camera2DProcessMode<enum_Camera2D_Camera2DProcessMode>`.
  331. .. rst-class:: classref-item-separator
  332. ----
  333. .. _class_Camera2D_property_rotating:
  334. .. rst-class:: classref-property
  335. :ref:`bool<class_bool>` **rotating** = ``false``
  336. .. rst-class:: classref-property-setget
  337. - void **set_rotating** **(** :ref:`bool<class_bool>` value **)**
  338. - :ref:`bool<class_bool>` **is_rotating** **(** **)**
  339. If ``true``, the camera view rotates with the target.
  340. .. rst-class:: classref-item-separator
  341. ----
  342. .. _class_Camera2D_property_smoothing_enabled:
  343. .. rst-class:: classref-property
  344. :ref:`bool<class_bool>` **smoothing_enabled** = ``false``
  345. .. rst-class:: classref-property-setget
  346. - void **set_enable_follow_smoothing** **(** :ref:`bool<class_bool>` value **)**
  347. - :ref:`bool<class_bool>` **is_follow_smoothing_enabled** **(** **)**
  348. If ``true``, the camera smoothly moves towards the target at :ref:`smoothing_speed<class_Camera2D_property_smoothing_speed>`.
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_Camera2D_property_smoothing_speed:
  352. .. rst-class:: classref-property
  353. :ref:`float<class_float>` **smoothing_speed** = ``5.0``
  354. .. rst-class:: classref-property-setget
  355. - void **set_follow_smoothing** **(** :ref:`float<class_float>` value **)**
  356. - :ref:`float<class_float>` **get_follow_smoothing** **(** **)**
  357. Speed in pixels per second of the camera's smoothing effect when :ref:`smoothing_enabled<class_Camera2D_property_smoothing_enabled>` is ``true``.
  358. .. rst-class:: classref-item-separator
  359. ----
  360. .. _class_Camera2D_property_zoom:
  361. .. rst-class:: classref-property
  362. :ref:`Vector2<class_Vector2>` **zoom** = ``Vector2( 1, 1 )``
  363. .. rst-class:: classref-property-setget
  364. - void **set_zoom** **(** :ref:`Vector2<class_Vector2>` value **)**
  365. - :ref:`Vector2<class_Vector2>` **get_zoom** **(** **)**
  366. The camera's zoom relative to the viewport. Values larger than ``Vector2(1, 1)`` zoom out and smaller values zoom in. For an example, use ``Vector2(0.5, 0.5)`` for a 2× zoom-in, and ``Vector2(4, 4)`` for a 4× zoom-out.
  367. .. rst-class:: classref-section-separator
  368. ----
  369. .. rst-class:: classref-descriptions-group
  370. Method Descriptions
  371. -------------------
  372. .. _class_Camera2D_method_align:
  373. .. rst-class:: classref-method
  374. void **align** **(** **)**
  375. Aligns the camera to the tracked node.
  376. .. rst-class:: classref-item-separator
  377. ----
  378. .. _class_Camera2D_method_clear_current:
  379. .. rst-class:: classref-method
  380. void **clear_current** **(** **)**
  381. Removes any **Camera2D** from the ancestor :ref:`Viewport<class_Viewport>`'s internal currently-assigned camera.
  382. .. rst-class:: classref-item-separator
  383. ----
  384. .. _class_Camera2D_method_force_update_scroll:
  385. .. rst-class:: classref-method
  386. void **force_update_scroll** **(** **)**
  387. Forces the camera to update scroll immediately.
  388. .. rst-class:: classref-item-separator
  389. ----
  390. .. _class_Camera2D_method_get_camera_position:
  391. .. rst-class:: classref-method
  392. :ref:`Vector2<class_Vector2>` **get_camera_position** **(** **)** |const|
  393. Returns the camera's ``position`` (the tracked point the camera attempts to follow), relative to the origin.
  394. \ **Note:** The returned value is not the same as :ref:`Node2D.position<class_Node2D_property_position>` or :ref:`Node2D.global_position<class_Node2D_property_global_position>`, as it is affected by the ``drag`` properties.
  395. .. rst-class:: classref-item-separator
  396. ----
  397. .. _class_Camera2D_method_get_camera_screen_center:
  398. .. rst-class:: classref-method
  399. :ref:`Vector2<class_Vector2>` **get_camera_screen_center** **(** **)** |const|
  400. Returns the location of the **Camera2D**'s screen-center, relative to the origin.
  401. \ **Note:** The real ``position`` of the camera may be different, see :ref:`get_camera_position<class_Camera2D_method_get_camera_position>`.
  402. .. rst-class:: classref-item-separator
  403. ----
  404. .. _class_Camera2D_method_get_drag_margin:
  405. .. rst-class:: classref-method
  406. :ref:`float<class_float>` **get_drag_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  407. Returns the specified margin. See also :ref:`drag_margin_bottom<class_Camera2D_property_drag_margin_bottom>`, :ref:`drag_margin_top<class_Camera2D_property_drag_margin_top>`, :ref:`drag_margin_left<class_Camera2D_property_drag_margin_left>`, and :ref:`drag_margin_right<class_Camera2D_property_drag_margin_right>`.
  408. .. rst-class:: classref-item-separator
  409. ----
  410. .. _class_Camera2D_method_get_limit:
  411. .. rst-class:: classref-method
  412. :ref:`int<class_int>` **get_limit** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  413. Returns the specified camera limit. 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>`.
  414. .. rst-class:: classref-item-separator
  415. ----
  416. .. _class_Camera2D_method_make_current:
  417. .. rst-class:: classref-method
  418. void **make_current** **(** **)**
  419. Make this the current 2D camera for the scene (viewport and layer), in case there are many cameras in the scene.
  420. .. rst-class:: classref-item-separator
  421. ----
  422. .. _class_Camera2D_method_reset_smoothing:
  423. .. rst-class:: classref-method
  424. void **reset_smoothing** **(** **)**
  425. Sets the camera's position immediately to its current smoothing destination.
  426. This method has no effect if :ref:`smoothing_enabled<class_Camera2D_property_smoothing_enabled>` is ``false``.
  427. .. rst-class:: classref-item-separator
  428. ----
  429. .. _class_Camera2D_method_set_drag_margin:
  430. .. rst-class:: classref-method
  431. void **set_drag_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`float<class_float>` drag_margin **)**
  432. Sets the specified margin. See also :ref:`drag_margin_bottom<class_Camera2D_property_drag_margin_bottom>`, :ref:`drag_margin_top<class_Camera2D_property_drag_margin_top>`, :ref:`drag_margin_left<class_Camera2D_property_drag_margin_left>`, and :ref:`drag_margin_right<class_Camera2D_property_drag_margin_right>`.
  433. .. rst-class:: classref-item-separator
  434. ----
  435. .. _class_Camera2D_method_set_limit:
  436. .. rst-class:: classref-method
  437. void **set_limit** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` limit **)**
  438. Sets the specified camera limit. 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>`.
  439. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  440. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  441. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  442. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`