fljot / Gestouch

Gestouch: multitouch gesture recognition library for Flash (ActionScript) development.
MIT License
355 stars 85 forks source link

Errors when using swipe gesture with Starling #88

Open Toinouze opened 9 years ago

Toinouze commented 9 years ago

Hi,

We have an error occuring when using a swipe gesture with Starling. Doesn't happen very oftern (1.5% of users), but still annoying :

Error: Not touch target found (hit test).Something is wrong, at least flash.display::Stage should be found.See Gestouch#addTouchHitTester() and Gestouch#inputAdapter.
   at org.gestouch.core::TouchesManager.org.gestouch.core::gestouch_internal::onTouchBegin()()
   at org.gestouch.input::NativeInputAdapter.touchBeginHandler()()

Here's our Gestouch initialization (done once at app launch):

Gestouch.inputAdapter ||= new NativeInputAdapter(Starling.current.nativeStage);
Gestouch.addDisplayListAdapter(DisplayObject, new StarlingDisplayListAdapter());
Gestouch.addTouchHitTester(new StarlingTouchHitTester(Starling.current), -1);

Here's how we create a swipe gesture :

swipeGesture = new SwipeGesture(this);
swipeGesture.direction = SwipeGestureDirection.HORIZONTAL;
swipeGesture.minOffset = Capabilities.screenDPI * 0.3;
swipeGesture.addEventListener(GestureEvent.GESTURE_RECOGNIZED, onSwipe);

As you can see, nothing complicated. The swipe gesture works fine, we cannot reproduce the bug on our device (as I said, only 1.5% of users are impacted). We display full screen ads (with a native, non AIR view) on our app, maybe it's related ?

Any help would be greatly appreciated.

Thanks !

fljot commented 9 years ago

It's not that you did something wrong, but that it needs to be "fixed" a bit. Read https://github.com/fljot/Gestouch/issues/86 for more info.

Add:

Gestouch.addDisplayListAdapter(flash.display.DisplayObject, new NativeDisplayListAdapter());
Gestouch.addTouchHitTester(new NativeTouchHitTester(stage));

Quick info to make it clear why so (if anyone will ever read this): it's because when input (touch/mouse event) happened, system (touches manager) couldn't find target for touch because there was only StarlingTouchHitTester registered and touch happened not over any Starling object. Adding these two lines will make it work with flash.display.DisplayObject also, fixing previously unresolved touch target.

Toinouze commented 9 years ago

Hi,

Thanks for your fast reply.

After adding the native adapter & touch hit tester, i got another error when clicking on anything :

~~Error: Display list adapter not found for target of type 'starling.display::Image'. at org.gestouch.core::GesturesManager/org.gestouch.core::gestouch_internal::onTouchBegin()[O:\Dev\Gestouch\src\org\gestouch\core\GesturesManager.as:218] at org.gestouch.core::TouchesManager/org.gestouch.core::gestouch_internal::onTouchBegin()[O:\Dev\Gestouch\src\org\gestouch\core\TouchesManager.as:151] at org.gestouch.input::NativeInputAdapter/mouseDownHandler()[O:\Dev\Gestouch\src\org\gestouch\input\NativeInputAdapter.as:189]~~

Edit : nevermind, it was an import issue. We will put this in production and see if the problems is fixed. Thanks a lot !