7 Mayıs 2015 Perşembe

android apk Tutorial (LibGDX & MTX) Test_05_InputIntent 2

android apk Tutorial (LibGDX & MTX) Test_05_InputIntent 2 android game , android apk Tutorial (LibGDX & MTX) Test_05_InputIntent 2 android free download , android apk Tutorial (LibGDX & MTX) Test_05_InputIntent 2 mobile game android apk Tutorial (LibGDX & MTX) Test_05_InputIntent 2 android free download

What if I just need to detect swipe intentions not minor drags on the screen. The very simple solution is again InputIntent class.

FOR EXAMPLE: When you get notification center in android, you need to drag abit longer, nut just minor drags like 4-5 pixels.






















SET DRAG INTERVAL

First I need to determine how much drag needed for a specific task, in my example below

        dragAmount = AppSettings.SCREEN_W / 5.0f;
        inputIntent.setTouchDragIntervalRange(dragAmount);


Drag amount is 1/5 of the Screen Width (So if you use Samsung Galaxy II, you need to drag 160 pixels, if you use the GSIII, you will need to drag 256 pixels)






















CHECK DRAG INTERVAL

It is again very simple, just use:

inputIntent.isTouchDragInterval() // This simple will return true if needed drag amount achieved which you set in above example (dragAmount) inputIntent.setTouchDragIntervalRange(dragAmount);

In my example I only want to detect drags to LEFT and RIGHT, I do not care for UP and DOWN drags, So if user drags to LEFT or RIGHT and if it is DRAG INTERVAL return true and do something.































EXAMPLE

The best example you can see in one my live wallpaper projects. "Christmas Live Wallpaper"

You need to drag a specific amount to UP and DOWN to switch between Christmas Tree and Christmas Objects.

NOTE: The InputIntent I used in this live wallpaper abit old version, back then it was only detecting by removing finger off the screen each time. The current InputIntent much more improved and better.

(Google Play)






















0 yorum:

Yorum Gönder