Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  LibGDX - Swipe Up, swipe right, swipe down, swipe left and buttons touch?  (Read 5467 times)
0 Members and 1 Guest are viewing this topic.
Offline ddfh

Junior Devvie

Medals: 1

« Posted 2013-03-05 10:08:30 »

In the green area the user can swipe up, right, down, left. How can I now get this swipes?
e.g. how to get a String -> input = getSwiped(); -> input is then Up, or right, or down, or left

And the user can touch two buttons. 1 or 2.
1 is for duck and 2 is for jump.

I want to check this inputs at the same time (Multitouch). The user can touch one of the button and also swipe at the same moment.

I know there is a GestureDetector. I looked at the code, but no clue how can I use the swipe part.

I know a little bit how to check the buttons. The problem is only here -> How to check the inputs at the same time and how get Swipe Up, or Swipe right etc.

I searched an found how to check Multitouching:
    for (int i = 0; i < 10; i++) {
        if (Gdx.input.isTouched(i) == false) continue;

        float x = Gdx.input.getX(i);
        float y = - Gdx.input.getY(i) - 1;

Thank You.
Offline ReBirth
« Reply #1 - Posted 2013-03-05 15:11:52 »

For swipe type just compare the delta between X pairs and Y pairs. If X delta > Y delta, then it's horizontal (vice versa). Left or right, look on which one bigger, the touch down or the touch up.

For duck and jump you may just add click listener to each button. You better have the buttons extending Actor.

Offline ddfh

Junior Devvie

Medals: 1

« Reply #2 - Posted 2013-03-05 16:22:06 »

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Cero
« Reply #3 - Posted 2013-03-05 20:38:38 »

Check out also GestureDetector in the API, it can detect certain gestures automatically

in this case you would use touchDragged and then check the values
or fling() in GestureDetector.GestureListener

Pages: [1]
  ignore  |  Print  

EgonOlsen (78 views)
2018-06-10 19:43:48

EgonOlsen (58 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (260 views)
2018-05-13 18:23:11

nelsongames (158 views)
2018-04-24 18:15:36

nelsongames (157 views)
2018-04-24 18:14:32

ivj94 (898 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (811 views)
2018-03-24 14:43:53

Solater (175 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!