natiny.input.get_touch_count
natiny.input.get_touch_count() -> count
Returns the number of touch identifiers available in the current frame. The count includes touches released during this frame.
Returns
| Type | Description |
|---|---|
number |
Number of available touch identifiers, from 0 to 24 |
Example
for i = 0, natiny.input.get_touch_count() - 1 do
local touch = natiny.input.get_touch_at(i)
natiny.render.circle(natiny.input.get_touch_x(touch),
natiny.input.get_touch_y(touch), 24)
end
Notes
- The count remains fixed for the current frame. A touch that starts during a frame appears in the next frame.
- A released touch remains in the list for its release frame. This preserves a
tap that starts and ends between two frames. See
natiny.input.get_touch_released. - Pass each index to
natiny.input.get_touch_at. The other touch functions take the returned identifier, not the index. - Natiny tracks at most 24 touches. Additional touches are ignored until a slot becomes available.
- Touch input is available on Android and in touch-enabled browsers. Other
platforms return
0. - The first active touch is also reported as the left mouse button. Do not process both APIs unless duplicate input is intended.