Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I detect touchswipe over a large area?

TouchSwipe is an event that occurs on all GuiObjects - including things that aren't GuiButtons.

I want to make a screen that is like most home screens on a smartphone: You can swipe to the left and right to change frames, and you can also tap individually on certain items to activate them.

But here's the catch - I can only swipe left and right on a certain large area of the screen to change frames. But in another area, it won't work.

How should I lay this out? Should I put a large invisible frame over the large area with a high Zindex so that swipes can be detected? Or is there another way this is supposed to work?

1 comment

0

I don't know the solution but I can confirm that TouchSwipe doesn't seem to work. It just pans the camera.

1 answer

Your idea sounds good, but you should also test what happens when you attempt to swipe over top of multiple overlapping frames. If it's anything like the Click/MouseMove events, the events may occur for all frames regardless of Z-value (unless Roblox has fixed this in the last few months). If this is also the case for Touch events, you will need to make sure that if a visible frame overlaps with your invisible one(s) and the swipe occurs overtop of the visible one, then make sure that the appropriate action is taken over the visible one, but not the invisible one.

An alternative is to use the events in UserInputService directly, such as the TouchPan or TouchSwipe events. If a potential swipe action has occurred and its start and end coordinates are in the appropriate regions, then you trigger your "swipe occurred" code. As in the previous paragraph, you have to make sure that the swipe wasn't meant for a different part of your GUI.

4 comments

0

Turns out my original answer didn't work - For some reason GUI's have these events but don't seem to activate at all.

0

Also - UserInputService has another problem: It cannot tell the start and end coordinates of a TouchSwipe event.

0

I might be able to use a combination of events which connect to each other (Such as TouchEnded, TouchMoved), but I need to know why an InputObject has a Vector3 position instead of a Vector2 or a UDim2.

0

iirc, an InputObject has a Vector3 for X, Y, and MiddleMouse Scroll amount

This discussion is preserved as it was. New answers, comments, and votes are closed.