rezoner / CanvasQuery

Canvas for 2d gamedevelopers. Out of box canvas, keyboard, mouse, events.
http://canvasquery.com
586 stars 52 forks source link

Touchend is unreliable in multitouch #37

Open feiss opened 9 years ago

feiss commented 9 years ago

Trying mobile multitouch support, I've notice this unpredictable behaviour. Sometimes touchend is called, sometimes is not, and sometimes is called in a wrong x,y. Test code below and try it on mobile.

The code in the docs (handling multitouch in render()) runs perfectly, but there's no easy way to know if a touch starts or ends.

Tested on iPad mini (ios 7.1.2) and Nexus7 (android 5.0.2). On the nexus, where the frame rate is lower, the effect is worse.

var app = playground({
  ready: function(){
    this.layer.clear('#000').strokeStyle('#f00');
  },
  touchstart: function(ev) {
      this.layer.fillStyle("#0f0").fillCircle(ev.x, ev.y, 5);
  },
  touchmove: function(ev) {
    this.layer.fillStyle("#fff").fillCircle(ev.x, ev.y, 2);
  },
  touchend: function(ev) {
      this.layer.strokeCircle(ev.x, ev.y, 20); // <------ !!!
  }
});
rezoner commented 9 years ago

@feiss - I've fixed it and put your test case online: http://canvasquery.com/toucherror

Could you confirm it's gone?

feiss commented 9 years ago

fixed in iOS! :dancer: :+1: :+1:

in Android touchend is not called (no red circles)

ps: do you have a life? :P

rezoner commented 9 years ago

Will investigate android as soon as I find my nexus.

ps: Since I am crunching Jameson for PAX the answer is close to no :)

feiss commented 9 years ago

Stop worrying about opened issues then! go go go! :loudspeaker: :loudspeaker:

(thanks anyway :)