Skip to main content

Touch

Description:

  Provides an interface to touch-screen presses.

getTouches

Type: Function.

Description:

  Gets a list of all active touch-presses. Overload details:

  1. The id values are the same as those used as arguments to love.touchpressed, love.touchmoved, and love.touchreleased. The id value of a specific touch-press is only guaranteed to be unique for the duration of that touch-press. As soon as love.touchreleased is called using that id, it may be reused for a new touch-press via love.touchpressed.

Signature:

getTouches: function(): {TouchID}

Returns:

Return TypeDescription
{TouchID}A list of active touch-press id values, which can be used with love.touch.getPosition.

getPosition

Type: Function.

Description:

  Gets the current position of the specified touch-press, in pixels. Overload details:

  1. The unofficial Android and iOS ports of LÖVE 0.9.2 reported touch-press positions as normalized values in the range of 1, whereas this API reports positions in pixels.

Signature:

getPosition: function(id: TouchID): number, number

Parameters:

ParameterTypeDescription
idTouchIDThe identifier of the touch-press. Use love.touch.getTouches, love.touchpressed, or love.touchmoved to obtain touch id values.

Returns:

Return TypeDescription
numberThe position along the x-axis of the touch-press inside the window, in pixels.
numberThe position along the y-axis of the touch-press inside the window, in pixels.

getPressure

Type: Function.

Description:

  Gets the current pressure of the specified touch-press.

Signature:

getPressure: function(id: TouchID): number

Parameters:

ParameterTypeDescription
idTouchIDThe identifier of the touch-press. Use love.touch.getTouches, love.touchpressed, or love.touchmoved to obtain touch id values.

Returns:

Return TypeDescription
numberThe pressure of the touch-press. Most touch screens aren't pressure sensitive, in which case the pressure will be 1.