natiny.input.get_touch_x

Lua
natiny.input.get_touch_x(touch) -> x

Returns the touch position on the x axis in the window's current drawing units.

Parameters

Name Type Description
touch number Touch identifier from natiny.input.get_touch_at

Returns

Type Description
number Position in drawing units from the window's left edge, or 0 for an invalid identifier

Example

Lua
for index = 0, natiny.input.get_touch_count() - 1 do
    local touch = natiny.input.get_touch_at(index)
    natiny.render.circle(natiny.input.get_touch_x(touch),
                         natiny.input.get_touch_y(touch), 24)
end

Notes

  • The value uses the window's scale mode, not physical pixels. It uses the same coordinate system as natiny.input.get_mouse_x and 2D drawing calls.
  • The value remains fixed for the current frame. Movement during a frame is visible in the next frame.
  • See also natiny.input.get_touch_x_speed.
  • Touch input is available on Android and in touch-enabled browsers.