Skip to content

Commit 7e30cfc

Browse files
fixed cocos2d#2452:optimize javascript code
1 parent 6844635 commit 7e30cfc

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

cocos2d/base_nodes/CCNode.js

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,37 +3549,19 @@ cc.NodeCanvas = cc.Class.extend(/** @lends cc.NodeCanvas# */{
35493549
if (len > 0) {
35503550
this.sortAllChildren();
35513551
// draw children zOrder < 0
3552-
/*var tag = children[0]._zOrder,tmpTag;
3553-
if(tag >= 0){
3554-
this.draw();
3552+
for (i = 0; i < len; i++) {
3553+
child = children[i];
3554+
if (child._zOrder < 0)
3555+
child.visit(context);
3556+
else
3557+
break;
35553558
}
3556-
for(i = 0; i < len;i++){
3559+
this.draw(context);
3560+
for (; i < len; i++) {
35573561
child = children[i];
3558-
tmpTag = child._zOrder;
3559-
if(tmpTag>=0 && tag < 0){
3560-
this.draw();
3561-
}
3562-
child.visit(context);
3563-
tag = tmpTag;
3562+
if (child._zOrder >= 0)
3563+
child.visit(context);
35643564
}
3565-
if(tag<0){
3566-
this.draw();
3567-
}*/
3568-
3569-
for (i = 0; i < len; i++) {
3570-
child = children[i];
3571-
if (child._zOrder < 0)
3572-
child.visit(context);
3573-
else
3574-
break;
3575-
}
3576-
this.draw(context);
3577-
for (; i < len; i++) {
3578-
child = children[i];
3579-
if (child._zOrder >= 0)
3580-
child.visit(context);
3581-
}
3582-
35833565
} else
35843566
this.draw(context);
35853567

0 commit comments

Comments
 (0)