Skip to content

Commit 9d76160

Browse files
committed
updated swap:withNewIndex: in CCSpriteBatchNode.m
textureAtlas quads are not updated to reflect changes to the atlas index of a swapped object. in consequence the draw order does not change. related to issue #598. Former-commit-id: 48de06e
1 parent a39eb57 commit 9d76160

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)