CCLabelBMFont 由于缺少图像消息而崩溃
我收到一个异常,说该行上的图像不能为 nil
:
CCLabelBMFont *label = [CCLabelBMFont labelWithString:@"5" fntFile:@"weaponnumbers.fnt"];
我做错了什么?我应该在不同的地方指定 PNG 吗?我把它放在项目的根目录下。
-(CCTexture2D*) addImage: (NSString*) path
{
NSAssert(path != nil, @"TextureCache: fileimage MUST not be nill");
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");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Weaponnumbers.fnt 是否包含在您的目标中?例如它是否编译到项目中?
另外,我认为您不太可能在这里遇到异常 - 您可能会在此调用的其中一个调用中的某个地方遇到异常。尝试在之前的行上设置断点,并使用“Step In”断点工具单步执行调用堆栈并找到异常的真正本质。
我发现 Cocos2D 异常非常不言自明,当您最终可以了解实际抛出异常的正确级别时。
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.
删除添加并清理修复了它。
NSString stringWithContentsOfFile 失败,似乎是错误的错误代码
A delete add and clean fixed it.
NSString stringWithContentsOfFile failing with what seems to be the wrong error code