@@ -73,7 +73,7 @@ cc.SpriteFrameCache = cc.Class.extend(/** @lends cc.SpriteFrameCache# */{
7373 if ( frameDict ) {
7474 var spriteFrame = this . _spriteFrames [ key ] ;
7575 if ( spriteFrame ) {
76- continue ;
76+ continue ;
7777 }
7878
7979 if ( format == 0 ) {
@@ -228,6 +228,9 @@ cc.SpriteFrameCache = cc.Class.extend(/** @lends cc.SpriteFrameCache# */{
228228 break ;
229229 case 2 :
230230 if ( texture instanceof cc . Texture2D ) {
231+ if ( this . _loadedFileNames . indexOf ( filePath ) === - 1 ) {
232+ this . _checkConflict ( dict ) ;
233+ }
231234 /** Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames. */
232235 this . _addSpriteFramesWithDictionary ( dict , texture ) ;
233236 } else {
@@ -240,8 +243,11 @@ cc.SpriteFrameCache = cc.Class.extend(/** @lends cc.SpriteFrameCache# */{
240243 var gTexture = cc . TextureCache . getInstance ( ) . addImage ( textureFileName ) ;
241244
242245 if ( gTexture ) {
246+ if ( this . _loadedFileNames . indexOf ( filePath ) === - 1 ) {
247+ this . _checkConflict ( dict ) ;
248+ this . _loadedFileNames . push ( filePath ) ;
249+ }
243250 this . _addSpriteFramesWithDictionary ( dict , gTexture ) ;
244- this . _loadedFileNames . push ( filePath ) ;
245251 } else {
246252 cc . log ( "cocos2d: cc.SpriteFrameCache: couldn't load texture file. File not found " + textureFileName ) ;
247253 }
@@ -252,6 +258,17 @@ cc.SpriteFrameCache = cc.Class.extend(/** @lends cc.SpriteFrameCache# */{
252258 }
253259 } ,
254260
261+ // Function to check if frames to add exists already, if so there may be name conflit that must be solved
262+ _checkConflict : function ( dictionary ) {
263+ var framesDict = dictionary [ "frames" ] ;
264+
265+ for ( var key in framesDict ) {
266+ if ( this . _spriteFrames [ key ] ) {
267+ cc . log ( "cocos2d: WARNING: Sprite frame: " + key + " has already been added by another source, please fix name conflit" ) ;
268+ }
269+ }
270+ } ,
271+
255272 /**
256273 * <p>
257274 * Adds an sprite frame with a given name.<br/>
0 commit comments