Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid texture for sprite'
Having abit of a problem with the above error.Im making a simple slider puzzle where ive added medium / hard levels. The easy level works no problems at all, but when i chose the medium or hard it throws this error out occasionally. 60% of the time they work fine but then the app crashes the other times.
What i dont understand is that it works fine for the easy levels but adding a medium level it gets problems. Heres the code if anyone wants to have a look.
NSString *name = [NSString stringWithFormat:@"%d.jpg",imgValue];
CCTexture2D * texture = [[CCTextureCache sharedTextureCache] addImage:name];
NSMutableArray *imgFrames = [NSMutableArray array];
for (int i = 0; i < 5; i++) {
for (int j = 4; j >= 0; j--) {
CCSpriteFrame *imgFrame = [CCSpriteFrame frameWithTexture:texture rect:CGRectMake(i*56, j*56, 56, 56) offset:CGPointZero];
[imgFrames addObject:[NSDictionary dictionaryWithObjectsAndKeys:imgFrame, @"frame", [NSNumber numberWithInt:[self hashOfXY:i y:size.height-1-j]], @"check", nil]];
Thats the only error it thro开发者_JAVA技巧ws out in the title. If anyone could help id be greatful.
Cheers
Most likely your texture cache is cleared at some point. Check applicationDidReceiveMemoryWarning if code there clears the cache unintentionally.
精彩评论