Search code examples
playn

Playn and multitouch?


I've made this Button class, to catch the Pointer event :

public class Button implements Pointer.Listener {

  public void initLayer(Image defaultImage) {
    layer = parent.createImageLayer(this.defaultImage);
    layer.addListener(this);
  }

...

If I touch one of the instanciated buttons, I get the onPointerStart & onPointerEnd events. But, if one of my button is already touched and I start to touch another, I don't get the onPointerStart event of the second button.

Is there a way to get these multi touch events with playn ?


Solution

  • The Pointer service is meant to abstract over either a simple touch interaction or a mouse interaction. Thus it does not support any sort of multi-touch interactions. You will not receive notifications about any touches other than the first via the Pointer service.

    If you want to handle multiple touches, you have to use the Touch service, and there is currently no way to register Touch listeners directly on layers. So you'll have to register a global listener and do your own hit testing, and map touch movements to the layer that was first hit by that touch, etc.