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...
TouchScreenButton
繼承: Node2D < CanvasItem < Node < Object
觸控式螢幕裝置的按鈕,供遊戲使用。
說明
TouchScreenButton allows you to create on-screen buttons for touch devices. It's intended for gameplay use, such as a unit you have to touch to move. Unlike Button, TouchScreenButton supports multitouch out of the box. Several TouchScreenButtons can be pressed at the same time with touch input.
This node inherits from Node2D. Unlike with Control nodes, you cannot set anchors on it. If you want to create menus or user interfaces, you may want to use Button nodes instead. To make button nodes react to touch events, you can enable ProjectSettings.input_devices/pointing/emulate_mouse_from_touch in the Project Settings.
You can configure TouchScreenButton to be visible only on touch devices, helping you develop your game both for desktop and mobile devices.
屬性
|
||
|
||
|
||
|
||
|
方法
is_pressed() const |
訊號
pressed() 🔗
當按鈕被按下時觸發,即向下。
released() 🔗
當按鈕被釋放時觸發,即向上。
列舉
enum VisibilityMode: 🔗
VisibilityMode VISIBILITY_ALWAYS = 0
始終可見。
VisibilityMode VISIBILITY_TOUCHSCREEN_ONLY = 1
僅在觸控式螢幕上可以看到。
屬性說明
按鈕的動作。動作可以用 InputEventAction 來處理。
按鈕的位元遮罩。
如果為 true,只要按下的手指進出按鈕,就會發出 pressed 和 released 訊號,即使壓力開始於按鈕的有效區域之外。
注意:這是一種“pass-by”的按壓模式 ,而不是“bypass”。
該按鈕的形狀。
如果為 true,按鈕的形狀會在提供的紋理中居中。如果沒有使用紋理,這個屬性就沒有效果。
如果為 true,則該按鈕的形狀在編輯器中可見。
該按鈕在正常狀態下的紋理。
按鈕在被按下狀態時的紋理。
VisibilityMode visibility_mode = 0 🔗
void set_visibility_mode(value: VisibilityMode)
VisibilityMode get_visibility_mode()
The button's visibility mode.
方法說明
如果這個按鈕目前被按下,則返回 true。