CCLabelBMFont crashing due to a missing image message
I'm getting an exception saying that the image cannot be nil
on this line:
CCLabelBMFont *label = [CCLabelBMFont labelWithString:@"5" fntFile:@"weaponnumbers.fnt"];
What am I doing wrong? Am I supposed开发者_开发百科 to specify the PNG somewhere different? I have it at the root of the project.
-(CCTexture2D*) addImage: (NSString*) path
{
NSAssert(path != nil, @"TextureCache: fileimage MUST not be nill");
Is weaponnumbers.fnt included in your target? E.g. is it compiled into the project?
Also, I think it's unlikely you're getting an exception here - you're probably getting an exception somewhere inside one of the calls made by this call. Try breakpointing the line before, and using the "Step In" breakpoint tool to step through the call stack and find the true nature of the exception.
I find Cocos2D exceptions to be pretty self-explanatory, when you can eventually get down to the right level of where the exception is actually being thrown.
A delete add and clean fixed it. NSString stringWithContentsOfFile failing with what seems to be the wrong error code
精彩评论