您好,我正在制作 cocos2d 侧滚动条。我需要为我的游戏使用精灵表,当我使用它时,它给了我一个 SIGABRT 错误我使用异常断点来查看导致问题的确切代码行并得到这一行:
NSAssert(spriteFrame!=nil, @"Invalid spriteFrame for sprite");
输出是:
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:找不到帧'(null)' 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] *** -[CCSprite initWithSpriteFrame:] 中的断言失败,
这是导致问题并显示此输出的代码:
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);
我正在使用精灵表和 .plist 文件来制作我的游戏。精灵表的 .plist 文件如下所示:
我用于游戏数据的 .plist 文件如下所示: