Skip to main content

touch_stick

2d · ui · 11 properties · 2D

An on-screen stick that pushes one action per axis while a thumb drags it, reading -1..1 with y positive away from the player, the way a gamepad's stick does. Placed against the screen less its safe area.

In a scene, touch_stick is the node key that applies it. A script reaches each property below as a field on node.touch_stick: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.touch_stick.get() and node.touch_stick.set(table).

Properties

propertytypedefaultdescription
action_xstringThe action the stick's left and right feed, -1 at the left of its throw
action_ystringThe action the stick's up and down feed, 1 pushed away from the player
anchorenumbottom_leftScreen 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.18]The base circle's fill, as channel floats or #rrggbb / #rrggbbaa
deadzonefloat0.15Fraction of the throw that reads zero, so a resting thumb does not drift; the rest is rescaled so the first live reading is near zero Range 0–0.95.
knob_colorcolor[1,1,1,0.45]The knob's fill
knob_radiusfloat38The knob's own radius in design pixels; drawing only At least 1.
offsetvec2[130,-130]From the anchor to the stick's centre, in design pixels, x right and y down
radiusfloat90The throw in design pixels: how far the knob travels for a full 1, and the circle a thumb may grab it in At least 1.
recenterboolfalseMove the stick's centre to the thumb that grabbed it, so an off-centre grab does not jerk
visibilityenumtouchscreentouchscreen hides it and stops it taking fingers where the platform has no touch screen One of always, touchscreen.