CharFXTransform¶
控制单个字符在RichTextEffect中的显示方式。
描述¶
通过在此对象上设置各种属性,可以控制单个字符在RichTextEffect中的显示方式。
教程¶
属性¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
属性说明¶
int absolute_index
Default |
|
Setter |
set_absolute_index(value) |
Getter |
get_absolute_index() |
当前字符的索引(从0开始)。设置此属性不会影响图形。
int character
Default |
|
Setter |
set_character(value) |
Getter |
get_character() |
字符所使用的 Unicode 码位。这只会影响非空白字符。@GDScript.ord 在这里可能很有用。例如,以下将用星号替换所有字符:
# `char_fx` 是 `_process_custom_fx()` 的 CharFXTransform 参数。
# 详情请参阅 RichTextEffect 的文档。
char_fx.character = ord("*")
Color color
Default |
|
Setter |
set_color(value) |
Getter |
get_color() |
绘制角色所用的颜色。
float elapsed_time
Default |
|
Setter |
set_elapsed_time(value) |
Getter |
get_elapsed_time() |
自RichTextLabel被添加到场景树后所经过的时间,单位秒。时间在RichTextLabel暂停时停止,参阅Node.pause_mode。当RichTextLabel中的文本改变时,会重新设置。
注意: 当RichTextLabel被隐藏时,时间仍会增加。
Dictionary env
Default |
|
Setter |
set_environment(value) |
Getter |
get_environment() |
包含在开头的BBCode标记中传递的参数。默认情况下,参数是字符串。如果它们的内容与bool,int或float之类的类型匹配,它们将被自动转换。格式为#rrggbb
或#rgb
的颜色代码将转换为不透明的Color。字符串参数即使使用引号也不能包含空格。如果存在,引号也将出现在最终字符串中。
例如,开头的BBCode标签[example foo = hello bar = true baz = 42 color =#ffffff]
将映射到以下Dictionary:
{"foo": "hello", "bar": true, "baz": 42, "color": Color(1, 1, 1, 1)}
Vector2 offset
Default |
|
Setter |
set_offset(value) |
Getter |
get_offset() |
绘制字符的位置偏移量(以像素为单位)。
int relative_index
Default |
|
Setter |
set_relative_index(value) |
Getter |
get_relative_index() |
当前字符的索引(从0开始)。设置此属性不会影响图形。
bool visible
Default |
|
Setter |
set_visibility(value) |
Getter |
is_visible() |
如果true
,将绘制字符。如果false
,则隐藏字符。隐藏字符周围的字符将回流以占用隐藏字符的空间。如果不希望这样做,可以将它们的color设置为Color(1, 1, 1, 0)
。