I want to combine three sprites and display it as a single sprite. I created a empty sprite and added parts but doesn't work properly.
CCNode *stars = [CCNode node];
CCSprite *star1 = [CCSprite spriteWithSpriteFrameName:@"star.png"];
star1.position = ccp(-10, 0);
[stars addChild:star1];
CCSprite *star2 = [CCSprite spriteWithSpriteFrameName:@"star.png"];
star2.position = ccp(0, 0);
[stars addChild:star2];
CCSprite *star3 = [CCSprite spriteWithSpriteFrameName:@"star.png"];
star3.position = ccp(10, 0);
[stars addChild:star3];
[self addChild:stars];
and I got the following exception
erminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid spriteFrameName: star.png'
please help me to figure out.
Are you adding the single sprite like this:
CCSprite *star1 = [CCSprite **spriteWithFile**:@"star.png"];
star1.position = ccp(-10, 0);
[self addChild:star1];
It sounds to me like you are trying to use sprite frames but you haven't loaded any sprite sheets properly or you mean to use spriteWithFile
.
CCNode *stars = [CCNode node];
CCSprite *star1 = [CCSprite spriteWithFile:@"star.png"];
star1.position = ccp(-10, 0);
[stars addChild:star1];
CCSprite *star2 = [CCSprite spriteWithFile:@"star.png"];
star2.position = ccp(0, 0);
[stars addChild:star2];
CCSprite *star3 = [CCSprite spriteWithFile:@"star.png"];
star3.position = ccp(10, 0);
[stars addChild:star3];
[self addChild:stars];
It sounds like there is something wrong with the .png file. Make sure that you have added it to the resources for your project.