class_camera2d.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Camera2D.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Camera2D:
  5. Camera2D
  6. ========
  7. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Camera node for 2D scenes.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`align<class_Camera2D_align>` **(** **)** |
  16. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`clear_current<class_Camera2D_clear_current>` **(** **)** |
  18. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`force_update_scroll<class_Camera2D_force_update_scroll>` **(** **)** |
  20. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Vector2<class_vector2>` | :ref:`get_camera_position<class_Camera2D_get_camera_position>` **(** **)** const |
  22. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Vector2<class_vector2>` | :ref:`get_camera_screen_center<class_Camera2D_get_camera_screen_center>` **(** **)** const |
  24. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Node<class_node>` | :ref:`get_custom_viewport<class_Camera2D_get_custom_viewport>` **(** **)** const |
  26. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  27. | :ref:`float<class_float>` | :ref:`get_h_offset<class_Camera2D_get_h_offset>` **(** **)** const |
  28. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  29. | :ref:`float<class_float>` | :ref:`get_v_offset<class_Camera2D_get_v_offset>` **(** **)** const |
  30. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`make_current<class_Camera2D_make_current>` **(** **)** |
  32. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`reset_smoothing<class_Camera2D_reset_smoothing>` **(** **)** |
  34. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`set_custom_viewport<class_Camera2D_set_custom_viewport>` **(** :ref:`Node<class_node>` viewport **)** |
  36. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`set_h_offset<class_Camera2D_set_h_offset>` **(** :ref:`float<class_float>` ofs **)** |
  38. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_v_offset<class_Camera2D_set_v_offset>` **(** :ref:`float<class_float>` ofs **)** |
  40. +--------------------------------+-------------------------------------------------------------------------------------------------------------+
  41. Member Variables
  42. ----------------
  43. .. _class_Camera2D_anchor_mode:
  44. - :ref:`int<class_int>` **anchor_mode** - The Camera2D's anchor point. See ``ANCHOR_MODE\_\*`` constants.
  45. .. _class_Camera2D_current:
  46. - :ref:`bool<class_bool>` **current** - 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.
  47. .. _class_Camera2D_drag_margin_bottom:
  48. - :ref:`float<class_float>` **drag_margin_bottom** - Bottom margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the edge of the screen.
  49. .. _class_Camera2D_drag_margin_h_enabled:
  50. - :ref:`bool<class_bool>` **drag_margin_h_enabled** - If ``true`` the camera only moves when reaching the horizontal drag margins. If ``false`` the camera moves horizontally regardless of margins. Default value: ``true``.
  51. .. _class_Camera2D_drag_margin_left:
  52. - :ref:`float<class_float>` **drag_margin_left** - Left margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the edge of the screen.
  53. .. _class_Camera2D_drag_margin_right:
  54. - :ref:`float<class_float>` **drag_margin_right** - Right margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the edge of the screen.
  55. .. _class_Camera2D_drag_margin_top:
  56. - :ref:`float<class_float>` **drag_margin_top** - Top margin needed to drag the camera. A value of ``1`` makes the camera move only when reaching the edge of the screen.
  57. .. _class_Camera2D_drag_margin_v_enabled:
  58. - :ref:`bool<class_bool>` **drag_margin_v_enabled** - If ``true`` the camera only moves when reaching the vertical drag margins. If ``false`` the camera moves vertically regardless of margins. Default value: ``true``.
  59. .. _class_Camera2D_editor_draw_drag_margin:
  60. - :ref:`bool<class_bool>` **editor_draw_drag_margin** - If ``true`` draws the camera's drag margin rectangle in the editor. Default value: ``false``
  61. .. _class_Camera2D_editor_draw_limits:
  62. - :ref:`bool<class_bool>` **editor_draw_limits** - If ``true`` draws the camera's limits rectangle in the editor. Default value: ``true``
  63. .. _class_Camera2D_editor_draw_screen:
  64. - :ref:`bool<class_bool>` **editor_draw_screen** - If ``true`` draws the camera's screen rectangle in the editor. Default value: ``false``
  65. .. _class_Camera2D_limit_bottom:
  66. - :ref:`int<class_int>` **limit_bottom** - Bottom scroll limit in pixels. The camera stops moving when reaching this value.
  67. .. _class_Camera2D_limit_left:
  68. - :ref:`int<class_int>` **limit_left** - Left scroll limit in pixels. The camera stops moving when reaching this value.
  69. .. _class_Camera2D_limit_right:
  70. - :ref:`int<class_int>` **limit_right** - Right scroll limit in pixels. The camera stops moving when reaching this value.
  71. .. _class_Camera2D_limit_smoothed:
  72. - :ref:`bool<class_bool>` **limit_smoothed** - If ``true`` the camera smoothly stops when reaches its limits. Default value: ``false``
  73. .. _class_Camera2D_limit_top:
  74. - :ref:`int<class_int>` **limit_top** - Top scroll limit in pixels. The camera stops moving when reaching this value.
  75. .. _class_Camera2D_offset:
  76. - :ref:`Vector2<class_vector2>` **offset** - The camera's offset, useful for looking around or camera shake animations.
  77. .. _class_Camera2D_rotating:
  78. - :ref:`bool<class_bool>` **rotating** - If ``true`` the camera rotates with the target. Default value: ``false``
  79. .. _class_Camera2D_smoothing_enabled:
  80. - :ref:`bool<class_bool>` **smoothing_enabled** - If ``true`` the camera smoothly moves towards the target at :ref:`smoothing_speed<class_Camera2D_smoothing_speed>`. Default value: ``false``
  81. .. _class_Camera2D_smoothing_speed:
  82. - :ref:`float<class_float>` **smoothing_speed** - Speed in pixels per second of the camera's smoothing effect when :ref:`smoothing_enabled<class_Camera2D_smoothing_enabled>` is ``true``
  83. .. _class_Camera2D_zoom:
  84. - :ref:`Vector2<class_vector2>` **zoom** - 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 2x zoom in, and ``Vector2(4, 4)`` for a 4x zoom out.
  85. Numeric Constants
  86. -----------------
  87. - **ANCHOR_MODE_FIXED_TOP_LEFT** = **0** --- The camera's position is fixed so that the top-left corner is always at the origin.
  88. - **ANCHOR_MODE_DRAG_CENTER** = **1** --- The camera's position takes into account vertical/horizontal offsets and the screen size.
  89. Description
  90. -----------
  91. 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.
  92. This node is intended to be a simple helper to get things going quickly and it may happen often that more functionality is desired to change how the camera works. To make your own custom camera node, simply inherit from :ref:`Node2D<class_node2d>` and change the transform of the canvas by calling get_viewport().set_canvas_transform(m) in :ref:`Viewport<class_viewport>`.
  93. Member Function Description
  94. ---------------------------
  95. .. _class_Camera2D_align:
  96. - void **align** **(** **)**
  97. Align the camera to the tracked node
  98. .. _class_Camera2D_clear_current:
  99. - void **clear_current** **(** **)**
  100. Removes any ``Camera2D`` from the ancestor :ref:`Viewport<class_viewport>`'s internal currently-assigned camera.
  101. .. _class_Camera2D_force_update_scroll:
  102. - void **force_update_scroll** **(** **)**
  103. Force the camera to update scroll immediately.
  104. .. _class_Camera2D_get_camera_position:
  105. - :ref:`Vector2<class_vector2>` **get_camera_position** **(** **)** const
  106. Return the camera position.
  107. .. _class_Camera2D_get_camera_screen_center:
  108. - :ref:`Vector2<class_vector2>` **get_camera_screen_center** **(** **)** const
  109. Returns the location of the ``Camera2D``'s screen-center, relative to the origin.
  110. .. _class_Camera2D_get_custom_viewport:
  111. - :ref:`Node<class_node>` **get_custom_viewport** **(** **)** const
  112. Returns the :ref:`Viewport<class_viewport>` used by the camera if it is not using the default viewport.
  113. .. _class_Camera2D_get_h_offset:
  114. - :ref:`float<class_float>` **get_h_offset** **(** **)** const
  115. Returns the horizontal offset of the camera.
  116. .. _class_Camera2D_get_v_offset:
  117. - :ref:`float<class_float>` **get_v_offset** **(** **)** const
  118. Returns the vertical offset of the camera.
  119. .. _class_Camera2D_make_current:
  120. - void **make_current** **(** **)**
  121. Make this the current 2D camera for the scene (viewport and layer), in case there's many cameras in the scene.
  122. .. _class_Camera2D_reset_smoothing:
  123. - void **reset_smoothing** **(** **)**
  124. Set the camera's position immediately to its current smoothing destination.
  125. This has no effect if smoothing is disabled.
  126. .. _class_Camera2D_set_custom_viewport:
  127. - void **set_custom_viewport** **(** :ref:`Node<class_node>` viewport **)**
  128. Assigns a custom :ref:`Viewport<class_viewport>` node to the ``Camera2D``. If ``viewport`` is not a :ref:`Viewport<class_viewport>`, it re-assigns the default viewport instead.
  129. .. _class_Camera2D_set_h_offset:
  130. - void **set_h_offset** **(** :ref:`float<class_float>` ofs **)**
  131. The camera's horizontal offset is set to ``ofs``.
  132. .. _class_Camera2D_set_v_offset:
  133. - void **set_v_offset** **(** :ref:`float<class_float>` ofs **)**
  134. The camera's vertical offset is set to ``ofs``.