编辑5:优化级别构建设置:
编辑4:我尝试更改构建配置,将所有内容置于“Debug”,然后运行“testing”。很奇怪它没有崩溃大约20次(我不断加载和卸载各种GameScenes和不同的资产)。在第21次(即使没有统计相关性),我还是认为它可能不会崩溃,但它会崩溃。摘要仍然不可用,所以我想知道我是否正确行事或是否存在其他问题。以下是构建配置和崩溃报告:
编辑3:重要的是这个错误只发生了一些时间,比如6/7运行中的1个,所以我发现很难将其隔离。
我在理解哪个纹理使NSAssert失败时遇到了一些麻烦。我已经尝试several approaches但没有一个工作(或者很可能只是我有点太愚蠢:))。
在调试器中,我可以看到GLuint信息。在互联网上阅读我发现这是一种引用框架(一种指针)的方法。
我认为应该有一种方法可以从batchNode plist文件中检索帧名称,并且想知道这个GLuint号码是否能够以某种方式与plist文件中帧的顺序相对应。
NSAssert( !batchNode_ || texture.name == batchNode_.texture.name , @"CCSprite: Batched sprites should use the same texture as the batchnode");
/** texture name */
@property(nonatomic,readonly) GLuint name;
我尝试了这些方法,但它们可以捕获所有情况:
//From CCSprite.m
-(void) setTexture:(CCTexture2D*)texture
{
if(!batchNode_ || texture.name != batchNode_.texture.name)
{
CCLOG(@""); // I added a debug here but it catches all cases..
NSAssert( !batchNode_ || texture.name == batchNode_.texture.name , @"CCSprite: Batched sprites should use the same texture as the batchnode");
}
编辑:我知道有点疯狂,但我粘贴了我在CCTexture2D中初始化fileName的尝试,因为我似乎无法正确初始化它:
- (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)hAlignment vAlignment:(CCVerticalTextAlignment) vAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode font:(UIFont*)uifont
{
NSAssert( uifont, @"Invalid font");
fileName=string;//TODO: Remove
.....
}
上面的一个是我能够修改的唯一initWithString。我无法修改另一个中的fileName属性:
#elif defined(__CC_PLATFORM_MAC)
- (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)hAlignment vAlignment:(CCVerticalTextAlignment)vAlignment attributedString:(NSAttributedString*)stringWithAttributes
编辑2: 我试图将fileName指定为:
fileName = [string copy];
但它仍然提供了我在此处报告的摘要:
问题似乎发生在动画更新期间的setTexture中,但fileName似乎原本是错误的。
这就是我在CCTexture2D中声明属性的方式:
@property(nonatomic, copy) NSString* fileName; //TODO Remove