Universal app sprite sheet help

Posts: 8
Joined: 2010.11
Post: #1

I am having difficulty loading sprites from a sprite sheet.

I am making a universal app in cocos2d. I have 4 sizes of each sprite: sprite.png, sprite-hd.png, sprite-ipad.png and sprite-ipadhd.png.

I one folder with iphone art and one folder with ipad art which I populate the sprite sheets using Texture Packer.

When I call the spriteWithSpriteFrameName there is an error:
NSAssert1(frame!=nil, @"Invalid spriteFrameName: %@", spriteFrameName);

Can anyone please tell me the way to do this properly?

- (void) spawnClownBumper
    CGSize winSize = [CCDirector sharedDirector].winSize;
    clownBumperSprite = [CCSprite spriteWithSpriteFrameName:@"clownBumper1.png"];
    clownBumperSprite.position = ccp(-clownBumperSprite.contentSize.width / 2, winSize.height * 0.5);
    [spriteSheet1BatchNode addChild:clownBumperSprite z:1];
    [clownBumperSprite runAction:
     [CCSequence actions:
            [CCEaseOut actionWithAction:
                    [CCMoveBy actionWithDuration:0.5
                                        position:ccp(clownBumperSprite.contentSize.width / 2 + winSize.width * 0.3, 0)] rate:4.0],
                                  [CCEaseInOut actionWithAction:
                                   [CCMoveBy actionWithDuration:0.5 position:ccp(-winSize.width * 0.2, 0)] rate:4.0],nil]];

- (void) setupBatchNode
    NSString *spriteSheet_1_iphonePvrCcz = @"SpriteSheet_1_iphone.pvr.ccz";
    NSString *spriteSheet_1_iphonePlist = @"SpriteSheet_1_iphone.plist";
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        spriteSheet_1_iphonePvrCcz = @"SpriteSheet_1_ipad.pvr.ccz";
        spriteSheet_1_iphonePlist = @"SpriteSheet_1_ipad.plist";
    spriteSheet1BatchNode = [CCSpriteBatchNode batchNodeWithFile:spriteSheet_1_iphonePvrCcz];
    [self addChild:spriteSheet1BatchNode z:1];
    [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:spriteSheet_1_iphonePlist];

Thank you for your time,


So, I have gotten the iphone sprites to work by naming the .pvr.ccz file with the hd suffix (sprite-hd.pvr.ccz) and using just .png for the individual sprites in both iphone sprite sheets. Now, that doesn't work for the ipad. Only the low res image shows up by adding the -ipadhd to the .pvr.ccz (sprite-ipadhd.pvr.ccz) file. So, I make four sprite sheets with the different extensions and name the sprites within the sheets all the same? (.png) I really would love some help with how this should be done. please?

Thank you so much
Quote this message in a reply
Post Reply