Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

TextureProgressBar

继承: Range < Control < CanvasItem < Node < Object

基于纹理的进度条。适用于加载屏幕和生命或体力条。

描述

TextureProgressBar 的工作方式类似于 ProgressBar,但最多使用 3 个纹理,不使用 Godot 的 Theme 资源。可用于创建水平、垂直和径向进度条。

属性

int

fill_mode

0

MouseFilter

mouse_filter

1 (overrides Control)

bool

nine_patch_stretch

false

Vector2

radial_center_offset

Vector2(0, 0)

float

radial_fill_degrees

360.0

float

radial_initial_angle

0.0

BitField<SizeFlags>

size_flags_vertical

1 (overrides Control)

float

step

1.0 (overrides Range)

int

stretch_margin_bottom

0

int

stretch_margin_left

0

int

stretch_margin_right

0

int

stretch_margin_top

0

Texture2D

texture_over

Texture2D

texture_progress

Vector2

texture_progress_offset

Vector2(0, 0)

Texture2D

texture_under

Color

tint_over

Color(1, 1, 1, 1)

Color

tint_progress

Color(1, 1, 1, 1)

Color

tint_under

Color(1, 1, 1, 1)

方法

int

get_stretch_margin ( Side margin ) const

void

set_stretch_margin ( Side margin, int value )


枚举

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_offsetradial_initial_angleradial_fill_degrees来控制条形填充的方式。

FillMode FILL_COUNTER_CLOCKWISE = 5

将节点变成径向条形。texture_progress逆时针填充。参阅radial_center_offsetradial_initial_angleradial_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_offsetradial_initial_angleradial_fill_degrees来控制条形填充的方式。


属性说明

int fill_mode = 0

  • void set_fill_mode ( int value )

  • int get_fill_mode ( )

填充方向。可能的取值见 FillMode


bool nine_patch_stretch = false

  • void set_nine_patch_stretch ( bool value )

  • bool get_nine_patch_stretch ( )

如果为 true,Godot 会像在 NinePatchRect 中那样处理条形纹理。使用 stretch_margin_* 属性,如 stretch_margin_bottom 来设置九宫格的 3×3 网格。当使用径向的 fill_mode 时,这个设置将启用拉伸功能。


Vector2 radial_center_offset = Vector2(0, 0)

  • void set_radial_center_offset ( Vector2 value )

  • Vector2 get_radial_center_offset ( )

如果fill_modeFILL_CLOCKWISEFILL_COUNTER_CLOCKWISE,则对texture_progress进行偏移。


float radial_fill_degrees = 360.0

  • void set_fill_degrees ( float value )

  • float get_fill_degrees ( )

如果fill_modeFILL_CLOCKWISEFILL_COUNTER_CLOCKWISE,则为texture_progress的填充上限。当节点的value等于其max_value时,纹理会填充到这个角度。

参阅Range.value, Range.max_value


float radial_initial_angle = 0.0

  • void set_radial_initial_angle ( float value )

  • float get_radial_initial_angle ( )

如果fill_modeFILL_CLOCKWISEFILL_COUNTER_CLOCKWISEtexture_progress的填充起始角度。当节点的value等于其min_value时,纹理根本不会显示出来。当value增加时,纹理会被填满并趋向于radial_fill_degrees


int stretch_margin_bottom = 0

  • void set_stretch_margin ( Side margin, int value )

  • int get_stretch_margin ( Side margin ) const

九宫格底行的高度。边距为 16 意味着九宫格的底角和侧面将有 16 像素的高度。你可以单独设置所有 4 个边距值,来创建具有非统一边框的面板。


int stretch_margin_left = 0

  • void set_stretch_margin ( Side margin, int value )

  • int get_stretch_margin ( Side margin ) const

九宫格左列的宽度。


int stretch_margin_right = 0

  • void set_stretch_margin ( Side margin, int value )

  • int get_stretch_margin ( Side margin ) const

九宫格右列的宽度。


int stretch_margin_top = 0

  • void set_stretch_margin ( Side margin, int value )

  • int get_stretch_margin ( Side margin ) const

九宫格顶行的高度。


Texture2D texture_over

在进度条至上绘制的 Texture2D。可用于添加高光,也可用于添加遮挡部分 texture_progress 的上层边框。


Texture2D texture_progress

被裁剪的 Texture2D。裁剪基于该节点的 valuefill_mode。随着 value 的增加,该纹理将被填满。当 value 达到 max_value 时,它将完整显示。如果 value 等于 min_value,则它根本不显示。

value 属性来自 Range。参见 Range.valueRange.min_valueRange.max_value


Vector2 texture_progress_offset = Vector2(0, 0)

  • void set_texture_progress_offset ( Vector2 value )

  • Vector2 get_texture_progress_offset ( )

texture_progress 的偏移量。对于带有花哨的边框的 texture_overtexture_under 很有用,可以避免进度纹理的边缘透明。


Texture2D texture_under

在进度条下绘制的 Texture2D。该进度条的背景。


Color tint_over = Color(1, 1, 1, 1)

  • void set_tint_over ( Color value )

  • Color get_tint_over ( )

将与该进度条的 texture_over 纹理的颜色相乘。其效果类似于 CanvasItem.modulate ,只是它只影响这个特定的纹理,而不是整个节点。


Color tint_progress = Color(1, 1, 1, 1)

  • void set_tint_progress ( Color value )

  • Color get_tint_progress ( )

将与该进度条的 texture_progress 纹理的颜色相乘。


Color tint_under = Color(1, 1, 1, 1)

  • void set_tint_under ( Color value )

  • Color get_tint_under ( )

将与该进度条的 texture_under 纹理的颜色相乘。


方法说明

int get_stretch_margin ( Side margin ) const

返回给定索引的拉伸边距。见 stretch_margin_bottom 及相关属性。


void set_stretch_margin ( Side margin, int value )

设置给定索引的拉伸边距。见 stretch_margin_bottom 及相关属性。