1

I'm trying to detect a swipe gesture on a game developed with PlayN and Tripleplay libraries. I did some experiment using tripleplay.gesture package but I don't understand how to use it. Is there any example? Thank you Giovanni

Gio
  • 94
  • 5

1 Answers1

1

I found a solution that works well. I hope it can be useful to someone (although I think that unfortunately there are few of us still using PlayN)

if (touch().hasTouch()) {
    platform().setPropagateEvents(true);

    final Swipe swipe = new Swipe(Gesture.Direction.LEFT);

    swipe.completed().connect(new UnitSlot() {
        @Override
        public void onEmit() {
            PlayN.log().info("Swipe");
            UIController.getInstance().toggleScreen();
        }
    });

    Touch.LayerListener tll = new GestureDirector(
            new Rectangle(
                    0,
                    0,
                    layerWidth,
                    layerHeigth
            ), UIController.getTimer()).add(swipe);
    layer.addListener(tll);
}
Gio
  • 94
  • 5