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...
TextureProgressBar
继承: Range < Control < CanvasItem < Node < Object
基于纹理的进度条。适用于加载屏幕和生命或体力条。
描述
TextureProgressBar 的工作方式类似于 ProgressBar,但最多使用 3 个纹理,不使用 Godot 的 Theme 资源。可用于创建水平、垂直和径向进度条。
属性
|
||
mouse_filter |
|
|
|
||
|
||
|
||
|
||
BitField[SizeFlags] |
size_flags_vertical |
|
step |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
get_stretch_margin(margin: Side) const |
|
void |
set_stretch_margin(margin: Side, value: int) |
枚举
enum FillMode: 🔗
FillMode FILL_LEFT_TO_RIGHT = 0
texture_progress 从左到右填充。
FillMode FILL_RIGHT_TO_LEFT = 1
texture_progress 从右到左填充。
FillMode FILL_TOP_TO_BOTTOM = 2
texture_progress 从上到下填充。
FillMode FILL_BOTTOM_TO_TOP = 3
texture_progress 自下而上填充。
FillMode FILL_CLOCKWISE = 4
将节点变成径向条形。texture_progress 顺时针填充。参阅radial_center_offset、radial_initial_angle和radial_fill_degrees来控制条形填充的方式。
FillMode FILL_COUNTER_CLOCKWISE = 5
将节点变成径向条形。texture_progress逆时针填充。参阅radial_center_offset、radial_initial_angle和radial_fill_degrees来控制条形填充的方式。
FillMode FILL_BILINEAR_LEFT_AND_RIGHT = 6
texture_progress从中心开始填充,向左和向右扩展。
FillMode FILL_BILINEAR_TOP_AND_BOTTOM = 7
texture_progress从中心开始填充,同时向顶部和底部扩展。
FillMode FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE = 8
将节点变成径向条形。texture_progress从中心径向填充,顺时针和逆时针扩展。参阅radial_center_offset、radial_initial_angle和radial_fill_degrees来控制条形填充的方式。
属性说明
填充方向。可能的取值见 FillMode。
bool nine_patch_stretch = false
🔗
如果为 true
,Godot 会像在 NinePatchRect 中那样处理进度条的纹理。请使用 stretch_margin_bottom 等 stretch_margin_*
属性来设置九宫格的 3×3 网格。当使用径向的 fill_mode 时,该设置将为 texture_progress 启用拉伸,texture_under 和 texture_over 则进行类似于 NinePatchRect 的处理。
Vector2 radial_center_offset = Vector2(0, 0)
🔗
fill_mode 为 FILL_CLOCKWISE、FILL_COUNTER_CLOCKWISE 或 FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE 时, texture_progress 的偏移。
注意:有效的径向中心始终保持在 texture_progress 的范围内。如果需要将其移动到纹理的边界之外,请修改 texture_progress,让该纹理包含所需的额外空白空间。
float radial_fill_degrees = 360.0
🔗
fill_mode 为 FILL_CLOCKWISE、FILL_COUNTER_CLOCKWISE 或 FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE 时, texture_progress 的填充上限。当节点的 value
等于其 max_value
时,则纹理将会填充到这个角度。
见 Range.value、Range.max_value。
float radial_initial_angle = 0.0
🔗
fill_mode 为 FILL_CLOCKWISE、FILL_COUNTER_CLOCKWISE 或 FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE 时,texture_progress 填充的起始角度。当节点的 value
等于其 min_value
时,纹理根本不会显示出来。当 value
增加时,纹理填充并趋向于 radial_fill_degrees。
注意:radial_initial_angle 会在 0
到 360
度之间环绕(包含两端)。
int stretch_margin_bottom = 0
🔗
九宫格底部一行的高度。边距为 16 意味着九宫格的底角和侧面将有 16 像素的高度。你可以单独设置所有 4 个边距值,来创建边框不均一的面板。仅在 nine_patch_stretch 为 true
时有效。
九宫格左侧一列的宽度。仅在 nine_patch_stretch 为 true
时有效。
int stretch_margin_right = 0
🔗
九宫格右侧一列的宽度。仅在 nine_patch_stretch 为 true
时有效。
九宫格顶部一行的高度。仅在 nine_patch_stretch 为 true
时有效。
在进度条至上绘制的 Texture2D。可用于添加高光,也可用于添加遮挡部分 texture_progress 的上层边框。
被裁剪的 Texture2D。裁剪基于该节点的 value
和 fill_mode。随着 value
的增加,该纹理将被填满。当 value
达到 max_value
时,它将完整显示。如果 value
等于 min_value
,则它根本不显示。
value
属性来自 Range。参见 Range.value、Range.min_value、Range.max_value。
Vector2 texture_progress_offset = Vector2(0, 0)
🔗
texture_progress 的偏移量。对于带有花哨的边框的 texture_over 和 texture_under 很有用,可以避免进度纹理的边缘透明。
在进度条下绘制的 Texture2D。该进度条的背景。
Color tint_over = Color(1, 1, 1, 1)
🔗
将与该进度条的 texture_over 纹理的颜色相乘。其效果类似于 CanvasItem.modulate ,只是它只影响这个特定的纹理,而不是整个节点。
Color tint_progress = Color(1, 1, 1, 1)
🔗
将与该进度条的 texture_progress 纹理的颜色相乘。
Color tint_under = Color(1, 1, 1, 1)
🔗
将与该进度条的 texture_under 纹理的颜色相乘。
方法说明
int get_stretch_margin(margin: Side) const 🔗
返回给定索引的拉伸边距。见 stretch_margin_bottom 及相关属性。
void set_stretch_margin(margin: Side, value: int) 🔗
设置给定索引的拉伸边距。见 stretch_margin_bottom 及相关属性。