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 ( AlignmentMode value )
AlignmentMode get_alignment_horizontal ( )
指定子控件的水平相对位置。
AlignmentMode alignment_vertical = 1
void set_alignment_vertical ( AlignmentMode value )
AlignmentMode get_alignment_vertical ( )
指定子控件的垂直相对位置。
float ratio = 1.0
对子控件强制实施的长宽比。这是宽度除以高度。这个比例取决于 stretch_mode。
StretchMode stretch_mode = 2
void set_stretch_mode ( StretchMode value )
StretchMode get_stretch_mode ( )
用来对齐子控件的拉伸模式。