Skip to content

Search

Documentation

touch_button

An on-screen button that presses an action while a finger is on it. anchor and offset place it inside the screen's safe area.

On this page

2d · ui · 9 properties · 2D

An on-screen button that presses an action while a finger is on it. anchor and offset place it inside the screen's safe area.

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.
kind enum circle The touch area's outline; a circle uses the larger half of the box One of rectangle, circle.
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
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.