PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

TouchSwipe

The TouchSwipe event fires when the player performs a swipe gesture on the UI element using a touch-enabled device. It fires with the direction of the gesture (Up, Down, Left or Right) and the number of touch points involved in the gesture. Swipe gestures are often used to change tabs in mobile UIs.

Since this event only requires one finger, this event can be simulated in Studio using the emulator and a mouse. Below is an example of TouchSwipe being fired on a Frame that is GuiObject/Active. Below, the event fires when the Frame moves and changes color slightly. The code for this can be found the code samples.

TouchSwipe event firing on a Frame

This event is part of a family of touch-related events. Other events like this one are GuiObject/TouchTap, GuiObject/TouchRotate, GuiObject/TouchPinch, GuiObject/TouchPan and Guiobject/TouchLongPress. In addition, UserInputService has a similarly named event that is not restricted to a specific UI element: UserInputService/TouchSwipe.

Parameters

Name Type Default Description

A Enum/SwipeDirection indicating the direction of the swipe gesture (Up, Down, Left or Right)

int

The number of touch points involved in the gesture (usually 1)


Code Samples


Bouncing Color Picker

This code sample will cause a Frame (or other GuiObject) to bounce when a swipe gesture is performed on a touch-enabled device (or Studio’s emulator). Horizontal swipes will change the hue of the GuiObject/BackgroundColor3, while vertical swipes will change the saturation.