Skip to content

Commit 723ab35

Browse files
committed
Fixed multi-touch handling
1 parent 4d4b7fc commit 723ab35

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

cocos2d/platform/CCEGLView.js

+20-12
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
653653
var ys = [];
654654

655655
var i = 0;
656+
var touch;
656657
for (var j = 0; j < touches.length; j++) {
657-
ids[i] = j;
658-
xs[i] = touches[j].getLocation().x;
659-
ys[i] = touches[j].getLocation().y;
658+
touch = touches[j];
659+
ids[i] = touch.getId() || j;
660+
xs[i] = touch.getLocation().x;
661+
ys[i] = touch.getLocation().y;
660662
++i;
661663
}
662664
this.handleTouchesBegin(i, ids, xs, ys);
@@ -668,10 +670,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
668670
var ys = [];
669671

670672
var i = 0;
673+
var touch;
671674
for (var j = 0; j < touches.length; j++) {
672-
ids[i] = j;
673-
xs[i] = touches[j].getLocation().x;
674-
ys[i] = touches[j].getLocation().y;
675+
touch = touches[j];
676+
ids[i] = touch.getId() || j;
677+
xs[i] = touch.getLocation().x;
678+
ys[i] = touch.getLocation().y;
675679
++i;
676680
}
677681
this.handleTouchesMove(i, ids, xs, ys);
@@ -683,10 +687,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
683687
var ys = [];
684688

685689
var i = 0;
690+
var touch;
686691
for (var j = 0; j < touches.length; j++) {
687-
ids[i] = j;
688-
xs[i] = touches[j].getLocation().x;
689-
ys[i] = touches[j].getLocation().y;
692+
touch = touches[j];
693+
ids[i] = touch.getId() || j;
694+
xs[i] = touch.getLocation().x;
695+
ys[i] = touch.getLocation().y;
690696
++i;
691697
}
692698
this.handleTouchesEnd(i, ids, xs, ys);
@@ -698,10 +704,12 @@ cc.EGLView = cc.Class.extend(/** @lends cc.EGLView# */{
698704
var ys = [];
699705

700706
var i = 0;
707+
var touch;
701708
for (var j = 0; j < touches.length; j++) {
702-
ids[i] = j;
703-
xs[i] = touches[j].getLocation().x;
704-
ys[i] = touches[j].getLocation().y;
709+
touch = touches[j];
710+
ids[i] = touch.getId() || j;
711+
xs[i] = touch.getLocation().x;
712+
ys[i] = touch.getLocation().y;
705713
++i;
706714
}
707715
this.handleTouchesCancel(i, ids, xs, ys);

0 commit comments

Comments
 (0)