Skip to content

Commit 2d78665

Browse files
committed
fix the bug that i is incorrect after remove a object
1 parent 34b9c0e commit 2d78665

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

extensions/GUI/CCControlExtension/CCControl.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ cc.Control = cc.LayerRGBA.extend({
318318
eventInvocationList.length = 0;
319319
} else {
320320
//normally we would use a predicate, but this won't work here. Have to do it manually
321-
for (var i = 0; i < eventInvocationList.length; i++) {
321+
for (var i = 0; i < eventInvocationList.length; ) {
322322
var invocation = eventInvocationList[i];
323323
var shouldBeRemoved = true;
324324
if (target)
@@ -328,6 +328,8 @@ cc.Control = cc.LayerRGBA.extend({
328328
// Remove the corresponding invocation object
329329
if (shouldBeRemoved)
330330
cc.ArrayRemoveObject(eventInvocationList, invocation);
331+
else
332+
i ++;
331333
}
332334
}
333335
},

0 commit comments

Comments
 (0)