Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
AspectRatioContainer
繼承: Container < Control < CanvasItem < Node < Object
保留子控制項長寬比的容器。
說明
一種容器類型,會在容器大小改變時自動保持子控制項比例。當容器尺寸為動態,且子節點必須隨之調整大小而又不能失去長寬比時特別實用。
教學
屬性
|
||
|
||
|
||
|
列舉
enum StretchMode: 🔗
StretchMode STRETCH_WIDTH_CONTROLS_HEIGHT = 0
子控制項的高度會根據容器寬度自動調整。
StretchMode STRETCH_HEIGHT_CONTROLS_WIDTH = 1
子控制項的寬度會根據容器高度自動調整。
StretchMode STRETCH_FIT = 2
子控制項的邊界矩形會自動調整以符合容器,同時保持長寬比。
StretchMode STRETCH_COVER = 3
子控制項的寬度與高度會自動調整,使其邊界矩形在保持長寬比的同時覆蓋整個容器區域。
當子控制項的邊界矩形超出容器大小,且啟用 Control.clip_contents 時,僅會顯示受自身邊界矩形限制的容器區域。
enum AlignmentMode: 🔗
AlignmentMode ALIGNMENT_BEGIN = 0
將子控制項與容器的起始處(左側或上方)對齊。
AlignmentMode ALIGNMENT_CENTER = 1
將子控制項與容器中心對齊。
AlignmentMode ALIGNMENT_END = 2
將子控制項與容器的末端(右側或底部)對齊。
屬性說明
AlignmentMode alignment_horizontal = 1 🔗
void set_alignment_horizontal(value: AlignmentMode)
AlignmentMode get_alignment_horizontal()
指定子控制項的水平相對位置。
AlignmentMode alignment_vertical = 1 🔗
void set_alignment_vertical(value: AlignmentMode)
AlignmentMode get_alignment_vertical()
指定子控制項的垂直相對位置。
對子控制項強制套用的長寬比,為寬度除以高度,其實際效果取決於 stretch_mode。
StretchMode stretch_mode = 2 🔗
void set_stretch_mode(value: StretchMode)
StretchMode get_stretch_mode()
用來對齊子控制項的拉伸模式。