Skip to content

Commit a9821a7

Browse files
fixed a bug for getting plist path in CCAnimationCache
1 parent ce72f22 commit a9821a7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cocos2d/sprite_nodes/CCAnimationCache.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ cc.AnimationCache = cc.Class.extend(/** @lends cc.AnimationCache# */{
7979
* Make sure that the frames were previously loaded in the cc.SpriteFrameCache.
8080
* </p>
8181
* @param {object} dictionary
82+
* @param {String} plist
8283
*/
83-
addAnimationsWithDictionary:function (dictionary) {
84+
_addAnimationsWithDictionary:function (dictionary,plist) {
8485
var animations = dictionary["animations"];
8586
if (!animations) {
8687
cc.log("cocos2d: cc.AnimationCache: No animations were found in provided dictionary.");
@@ -92,8 +93,11 @@ cc.AnimationCache = cc.Class.extend(/** @lends cc.AnimationCache# */{
9293
if (properties) {
9394
version = (properties["format"] != null) ? parseInt(properties["format"]) : version;
9495
var spritesheets = properties["spritesheets"];
96+
var spriteFrameCache = cc.SpriteFrameCache.getInstance();
97+
var fileUtils = cc.FileUtils.getInstance(), path;
9598
for (var i = 0; i < spritesheets.length; i++) {
96-
cc.SpriteFrameCache.getInstance().addSpriteFrames(spritesheets[i]);
99+
path = fileUtils.fullPathFromRelativeFile(spritesheets[i], plist);
100+
spriteFrameCache.addSpriteFrames(path);
97101
}
98102
}
99103

@@ -121,7 +125,6 @@ cc.AnimationCache = cc.Class.extend(/** @lends cc.AnimationCache# */{
121125
if(!plist)
122126
throw "cc.AnimationCache.addAnimations(): Invalid texture file name";
123127
var fileUtils = cc.FileUtils.getInstance();
124-
125128
var path = fileUtils.fullPathForFilename(plist);
126129
var dict = fileUtils.dictionaryWithContentsOfFileThreadSafe(path);
127130

@@ -130,7 +133,7 @@ cc.AnimationCache = cc.Class.extend(/** @lends cc.AnimationCache# */{
130133
return;
131134
}
132135

133-
this.addAnimationsWithDictionary(dict);
136+
this._addAnimationsWithDictionary(dict,plist);
134137
},
135138

136139
_parseVersion1:function (animations) {

0 commit comments

Comments
 (0)