Skip to content

Commit f8c1580

Browse files
committed
Issue cocos2d#2416: correct a mistake of cc.SpriteBatchNode
1 parent c9ee5cc commit f8c1580

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

cocos2d/core/base-nodes/CCNode.js

-1
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
14381438
child.arrivalOrder = cc.s_globalOrderOfArrival;
14391439
cc.s_globalOrderOfArrival++;
14401440
child._setLocalZOrder(zOrder);
1441-
this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.orderDirty);
14421441
},
14431442

14441443
/**

cocos2d/core/sprites/CCSpriteBatchNode.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{
410410
cc.log(cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite);
411411
return;
412412
}
413-
this._renderCmd.checkAtlasCapacity(index);
413+
this._renderCmd.insertQuad(sprite, index);
414414

415415
//
416416
// update the quad directly. Don't add the sprite to the scene graph
@@ -422,9 +422,6 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{
422422
// XXX: so, it should be AFTER the insertQuad
423423
sprite.dirty = true;
424424
sprite.updateTransform();
425-
426-
//sprite._renderCmd._setCachedParent(this._renderCmd); //TODO need move to renderCmd
427-
this._children.splice(index, 0, sprite);
428425
},
429426

430427
/**
@@ -458,11 +455,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{
458455
sprite.atlasIndex = index;
459456
sprite.dirty = true;
460457

461-
var locTextureAtlas = this.getTextureAtlas();
462-
if (locTextureAtlas.totalQuads >= locTextureAtlas.capacity)
463-
this.increaseAtlasCapacity();
464-
465-
locTextureAtlas.insertQuad(sprite.quad, index);
458+
this._renderCmd.insertQuad(sprite, index);
466459
this._descendants.splice(index, 0, sprite);
467460

468461
// update indices
@@ -497,6 +490,7 @@ cc.SpriteBatchNode = cc.Node.extend(/** @lends cc.SpriteBatchNode# */{
497490

498491
this._descendants.push(sprite);
499492
var index = this._descendants.length - 1;
493+
500494
sprite.atlasIndex = index;
501495
this._renderCmd.insertQuad(sprite, index);
502496

cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@
4141
this._texture = texture;
4242
};
4343

44-
proto.insertQuad = function(){};
44+
proto.insertQuad = function(sprite, index){
45+
var node = this._node;
46+
node._children.splice(index, 0, sprite);
47+
//sprite._renderCmd._setCachedParent(this._renderCmd); //TODO need move to renderCmd
48+
};
4549

4650
proto.increaseAtlasCapacity = function(){};
4751

cocos2d/tilemap/CCTMXLayer.js

+3
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ cc.TMXLayer = cc.SpriteBatchNode.extend(/** @lends cc.TMXLayer# */{
455455
return;
456456
}
457457

458+
console.log("textureAtlas capacity:" + this.textureAtlas.capacity + " textureAtlas totalQuads:" + this.textureAtlas.totalQuads);
459+
console.log("x:" + pos.x + " y:" + pos.y);
460+
458461
flags = flags || 0;
459462
this._setNodeDirtyForCache();
460463
var currentFlags = this.getTileFlagsAt(pos);

0 commit comments

Comments
 (0)