TextureButton
继承: BaseButton
< Control
< CanvasItem
< Node
< Object
Texture-based button. Supports Pressed, Hover, Disabled and Focused states.
描述
TextureButton has the same functionality as Button
, except it uses sprites instead of Godot's Theme
resource. It is faster to create, but it doesn't support localization like more complex Control
s.
The "normal" state must contain a texture (texture_normal
); other textures are optional.
See also BaseButton
which contains common properties and methods associated with this node.
属性
枚举
enum StretchMode:
StretchMode STRETCH_SCALE = 0
Scale to fit the node's bounding rectangle.
StretchMode STRETCH_TILE = 1
Tile inside the node's bounding rectangle.
StretchMode STRETCH_KEEP = 2
The texture keeps its original size and stays in the bounding rectangle's top-left corner.
StretchMode STRETCH_KEEP_CENTERED = 3
The texture keeps its original size and stays centered in the node's bounding rectangle.
StretchMode STRETCH_KEEP_ASPECT = 4
Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.
StretchMode STRETCH_KEEP_ASPECT_CENTERED = 5
Scale the texture to fit the node's bounding rectangle, center it, and maintain its aspect ratio.
StretchMode STRETCH_KEEP_ASPECT_COVERED = 6
Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.
属性说明
bool
flip_h = false
If true
, texture is flipped horizontally.
bool
flip_v = false
If true
, texture is flipped vertically.
bool
ignore_texture_size = false
If true
, the size of the texture won't be considered for minimum size calculation, so the TextureButton can be shrunk down past the texture size.
StretchMode stretch_mode = 2
void
set_stretch_mode ( value: StretchMode )- StretchMode get_stretch_mode ( )
Controls the texture's behavior when you resize the node's bounding rectangle. See the StretchMode constants for available options.
BitMap
texture_click_mask
Pure black and white BitMap
image to use for click detection. On the mask, white pixels represent the button's clickable area. Use it to create buttons with curved shapes.
Texture2D
texture_disabled
Texture to display when the node is disabled. See BaseButton.disabled
.
Texture2D
texture_focused
Texture to display when the node has mouse or keyboard focus. texture_focused
is displayed over the base texture, so a partially transparent texture should be used to ensure the base texture remains visible. A texture that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a fully transparent texture of any size. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
Texture2D
texture_hover
Texture to display when the mouse hovers the node.
Texture2D
texture_normal
Texture to display by default, when the node is not in the disabled, hover or pressed state. This texture is still displayed in the focused state, with texture_focused
drawn on top.
Texture2D
texture_pressed
Texture to display on mouse down over the node, if the node has keyboard focus and the player presses the Enter key or if the player presses the BaseButton.shortcut
key.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。