TouchPanel - stingray.TouchPanel namespace reference - Stingray Lua API Reference

stingray.TouchPanel namespace reference

Description

Deprecated; use stingray.TouchPanel1.

Functions

Parameters
This function does not accept any parameters.
Returns

stingray.Vector3

The accelerator resolution for the controller.

Parameters
This function does not accept any parameters.
Returns

boolean

Returns true if the controller is active, or false otherwise.

Parameters
This function does not accept any parameters.
Returns

boolean

Returns true if the controller was attached this frame, or false otherwise.

Parameters
This function does not accept any parameters.
Returns

boolean

Returns true if the controller was disconnected this frame, or false otherwise.

Parameters
This function does not accept any parameters.
Returns

string

A string that contains a unique name for the controller.

In most cases this name will be a variant of the string returned by type(), with an additional counter added.

Parameters
This function does not accept any parameters.
Returns

string

A string that describes the type of the controller device.

This identifier will be the same for all controllers of the same model (with some exceptions): e.g. xbox_controller, logitech_mx518_mouse or generic_105_key_keyboard. Note that this value may be the same regardless of the input device model on some platforms.

Buttons and axes

The functions in this group relate to getting values from the buttons and axes tracked by this controller.

Parameters
This function does not accept any parameters.
Returns

integer?

The id of the first button that the player pressed this frame, or nil if the player did not press any buttons.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

If so, returns the id of the first button the player pressed.

Parameters
This function does not accept any parameters.
Returns

integer?

The id of the first button that the player released this frame, or nil if the player did not release any buttons.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

If so, returns the id of the first button the player released.

Parameters

id :

integer

The id of the axis whose value will be retrieved.

dead_zone_mode :

integer?

Specifies the kind of dead zone to be applied before returning the value read from the controller. This value may be any of the dead zone mode constants. If you specify this parameter, you must also specify the dead_zone_size. If omitted, the default dead zone values you set using [InputController.set_dead_zone()] are used.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

dead_zone_size :

number?

The size of the dead zone to apply to the value read from the controller.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns

stingray.Vector3

The input value of the controller for the axis with the specified id.

Note that the dead zone configuration controls are only available for non-touch interfaces.

Parameters

name :

string

The name of the axis whose id you want to retrieve.

Returns

integer

The id of the axis, or nil if no axis is found with a matching name.

Parameters

id :

integer

The id of the axis whose name you want to retrieve.

Returns

string

The name of the axis.

Parameters

id :

integer

The id of the button whose value you want to retrieve.

Returns

number

The current value of the button, expressed as a value between 0 and 1.

Parameters

name :

string

The name of the button whose id you want to retrieve.

Returns

integer

The id of the button, or nil if no button is found with a matching name.

Parameters

id :

integer

The id of the button whose name you want to retrieve.

Returns

string

The name of the button, or an empty string if no button is found with a matching id.

Parameters
This function does not accept any parameters.
Returns

integer

The number of axes on the controller.

Parameters
This function does not accept any parameters.
Returns

integer

The number of buttons on the controller.

Parameters

id :

integer

The id of the button you want to test.

Returns

boolean

Returns true if the player pressed the button during this frame, of false otherwise.

Parameters

id :

integer

The id of the button you want to test.

Returns

boolean

Returns true if the player released the button during this frame, of false otherwise.

Contacts

The functions in this group are used to get finger touch data from the touch controller.

Parameters
This function does not accept any parameters.
Returns

integer*

Returns the indices of all current contacts.

The * notation indicates that there may be zero or more instances of the specified type.
Parameters

contact_id :

integer

The id of the contact to test.

Returns

string?

If this contact originated on an edge of the touch panel, this string will be one of the following values: TOP, BOTTOM, RIGHT, or LEFT. If this contact did not originate at an edge, or if edge detection is unsupported by this device, this function returns nil.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

Available on Android platforms only.

Parameters

contact_id :

integer

The id of the contact to test.

Returns

boolean

Returns true if the contact exists, or false otherwise.

Parameters

contact_id :

integer

The id of the contact to test.

Returns

boolean

Returns true if the contact is the primary contact.

Parameters

contact_id :

integer

The id of the contact to test.

Returns

boolean

Returns true if the contact was initiated in this frame.

Parameters

contact_id :

integer

The id of the contact to test.

Returns

boolean

Returns true if the contact was released in this frame.

Parameters

contact_id :

integer

The id of the contact to test.

Returns

stingray.Vector3

The X,Y coordinates of the contact's current position.

Parameters

contact_id :

integer

The id of the contact to test.

Returns

stingray.Vector3

The change in the contact's X,Y coordinates in this frame.

Parameters

contact_id :

integer

The id of the contact to test.

Returns

number

The size of the specified contact on the major axis, in pixels.

Available on Android platforms only.

Parameters

contact_id :

integer

The id of the contact to test.

Returns

number

The size of the specified contact on the minor axis, in pixels.

Available on Android platforms only.

Parameters
This function does not accept any parameters.
Returns

integer

The number of currently active touch contacts.

Parameters

contact_id :

integer

The id of the contact to test.

Returns

number

The pressure of the specified contact on the touch panel.

Available on Android platforms only.

Parameters
This function does not accept any parameters.
Returns

stingray.Vector3

The resolution of the input coordinates for the controller.

This usually maps 1:1 to pixels on the X and Y axes. The Z-axis coordinate contains the maximal pressure value for contacts.

Parameters

contact_id :

integer

The id of the contact to test.

Returns

number

The size of the specified contact.

This is a normalized value relative to the largest possible touch contact that the device can sense. The smallest possible normalized size is 0.0 (no contact, or it is unmeasurable), and the largest possible normalized size is 1.0 (the sensor area is saturated). Available on Android platforms only.

Gestures

The functions in this group are used gesture data from the touch controller.

Parameters
This function does not accept any parameters.
Returns

stingray.Vector2?

Returns the location of where the long press gesture began.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Parameters
This function does not accept any parameters.
Returns

boolean?

Returns whether the gesture began during the last frame.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

boolean?

Returns whether the gesture ended during the last frame.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

stingray.Vector2?

Returns the center-location of where the gesture began.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

number?

Returns the current scale value of the pinch gesture.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

number?

Returns the current scale_per_second value of the pinch gesture.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

While in low frame-rate, begin and ended might both return true in the same call.

Parameters
This function does not accept any parameters.
Returns

boolean?

Returns whether the gesture began during the last frame.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

boolean?

Returns whether the gesture ended during the last frame.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

stingray.Vector2?

Returns the center-location of where the gesture began.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

number?

Returns the total accumulated rotation value of the gesture displayed in radians.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

number?

Returns the current rotation per second value of the gesture.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

While in low frame-rate, begin and ended might both return true in the same call.

Parameters
This function does not accept any parameters.
Returns

stingray.SwipeDirection?

Returns the direction of the swipe.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Parameters
This function does not accept any parameters.
Returns

stingray.Vector2?

Returns the location of the most recent non-sequence tap.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Parameters
This function does not accept any parameters.
Returns

number?

Returns the number of subsequent taps. (2-5 on iOS, unlimited on Android)

The ? notation indicates that this type is optional: there may be zero or one instances of it.

stingray.Vector2?

Returns the location of the most recent tap.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

Deprecated functions

Use the _id versions of these functions instead.

Parameters

name :

string

The name of the axis whose id you want to retrieve.

Returns

integer

The index of the axis, or nil if no axis is found with a matching name.

Axes must be referred to by IDs, not indices. Please use axis_id() instead.

Parameters

name :

string

The name of the button whose id you want to retrieve.

Returns

integer

The index of the button, or nil if no button is found with a matching name.

Buttons must be referred to by IDs, not indices. Please use button_id() instead.