Strange error: CGImageProviderCreate: Invalid image provider size: 55 x 36

I use Objective-c and cocos2d and I get a weird error when combining two parts of seemingly unrelated code.

The intended code at the beginning of the layer.

/* sprite setup */ CCSprite *sprite = [ [ [ StaticSprite alloc ] initWithSheetName: @"001-Fighter01" atPosition: ccp( 200, 200 ) withColumn: 0 withRow: 1 ] autorelease ]; [ map.spriteLayer addChild: sprite ]; CCSprite *sprite2 = [ [ [ StaticSprite alloc ] initWithSheetName: @"001-Fighter01" atPosition: ccp( 250, 200 ) withColumn: 0 withRow: 1 ] autorelease ]; [ map.spriteLayer addChild: sprite2 ]; CCSprite *sprite3 = [ [ [ StaticSprite alloc ] initWithSheetName: @"001-Fighter01" atPosition: ccp( 200, 250 ) withColumn: 0 withRow: 1 ] autorelease ]; [ map.spriteLayer addChild: sprite3 ]; /* ui setup */ // dpad dPadUI = [ DPad node ]; [ self addChild: dPadUI ]; 

Creating a DPad gives the error CGImageProviderCreate: invalid image provider size: 55 x 36 , which causes a crash. The strange part is, if I delete the sprite setup code, the DPad code works fine, and if I delete the DPad code the sprite code will work fine, but somehow, when both are present, I get an error.

StaticSprite is a fairly simple extension to the CCSprite class:

 @implementation StaticSprite - ( id ) initWithSheetName: ( NSString * ) sheetName atPosition: ( CGPoint ) initPosition withColumn: ( int ) column withRow: ( int ) row { // setup frames [ [ CCSpriteFrameCache sharedSpriteFrameCache ] addSpriteFramesWithFile: [ NSString stringWithFormat: @"%@.plist", sheetName ] ]; if ( self = [ super initWithSpriteFrameName:[ NSString stringWithFormat: @"%@-%d,%d.png", sheetName, column, row ] ] ) { int halfSize = [ Geometry spriteHalfSizeFromRect: [ self boundingBox ] ]; self.anchorPoint = ccp( .5, halfSize / [ self boundingBox ].size.height ); self.position = initPosition; self.zOrder = -self.position.y; } return self; } @end 

DPad is also a fairly simple extension to CCSprite:

 @implementation DPad - ( id ) init { if ( self = [ super initWithFile: @"dPad.png" ] ) { self.anchorPoint = ccp( 18 / [ self boundingBox ].size.width, .5 ); self.visible = false; self.blendFunc = ( ccBlendFunc ) { GL_SRC_ALPHA, GL_ONE }; self.opacity = 64; } return self; } - ( void ) activateWithDirection: ( double ) angle { self.visible = true; [ self setRotation: CC_RADIANS_TO_DEGREES( -angle ) ]; } - ( void ) deactivate { self.visible = false; } @end 

It seems that I can add as many static sprites with different images without problems, and the DPad image is quite small. Why do both of these sections of code work alone, but when they are in the same application, they cause a strange error?

I tried to enable the renaming of the DPad init method in initDefault .

EDIT

I went through the cocos2d code and found that the error was happening right here. After the error, image rotated to zero.

 UIImage *image = [[UIImage alloc] initWithContentsOfFile:fullpath]; 

I know this is an image search because it prints the size of the image in its error in the log. I cannot find anyone else who has seen this error message on Google.

I am currently working on this error by putting the DPad code in front of all the Sprite creation code, which seems to have stopped the error, but I would really like to find out why this is happening. Sporadic errors are very nervous until I can understand them.

+4
source share
2 answers

Wow, so this is weird. Somewhere in my code, I had max instead of max , and this caused all kinds of chaos in all my code. Three inexplicable errors for which I complained the last few days, all this disappeared after this change. For some reason, using max in my code caused everything from this, before the floatValue returned nil inexplicably, to add an object to the array, you would get an inexplicable error with incorrect access.

Thanks to everyone who helped.

+3
source

This is a long snapshot, but I suspect that xcode is β€œthinking” that the file name in the error is somewhere else. I suggest trying to delete the current photos and rewrite them in your project with a new name that you have not used (testMeNow.jpg) and take a picture.

+1
source

All Articles