Hello I am making a cocos2d side scroller. I need to use a sprite sheet for my game and when I do use it it gives me a SIGABRT error I used an exception breakpoint to see the exact line of code that is causing the problem and got this line:
NSAssert(spriteFrame!=nil, @"Invalid spriteFrame for sprite");
The output is:
2013-08-24 15:51:28.410 App[2171:a0b] sprite sheet name is characterssheet_poses 2013-08-24 15:51:28.419 App[2171:a0b] bruisedImage = (null) 2013-08-24 15:51:28.420 App[2171:a0b] cocos2d: CCSpriteFrameCache: Frame '(null)' not found 2013-08-24 15:51:28.420 App[2171:a0b] bruisedPose = (null) 2013-08-24 15:51:28.421 App[2171:a0b] defaultImage = (null) 2013-08-24 15:51:28.421 App[2171:a0b] cocos2d: CCSpriteFrameCache: Frame '(null)' not found 2013-08-24 15:51:28.422 App[2171:a0b] defaultPose = (null) 2013-08-24 15:51:28.422 App[2171:a0b] *** Assertion failure in -[CCSprite initWithSpriteFrame:],
Here is the code that is causing the problem and that is displaying this output:
NSString* spriteSheetName = [theDictionary objectForKey:@"SpriteSheet"];
CCLOG(@"sprite sheet name is %@", spriteSheetName);
NSString* plistName = [NSString stringWithFormat:@"%@.plist", spriteSheetName ];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:plistName ];
NSString* bruisedImage = [theDictionary objectForKey:@"BruisedPose"];
CCLOG(@"bruisedImage = %@",bruisedImage);
bruisedPose = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:bruisedImage];
CCLOG(@"bruisedPose = %@",bruisedPose);
NSString* defaultImage = [theDictionary objectForKey:@"BasePose"];
CCLOG(@"defaultImage = %@",defaultImage);
defaultPose = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:defaultImage];
CCLOG(@"defaultPose = %@",defaultPose);
I am using sprite sheets and a .plist file to make my game. The sprite sheet's .plist file looks like this:
The .plist file I am using for game data looks like this:
You have a dictionary in a dictionary situation.
Your
theDictionary
object points to the root of the plist. First problem is: since you have 2 different plists you can't use the same dictionary object to read information from both plists. Without seeing how you initializetheDictionary
I can't tell but unless you merged the contents of both plists only one of the two plist's information will be in it.Next if you want to get the PlayerProperties (or frames) dictionary, you'd have to do something like this (assuming theDictionary represents the game data dictionary):
Or somewhat more convenient with KVC: