Letrstotheprez
Letrstotheprez

Reputation: 622

CCSprite spriteWithFile: returning a nil object

After creating a CCSprite, I am adding it to a layer with this code:

CCSprite *bg1 = [CCSprite spriteWithFile:@"menuback1.png"];
bg1.anchorPoint = ccp(0, 0);
bg1.position = ccp(0, 0);
[self addChild:bg1 z:0];

When the program runs, I get this error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Argument must be non-nil'

After setting a breakpoint near here and checking the value of bg1, I indeed find it to be nil. menuback1.png does exist in the resources folder. I am using cocos2d 2.0 rc0a.

Upvotes: 0

Views: 1023

Answers (1)

Richard J. Ross III
Richard J. Ross III

Reputation: 55543

The problem is that the file is not found. Can you navigate to the built products directory and confirm that the file exists? If not, try deleting and re-adding the file.

Upvotes: 3

Related Questions