touch_button
2d · ui · 9 properties · 2D
An on-screen button that presses an action while a finger is on it, so a game bound to a key on a desktop needs no second code path on a phone. Placed against the screen less its safe area, not in the scene's world.
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 or edge the offset is measured from, 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. |
offset | vec2 | [-110,-110] | From the anchor to the button's centre, in design pixels, x right and y down |
pressed_color | color | [1,1,1,0.5] | Fill while a finger is on it |
shape | enum | circle | The touch area's outline; a circle uses the larger half of the box One of rect, circle. |
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. |