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

163 lines
8.9 KiB
ReStructuredText

:github_url: hide
.. _class_ParallaxBackground:
ParallaxBackground
==================
**已棄用:** Use the :ref:`Parallax2D<class_Parallax2D>` node instead.
**繼承:** :ref:`CanvasLayer<class_CanvasLayer>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
用於建立視差滾動背景的節點。
.. rst-class:: classref-introduction-group
說明
----
ParallaxBackground 使用一個或多個 :ref:`ParallaxLayer<class_ParallaxLayer>` 子節點來建立視差效果。每個 :ref:`ParallaxLayer<class_ParallaxLayer>` 可以使用 :ref:`ParallaxLayer.motion_offset<class_ParallaxLayer_property_motion_offset>` 以不同的速度移動。這在 2D 遊戲中可以創造一種深度錯覺。如果沒有與 :ref:`Camera2D<class_Camera2D>` 一起使用,你必須手動計算 :ref:`scroll_offset<class_ParallaxBackground_property_scroll_offset>`\ 。
\ **注意:**\ 每個 **ParallaxBackground** 都是在各自的 :ref:`Viewport<class_Viewport>` 中繪製的,無法在不同 :ref:`Viewport<class_Viewport>` 之間共用,見 :ref:`CanvasLayer.custom_viewport<class_CanvasLayer_property_custom_viewport>`\ 。在分屏遊戲等使用多個 :ref:`Viewport<class_Viewport>` 的場景下,你需要每個需要繪製的 :ref:`Viewport<class_Viewport>` 建立單獨的 **ParallaxBackground**\ 。
.. rst-class:: classref-reftable-group
屬性
----
.. table::
:widths: auto
+-------------------------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
| :ref:`int<class_int>` | layer | ``-100`` (overrides :ref:`CanvasLayer<class_CanvasLayer_property_layer>`) |
+-------------------------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`scroll_base_offset<class_ParallaxBackground_property_scroll_base_offset>` | ``Vector2(0, 0)`` |
+-------------------------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`scroll_base_scale<class_ParallaxBackground_property_scroll_base_scale>` | ``Vector2(1, 1)`` |
+-------------------------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`scroll_ignore_camera_zoom<class_ParallaxBackground_property_scroll_ignore_camera_zoom>` | ``false`` |
+-------------------------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`scroll_limit_begin<class_ParallaxBackground_property_scroll_limit_begin>` | ``Vector2(0, 0)`` |
+-------------------------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`scroll_limit_end<class_ParallaxBackground_property_scroll_limit_end>` | ``Vector2(0, 0)`` |
+-------------------------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`scroll_offset<class_ParallaxBackground_property_scroll_offset>` | ``Vector2(0, 0)`` |
+-------------------------------+-----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
屬性說明
--------
.. _class_ParallaxBackground_property_scroll_base_offset:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **scroll_base_offset** = ``Vector2(0, 0)`` :ref:`🔗<class_ParallaxBackground_property_scroll_base_offset>`
.. rst-class:: classref-property-setget
- |void| **set_scroll_base_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_scroll_base_offset**\ (\ )
所有 :ref:`ParallaxLayer<class_ParallaxLayer>` 子元素的基本位置偏移。
.. rst-class:: classref-item-separator
----
.. _class_ParallaxBackground_property_scroll_base_scale:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **scroll_base_scale** = ``Vector2(1, 1)`` :ref:`🔗<class_ParallaxBackground_property_scroll_base_scale>`
.. rst-class:: classref-property-setget
- |void| **set_scroll_base_scale**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_scroll_base_scale**\ (\ )
所有 :ref:`ParallaxLayer<class_ParallaxLayer>` 子元素的基本移動比例。
.. rst-class:: classref-item-separator
----
.. _class_ParallaxBackground_property_scroll_ignore_camera_zoom:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **scroll_ignore_camera_zoom** = ``false`` :ref:`🔗<class_ParallaxBackground_property_scroll_ignore_camera_zoom>`
.. rst-class:: classref-property-setget
- |void| **set_ignore_camera_zoom**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_ignore_camera_zoom**\ (\ )
``true`` 時,\ :ref:`ParallaxLayer<class_ParallaxLayer>` 子元素將不受相機縮放級別的影響。
.. rst-class:: classref-item-separator
----
.. _class_ParallaxBackground_property_scroll_limit_begin:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **scroll_limit_begin** = ``Vector2(0, 0)`` :ref:`🔗<class_ParallaxBackground_property_scroll_limit_begin>`
.. rst-class:: classref-property-setget
- |void| **set_limit_begin**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_limit_begin**\ (\ )
開始滾動的左上角限制。如果相機超出這個限制,背景將停止滾動。必須低於 :ref:`scroll_limit_end<class_ParallaxBackground_property_scroll_limit_end>` 才能工作。
.. rst-class:: classref-item-separator
----
.. _class_ParallaxBackground_property_scroll_limit_end:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **scroll_limit_end** = ``Vector2(0, 0)`` :ref:`🔗<class_ParallaxBackground_property_scroll_limit_end>`
.. rst-class:: classref-property-setget
- |void| **set_limit_end**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_limit_end**\ (\ )
右下角限制滾動結束。如果相機超出這個限制,背景將停止滾動。必須高於 :ref:`scroll_limit_begin<class_ParallaxBackground_property_scroll_limit_begin>` 才能工作。
.. rst-class:: classref-item-separator
----
.. _class_ParallaxBackground_property_scroll_offset:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **scroll_offset** = ``Vector2(0, 0)`` :ref:`🔗<class_ParallaxBackground_property_scroll_offset>`
.. rst-class:: classref-property-setget
- |void| **set_scroll_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_scroll_offset**\ (\ )
視差背景的滾動值。使用 :ref:`Camera2D<class_Camera2D>` 時會自動計算,但也可用於手動管理無相機時的滾動。
.. |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 (無回傳值。)`