TouchScreenButton

继承: Item < Object

用于应用使用的触摸屏设备按钮。

描述

TouchScreenButton允许您为触摸设备创建屏幕按钮。它旨在用于应用用途,例如您必须触摸才能移动的单元。与Button不同,TouchScreenButton支持开箱即用的多点触控。可以通过触摸输入同时按下多个TouchScreenButton。

Control节点不同,您不能在其上设置锚点。如果要创建菜单或用户界面,您可能希望改用Button节点。要使按钮节点对触摸事件做出反应,您可以在项目设置中启用ProjectSettings.input_devices/pointing/emulate_mouse_from_touch

您可以将TouchScreenButton配置为仅在触摸设备上可见,从而帮助您为桌面和移动设备开发应用。

属性

方法

bool

is_pressed() const


信号

pressed() 🔗

按下(向下)按钮时发出。


released() 🔗

释放按钮时发出(向上)。


枚举

enum VisibilityMode: 🔗

VisibilityMode VISIBILITY_ALWAYS = 0

始终可见。

VisibilityMode VISIBILITY_TOUCHSCREEN_ONLY = 1

仅在触摸屏上可见。


属性说明

String action = "" 🔗

按钮的动作。可以使用InputEventAction处理操作。


BitMap bitmask 🔗

按钮的位掩码。


bool passby_press = false 🔗

  • void set_passby_press(value: bool)

  • bool is_passby_press_enabled()

如果true,则每当被按下的手指进出按钮时,即使压力在按钮的活动区域之外开始,也会发出pressedreleased信号。

注意:这是一种“pass-by”的按压模式 ,而不是“bypass”。


Shape2D shape 🔗

  • void set_shape(value: Shape2D)

  • Shape2D get_shape()

按钮的形状。


bool shape_centered = true 🔗

  • void set_shape_centered(value: bool)

  • bool is_shape_centered()

如果true,则按钮的形状在提供的纹理中居中。如果不使用纹理,则此属性无效。


bool shape_visible = true 🔗

  • void set_shape_visible(value: bool)

  • bool is_shape_visible()

如果true,则按钮的形状在编辑器中可见。


Texture2D texture_normal 🔗

按钮的纹理为正常状态。


Texture2D texture_pressed 🔗

按下状态的按钮纹理。


VisibilityMode visibility_mode = 0 🔗

按钮的可见性模式。有关可能的值,请参阅VisibilityMode


方法说明

bool is_pressed() const 🔗

如果当前按下此按钮,则返回true