@@ -56,6 +56,8 @@ cc.UIInterfaceOrientationPortrait = 0;
56
56
* @name cc.inputManager
57
57
*/
58
58
cc . inputManager = /** @lends cc.inputManager# */ {
59
+ TOUCH_TIMEOUT : 5000 ,
60
+
59
61
_mousePressed : false ,
60
62
61
63
_isRegisterEvent : false ,
@@ -81,12 +83,21 @@ cc.inputManager = /** @lends cc.inputManager# */{
81
83
82
84
_getUnUsedIndex : function ( ) {
83
85
var temp = this . _indexBitsUsed ;
86
+ var now = cc . sys . now ( ) ;
84
87
85
88
for ( var i = 0 ; i < this . _maxTouches ; i ++ ) {
86
89
if ( ! ( temp & 0x00000001 ) ) {
87
90
this . _indexBitsUsed |= ( 1 << i ) ;
88
91
return i ;
89
92
}
93
+ else {
94
+ var touch = this . _touches [ i ] ;
95
+ if ( now - touch . _lastModified > this . TOUCH_TIMEOUT ) {
96
+ this . _removeUsedIndexBit ( i ) ;
97
+ delete this . _touchesIntegerDict [ touch . getID ( ) ] ;
98
+ return i ;
99
+ }
100
+ }
90
101
temp >>= 1 ;
91
102
}
92
103
@@ -110,7 +121,9 @@ cc.inputManager = /** @lends cc.inputManager# */{
110
121
* @param {Array } touches
111
122
*/
112
123
handleTouchesBegin : function ( touches ) {
113
- var selTouch , index , curTouch , touchID , handleTouches = [ ] , locTouchIntDict = this . _touchesIntegerDict ;
124
+ var selTouch , index , curTouch , touchID ,
125
+ handleTouches = [ ] , locTouchIntDict = this . _touchesIntegerDict ,
126
+ now = cc . sys . now ( ) ;
114
127
for ( var i = 0 , len = touches . length ; i < len ; i ++ ) {
115
128
selTouch = touches [ i ] ;
116
129
touchID = selTouch . getID ( ) ;
@@ -124,6 +137,7 @@ cc.inputManager = /** @lends cc.inputManager# */{
124
137
}
125
138
//curTouch = this._touches[unusedIndex] = selTouch;
126
139
curTouch = this . _touches [ unusedIndex ] = new cc . Touch ( selTouch . _point . x , selTouch . _point . y , selTouch . getID ( ) ) ;
140
+ curTouch . _lastModified = now ;
127
141
curTouch . _setPrevPoint ( selTouch . _prevPoint ) ;
128
142
locTouchIntDict [ touchID ] = unusedIndex ;
129
143
handleTouches . push ( curTouch ) ;
@@ -142,7 +156,9 @@ cc.inputManager = /** @lends cc.inputManager# */{
142
156
* @param {Array } touches
143
157
*/
144
158
handleTouchesMove : function ( touches ) {
145
- var selTouch , index , touchID , handleTouches = [ ] , locTouches = this . _touches ;
159
+ var selTouch , index , touchID ,
160
+ handleTouches = [ ] , locTouches = this . _touches ,
161
+ now = cc . sys . now ( ) ;
146
162
for ( var i = 0 , len = touches . length ; i < len ; i ++ ) {
147
163
selTouch = touches [ i ] ;
148
164
touchID = selTouch . getID ( ) ;
@@ -155,6 +171,7 @@ cc.inputManager = /** @lends cc.inputManager# */{
155
171
if ( locTouches [ index ] ) {
156
172
locTouches [ index ] . _setPoint ( selTouch . _point ) ;
157
173
locTouches [ index ] . _setPrevPoint ( selTouch . _prevPoint ) ;
174
+ locTouches [ index ] . _lastModified = now ;
158
175
handleTouches . push ( locTouches [ index ] ) ;
159
176
}
160
177
}
0 commit comments