Search code examples
flutterflame

Gesture detected which is non targeted by camera


I have two worlds A and B. A has tappable components but B doesn't have tappable components.

First my single CameraComponent targets world A and I can detect gesture on the tappable components in A. Next, my camera switches from targeting world A to world B, then I switch the view to world B. Finally, When I tap the displayed world B, the gestures are still detected like it would have been world A.

See example here: https://i.sstatic.net/jcpkb.gif

flame: ^1.6.0

I expected that the gestures shouldn't be detected once I swapped to world b, is this not correct?


Solution

  • You have to also remove world A from the component tree if you don't want the gestures to trigger on there.

    Just do something like this when you swap the camera to the world B:

    gameRef.remove(worldA);