touch_button
An on-screen button that presses an action while a finger is on it. anchor, x and y place it inside the screen's safe area, as they place a widget.
Op deze pagina
2d · ui · 10 properties · 2D
An on-screen button that presses an action while a finger is on it. anchor, x and y place it inside the screen's safe area, as they place a widget.
In a scene, touch_button is the node key that applies it. A script reaches each property below as a field on node.touch_button: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.touch_button.get() and node.touch_button.set(table).
Properties
| property | type | default | description |
|---|---|---|---|
action |
string | — | The action a finger on this button presses, as [input.actions] names it; the action needs no touch binding |
anchor |
enum | bottom_right |
Screen corner, edge or middle the button sits against, inside the safe area One of top_left, center_top, top_right, center_left, center, center_right, bottom_left, center_bottom, bottom_right. |
color |
color | [1,1,1,0.25] |
Fill while nothing is on it, as channel floats or #rrggbb / #rrggbbaa |
height |
float | 120 |
Touch area height in design pixels At least 0. |
kind |
enum | circle |
The touch area's outline; a circle uses the larger half of the box One of rectangle, circle. |
pressed_color |
color | [1,1,1,0.5] |
Fill while a finger is on it |
visibility |
enum | touchscreen |
touchscreen hides it and stops it taking fingers where the platform has no touch screen One of always, touchscreen. |
width |
float | 120 |
Touch area width in design pixels At least 0. |
x |
float | 50 |
Inward from the anchored side to the button's own, in design pixels; from the middle when the anchor centres it |
y |
float | 50 |
Inward from the anchored top or bottom to the button's own, in design pixels; from the middle when the anchor centres it |