Files
godot-docs-l10n/classes/zh_Hant/class_parallax2d.rst

248 lines
14 KiB
ReStructuredText

:github_url: hide
.. _class_Parallax2D:
Parallax2D
==========
**繼承:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
用於建立視差滾動背景的節點。
.. rst-class:: classref-introduction-group
說明
----
A **Parallax2D** is used to create a parallax effect. It can move at a different speed relative to the camera movement using :ref:`scroll_scale<class_Parallax2D_property_scroll_scale>`. This creates an illusion of depth in a 2D game. If manual scrolling is desired, the :ref:`Camera2D<class_Camera2D>` position can be ignored with :ref:`ignore_camera_scroll<class_Parallax2D_property_ignore_camera_scroll>`.
\ **Note:** Any changes to this node's position made after it enters the scene tree will be overridden if :ref:`ignore_camera_scroll<class_Parallax2D_property_ignore_camera_scroll>` is ``false`` or :ref:`screen_offset<class_Parallax2D_property_screen_offset>` is modified.
.. rst-class:: classref-introduction-group
教學
----
- :doc:`2D Parallax <../tutorials/2d/2d_parallax>`
.. rst-class:: classref-reftable-group
屬性
----
.. table::
:widths: auto
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`autoscroll<class_Parallax2D_property_autoscroll>` | ``Vector2(0, 0)`` |
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`follow_viewport<class_Parallax2D_property_follow_viewport>` | ``true`` |
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`ignore_camera_scroll<class_Parallax2D_property_ignore_camera_scroll>` | ``false`` |
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`limit_begin<class_Parallax2D_property_limit_begin>` | ``Vector2(-10000000, -10000000)`` |
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`limit_end<class_Parallax2D_property_limit_end>` | ``Vector2(10000000, 10000000)`` |
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`PhysicsInterpolationMode<enum_Node_PhysicsInterpolationMode>` | physics_interpolation_mode | ``2`` (overrides :ref:`Node<class_Node_property_physics_interpolation_mode>`) |
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`repeat_size<class_Parallax2D_property_repeat_size>` | ``Vector2(0, 0)`` |
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`repeat_times<class_Parallax2D_property_repeat_times>` | ``1`` |
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`screen_offset<class_Parallax2D_property_screen_offset>` | ``Vector2(0, 0)`` |
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`scroll_offset<class_Parallax2D_property_scroll_offset>` | ``Vector2(0, 0)`` |
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`scroll_scale<class_Parallax2D_property_scroll_scale>` | ``Vector2(1, 1)`` |
+---------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
屬性說明
--------
.. _class_Parallax2D_property_autoscroll:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **autoscroll** = ``Vector2(0, 0)`` :ref:`🔗<class_Parallax2D_property_autoscroll>`
.. rst-class:: classref-property-setget
- |void| **set_autoscroll**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_autoscroll**\ (\ )
Velocity at which the offset scrolls automatically, in pixels per second.
.. rst-class:: classref-item-separator
----
.. _class_Parallax2D_property_follow_viewport:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **follow_viewport** = ``true`` :ref:`🔗<class_Parallax2D_property_follow_viewport>`
.. rst-class:: classref-property-setget
- |void| **set_follow_viewport**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_follow_viewport**\ (\ )
If ``true``, this **Parallax2D** is offset by the current camera's position. If the **Parallax2D** is in a :ref:`CanvasLayer<class_CanvasLayer>` separate from the current camera, it may be desired to match the value with :ref:`CanvasLayer.follow_viewport_enabled<class_CanvasLayer_property_follow_viewport_enabled>`.
.. rst-class:: classref-item-separator
----
.. _class_Parallax2D_property_ignore_camera_scroll:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **ignore_camera_scroll** = ``false`` :ref:`🔗<class_Parallax2D_property_ignore_camera_scroll>`
.. rst-class:: classref-property-setget
- |void| **set_ignore_camera_scroll**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_ignore_camera_scroll**\ (\ )
If ``true``, **Parallax2D**'s position is not affected by the position of the camera.
.. rst-class:: classref-item-separator
----
.. _class_Parallax2D_property_limit_begin:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **limit_begin** = ``Vector2(-10000000, -10000000)`` :ref:`🔗<class_Parallax2D_property_limit_begin>`
.. rst-class:: classref-property-setget
- |void| **set_limit_begin**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_limit_begin**\ (\ )
Top-left limits for scrolling to begin. If the camera is outside of this limit, the **Parallax2D** stops scrolling. Must be lower than :ref:`limit_end<class_Parallax2D_property_limit_end>` minus the viewport size to work.
.. rst-class:: classref-item-separator
----
.. _class_Parallax2D_property_limit_end:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **limit_end** = ``Vector2(10000000, 10000000)`` :ref:`🔗<class_Parallax2D_property_limit_end>`
.. rst-class:: classref-property-setget
- |void| **set_limit_end**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_limit_end**\ (\ )
Bottom-right limits for scrolling to end. If the camera is outside of this limit, the **Parallax2D** will stop scrolling. Must be higher than :ref:`limit_begin<class_Parallax2D_property_limit_begin>` and the viewport size combined to work.
.. rst-class:: classref-item-separator
----
.. _class_Parallax2D_property_repeat_size:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **repeat_size** = ``Vector2(0, 0)`` :ref:`🔗<class_Parallax2D_property_repeat_size>`
.. rst-class:: classref-property-setget
- |void| **set_repeat_size**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_repeat_size**\ (\ )
Repeats the :ref:`Texture2D<class_Texture2D>` of each of this node's children and offsets them by this value. When scrolling, the node's position loops, giving the illusion of an infinite scrolling background if the values are larger than the screen size. If an axis is set to ``0``, the :ref:`Texture2D<class_Texture2D>` will not be repeated.
.. rst-class:: classref-item-separator
----
.. _class_Parallax2D_property_repeat_times:
.. rst-class:: classref-property
:ref:`int<class_int>` **repeat_times** = ``1`` :ref:`🔗<class_Parallax2D_property_repeat_times>`
.. rst-class:: classref-property-setget
- |void| **set_repeat_times**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_repeat_times**\ (\ )
Overrides the amount of times the texture repeats. Each texture copy spreads evenly from the original by :ref:`repeat_size<class_Parallax2D_property_repeat_size>`. Useful for when zooming out with a camera.
.. rst-class:: classref-item-separator
----
.. _class_Parallax2D_property_screen_offset:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **screen_offset** = ``Vector2(0, 0)`` :ref:`🔗<class_Parallax2D_property_screen_offset>`
.. rst-class:: classref-property-setget
- |void| **set_screen_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_screen_offset**\ (\ )
Offset used to scroll this **Parallax2D**. This value is updated automatically unless :ref:`ignore_camera_scroll<class_Parallax2D_property_ignore_camera_scroll>` is ``true``.
.. rst-class:: classref-item-separator
----
.. _class_Parallax2D_property_scroll_offset:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **scroll_offset** = ``Vector2(0, 0)`` :ref:`🔗<class_Parallax2D_property_scroll_offset>`
.. rst-class:: classref-property-setget
- |void| **set_scroll_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_scroll_offset**\ (\ )
The **Parallax2D**'s offset. Similar to :ref:`screen_offset<class_Parallax2D_property_screen_offset>` and :ref:`Node2D.position<class_Node2D_property_position>`, but will not be overridden.
\ **Note:** Values will loop if :ref:`repeat_size<class_Parallax2D_property_repeat_size>` is set higher than ``0``.
.. rst-class:: classref-item-separator
----
.. _class_Parallax2D_property_scroll_scale:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **scroll_scale** = ``Vector2(1, 1)`` :ref:`🔗<class_Parallax2D_property_scroll_scale>`
.. rst-class:: classref-property-setget
- |void| **set_scroll_scale**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_scroll_scale**\ (\ )
Multiplier to the final **Parallax2D**'s offset. Can be used to simulate distance from the camera.
For example, a value of ``1`` scrolls at the same speed as the camera. A value greater than ``1`` scrolls faster, making objects appear closer. Less than ``1`` scrolls slower, making objects appear further, and a value of ``0`` stops the objects completely.
.. |virtual| replace:: :abbr:`virtual (本方法通常需要使用者覆寫才能生效。)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (本方法沒有副作用。不會修改該實例的任何成員變數。)`
.. |vararg| replace:: :abbr:`vararg (本方法除了這裡描述的參數外,還可以接受任意數量的參數。)`
.. |constructor| replace:: :abbr:`constructor (本方法用於建構一個型別。)`
.. |static| replace:: :abbr:`static (本方法無需實例即可呼叫,因此可以直接使用類別名稱呼叫。)`
.. |operator| replace:: :abbr:`operator (本方法描述將本型別作為左運算元時可用的有效運算子。)`
.. |bitfield| replace:: :abbr:`BitField (此值是由下列旗標組成的位元遮罩整數。)`
.. |void| replace:: :abbr:`void (無回傳值。)`