Skip to content

Commit e74a277

Browse files
committed
Merge pull request #605 from kalo-/patch-2
updated swap:withNewIndex: in CCSpriteBatchNode.m Former-commit-id: 3ea9615
2 parents 99f4a7b + 9d76160 commit e74a277

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cocos2d/CCSpriteBatchNode.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ - (void) swap:(NSInteger) oldIndex withNewIndex:(NSInteger) newIndex
337337
//update the index of other swapped item
338338
( ( CCSprite* )[ _descendants objectAtIndex:newIndex ] ).atlasIndex = oldIndex;
339339
[_descendants exchangeObjectAtIndex:oldIndex withObjectAtIndex:newIndex];
340+
341+
// update the quads for the swapped sprites in the textureAtlas (issue #598)
342+
_textureAtlas.quads[newIndex] = [(CCSprite *)[_descendants objectAtIndex:newIndex] quad];
343+
_textureAtlas.quads[oldIndex] = [(CCSprite *)[_descendants objectAtIndex:oldIndex] quad];
340344
}
341345

342346
- (void) reorderBatch:(BOOL) reorder

0 commit comments

Comments
 (0)