Ios6 雪碧片不适用于视网膜显示

Ios6 雪碧片不适用于视网膜显示,ios6,cocos2d-iphone,sprite-sheet,Ios6,Cocos2d Iphone,Sprite Sheet,我已经为非视网膜显示器创建了一个精灵表,它在模拟器上运行良好。。 我已经使用了代码 -(Void)addSprites{ [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"image.plist"]; CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"image.png"]; [se

我已经为
非视网膜显示器创建了一个
精灵表
,它在模拟器上运行良好。。 我已经使用了代码

 -(Void)addSprites{
     [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"image.plist"];

    CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"image.png"];
    [self addChild:spriteSheet];

 // Load up the frames of our animation
    NSMutableArray *walkAnimFrames = [NSMutableArray array];
    for(int i = 1; i < 5; i++) {
        [walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"image%d.png", i]]];
    }

    CCAnimation *walkAnim = [CCAnimation animationWithSpriteFrames:walkAnimFrames delay:0.20f];
// Create a sprite for our bear

    background = [CCSprite spriteWithSpriteFrameName:@"image1.png"];
    background.position = ccp(280, 175);
    self.walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim]];
    [spriteSheet addChild:background];  
}
 -(void)startAnimation{
    [background runAction:_walkAction];

但是上面的代码在模拟器上运行良好,默认情况下cocos2d使用-hd后缀不是“@2x”。sprite表中的文件名必须相同,没有任何“-hd”或@2x。只是主精灵工作表文件名需要带有后缀“-hd”


myPlist hd.plist

按照给定的步骤操作-

  • 为视网膜和正常分辨率创建两个不同的精灵表

  • 假设您有四个图像image1.png、image2.png、image3.png和image4.png。首先,根据视网膜显示确定它们的大小。然后使用这些图像创建spritesheet和plist。另存为animation@2x.png及animation@2x.plist

  • 然后得到相同的四幅图像,将它们的大小缩小到一半。确保他们的名字保持不变。使用名为animation.png和animation.plist的zwoptex创建图纸

  • 现在你有两种不同版本的spritesheets和Plist,分别用于视网膜和正常。使用以下代码加载它们:

    [[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@“animation.plist”]

    [[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@”animation@2x.plist"];

    现在使用它们。他们会表现得很好

     CCSpriteFrameCache: Frame 'image1.png' not found
    2013-05-03 16:19:49.764  *** Terminating app due to uncaught exception 
    'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object    cannot be nil'
    
    CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"animation.png"];
    [self addChild:spriteSheet];
    
    CCSpriteBatchNode *spriteSheethd = [CCSpriteBatchNode batchNodeWithFile:@"animation@2x.png"];
    [self addChild:spriteSheethd];