Skip to main content

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

propertytypedefaultdescription
actionstringThe action a finger on this button presses, as [input.actions] names it; the action needs no touch binding
anchorenumbottom_rightScreen 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.
colorcolor[1,1,1,0.25]Fill while nothing is on it, as channel floats or #rrggbb / #rrggbbaa
heightfloat120Touch area height in design pixels At least 0.
offsetvec2[-110,-110]From the anchor to the button's centre, in design pixels, x right and y down
pressed_colorcolor[1,1,1,0.5]Fill while a finger is on it
shapeenumcircleThe touch area's outline; a circle uses the larger half of the box One of rect, circle.
visibilityenumtouchscreentouchscreen hides it and stops it taking fingers where the platform has no touch screen One of always, touchscreen.
widthfloat120Touch area width in design pixels At least 0.