0
votes

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];
3
which version of cocos2d? Have you tried disabling Retina display mode (see appdelegate) specifically on Retina iPads? That should automatically scale up all content to Retina but could mean rejection by Apple. Apple requires developers to include Retina assets since May.LearnCocos2D
No, the rest of the app uses retina assets. Just this one doesn't need the resolution. Using cocos2d version 0x00020100. So there's no way to just apply a scale factor to this animation?soleil
you could simply set the scale property to 2 on iPad Retina devices, at least for the duration of the animationLearnCocos2D
Set the scale property of which object?soleil
the one you run the animation onLearnCocos2D

3 Answers

0
votes

If using Ipad retina, do this:

    self.zapper.scale = 2.0;
0
votes

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;
0
votes

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;