Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (494)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 1614 times)
0 Members and 1 Guest are viewing this topic.
Offline ddfh

Junior Member


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:
1  
2  
3  
4  
5  
6  
7  
    for (int i = 0; i < 10; i++) {
        if (Gdx.input.isTouched(i) == false) continue;

        float x = Gdx.input.getX(i);
        float y = Gdx.graphics.getHeight() - 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 Member


Medals: 1



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

Thanks!
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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (22 views)
2014-09-12 09:08:26

Norakomi (55 views)
2014-09-10 13:57:51

TehJavaDev (66 views)
2014-09-10 06:39:09

Tekkerue (33 views)
2014-09-09 02:24:56

mitcheeb (54 views)
2014-09-08 06:06:29

BurntPizza (38 views)
2014-09-07 01:13:42

Longarmx (24 views)
2014-09-07 01:12:14

Longarmx (30 views)
2014-09-07 01:11:22

Longarmx (28 views)
2014-09-07 01:10:19

mitcheeb (37 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!