Sprite Kit动画:Atlas错误

时间:2014-05-07 21:40:02

标签: animation sprite-kit atlas

我将纹理图集拖入我的项目中。图片命名正确(“heliani_1-9”) 动画运行平稳,除了3帧,在白色地面上显示为大红十字。 (见随附的截图)

enter image description here

我的代码出了什么问题?

干杯

#import "MRMPlayer.h"

@implementation MRMPlayer

-(instancetype)init
{
    self = [super init];
    {

        [self setupAnimations];

        [self runAction:[SKAction repeatActionForever:[SKAction animateWithTextures:self.runFrames timePerFrame:0.5 resize:YES restore:NO]] withKey:@"heli"];

        self.name = playerName;
    }
    return self;
}


-(void) setupAnimations{
    self.runFrames = [[NSMutableArray alloc]init];
    SKTextureAtlas *heliAtlas = [SKTextureAtlas atlasNamed:@"heli"];

    for (int i = 0; i < [heliAtlas.textureNames count]; i++) {
        NSString *tempName = [NSString stringWithFormat:@"heliani_%d",i];
        SKTexture *tempTexture = [heliAtlas textureNamed:tempName];
        if(tempTexture) {
            [self.runFrames addObject:tempTexture];
        }
    }
}


@end

1 个答案:

答案 0 :(得分:2)

转到产品菜单,您会看到Clean选项。

现在,按住键盘上的option按钮,文字应更改为Clean build folder...

选择该选项,它还将删除衍生数据文件夹,该文件夹缓存包括纹理图集在内的很多内容,并且我发现会引起您所描述的问题。如果你重命名地图册中的文件,那通常是我自己遇到过这个问题的时候。

我不喜欢这个选项是你必须要工作的东西,很高兴在那里有第二个选项而不必按住选项键。

如果这不能解决问题,那么你真的有一个命名问题imo。

注意 您也可以从管理器窗口中删除衍生数据文件夹。