问题
EDIT 5: Optimization level build settings:
EDIT 4: I tried to change the build configuration putting all to "Debug" and then run for "testing". Weirdly enough it didn't crash for about 20 times (I kept load and unloading various GameScenes whith different assets). At the 21st time (even if not statistically relevant) I was about to think that it might not crash anymore but it crashed. The summary is still unavailable so I am wondering if I am doing it right or if there is some other issue.. Here are the build configuration and the crash report:
EDIT 3: Importantly this bug happens only some times, like 1 out of 6/7 runs so I find it difficult to isolate it.
I am having some serious trouble understanding which texture is getting this NSAssert to fail. I have tried several approaches but none worked (or most likely its just me being a bit too stupid :)).
In the debugger I can see the GLuint information. Reading up on the internet I found that is a way to reference a frame (a sort of pointer).
I thought that there should be a way to retrieve the frame name from the batchNode plist file and was wondering if this GLuint number can correspond somehow to the order of the frame within the plist file.
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;
I tried those approaches but they catch all cases:
//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");
}
EDIT: I know is kind of crazy but I paste my attempt to initialize fileName in CCTexture2D as I don't seem to be able to initialize it correctly:
- (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
.....
}
The one above is the only initWithString that I was able to modify. I cannot modify the fileName property in this other one:
#elif defined(__CC_PLATFORM_MAC)
- (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)hAlignment vAlignment:(CCVerticalTextAlignment)vAlignment attributedString:(NSAttributedString*)stringWithAttributes
EDIT 2: I tried to assign fileName as:
fileName = [string copy];
but it still gives me summary unavailable as reported here:
the problem seems to happen in setTexture during an Animation update but the fileName seems to be originally wrong.
That's how I declared the property in CCTexture2D:
@property(nonatomic, copy) NSString* fileName; //TODO Remove
来源:https://stackoverflow.com/questions/15208275/how-can-i-retrieve-the-corresponding-texture-name-from-a-gluint