Question

I have a sprite animation that is scaled correctly on the iPad, but appears at half-size on the iPad retina (the images are 1024px wide and 20px tall, and should stretch across the entire screen whether on retina or not). I don't want to create an -ipadhd sprite sheet for this animation because the file size is too large and I'm fine if the resolution isn't great. So how can I force it to scale up to twice the size on the retina device so that it stretches across the screen?

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"zapperAnim.plist"];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"zapperAnim.png"];

NSMutableArray *walkAnimFrames = [NSMutableArray array];
NSString *frameName = @"length_0000";

        for (int i=0; i<=6; i++) {
            [walkAnimFrames addObject:
             [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"%@%d.png", frameName, i]]];
        }

        CCAnimation *zapAnim = [CCAnimation animationWithSpriteFrames:walkAnimFrames delay:0.05f];

        self.zapper = [CCPhysicsSprite spriteWithSpriteFrameName:[NSString stringWithFormat:@"%@0.png", frameName]];
        self.zapAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:zapAnim]];
        [self.zapper runAction:self.zapAction];
Was it helpful?

Solution

If using Ipad retina, do this:

    self.zapper.scale = 2.0;

OTHER TIPS

you can check if screen is retina or not if it then set scale 2

if((([[UIScreen mainScreen] respondsToSelector:@selector(scale)] &&
[UIScreen mainScreen].scale > 1))) spr.scale = 2;

After coding for android, I try to keep the device checks to a minimum. I would use something like

self.zapper.scale=winSize.height/self.zapper.contentSize.height;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top