When to use this skill
Provides an interface to touch-screen presses. Use this skill when working with touch operations, multi-touch gestures, touch events, or any touch-related operations in LÖVE games.
Common use cases
- Handling touch screen input
- Implementing multi-touch gestures
- Working with touch-based game controls
- Managing touch events and callbacks
- Supporting mobile touch interfaces
Functions
love.touch.getPosition(id: light userdata) -> x: number, y: number: Gets the current position of the specified touch-press, in pixels.
love.touch.getPressure(id: light userdata) -> pressure: number: Gets the current pressure of the specified touch-press.
love.touch.getTouches() -> touches: table: Gets a list of all active touch-presses.
Examples
Handling touch input
function love.touchpressed(id, x, y, dx, dy, pressure)
-- Store touch position
touches[id] = {x = x, y = y, pressure = pressure}
-- Handle touch at position (x, y)
handleTouchAt(x, y)
end
Multi-touch handling
function love.touchmoved(id, x, y, dx, dy, pressure)
if touches[id] then
-- Update touch position
touches[id].x = x
touches[id].y = y
-- Handle drag gesture
handleDrag(id, dx, dy)
end
end
function love.touchreleased(id, x, y, dx, dy, pressure)
-- Remove touch
touches[id] = nil
end
Best practices
- Support both touch and mouse input for cross-platform compatibility
- Handle multi-touch gestures appropriately
- Consider touch interface design for mobile devices
- Test touch input on target platforms
- Be mindful of touch accuracy and precision
Platform compatibility
- Desktop (Windows, macOS, Linux): Touch support on touchscreen devices
- Mobile (iOS, Android): Full multi-touch support
- Web: Browser-based touch support
1---2name: love-touch3description: Provides an interface to touch-screen presses. Use this skill when working with touch operations, multi-touch gestures, touch events, or any touch-related operations in LÖVE games.4license: MIT5---67## When to use this skill8Provides an interface to touch-screen presses. Use this skill when working with touch operations, multi-touch gestures, touch events, or any touch-related operations in LÖVE games.910## Common use cases11- Handling touch screen input12- Implementing multi-touch gestures13- Working with touch-based game controls14- Managing touch events and callbacks15- Supporting mobile touch interfaces1617## Functions1819- `love.touch.getPosition(id: light userdata) -> x: number, y: number`: Gets the current position of the specified touch-press, in pixels.20- `love.touch.getPressure(id: light userdata) -> pressure: number`: Gets the current pressure of the specified touch-press.21- `love.touch.getTouches() -> touches: table`: Gets a list of all active touch-presses.2223## Examples2425### Handling touch input26```lua27function love.touchpressed(id, x, y, dx, dy, pressure)28 -- Store touch position29 touches[id] = {x = x, y = y, pressure = pressure}3031 -- Handle touch at position (x, y)32 handleTouchAt(x, y)33end34```3536### Multi-touch handling37```lua38function love.touchmoved(id, x, y, dx, dy, pressure)39 if touches[id] then40 -- Update touch position41 touches[id].x = x42 touches[id].y = y4344 -- Handle drag gesture45 handleDrag(id, dx, dy)46 end47end4849function love.touchreleased(id, x, y, dx, dy, pressure)50 -- Remove touch51 touches[id] = nil52end53```5455## Best practices56- Support both touch and mouse input for cross-platform compatibility57- Handle multi-touch gestures appropriately58- Consider touch interface design for mobile devices59- Test touch input on target platforms60- Be mindful of touch accuracy and precision6162## Platform compatibility63- **Desktop (Windows, macOS, Linux)**: Touch support on touchscreen devices64- **Mobile (iOS, Android)**: Full multi-touch support65- **Web**: Browser-based touch support