TextureAtlas tool not reading Texture atlas - SpriteKit Texture Atlas Generator Error

会有一股神秘感。 提交于 2019-12-11 05:33:58

问题


I am trying to make a node with a simple animation, so I created a animation with each individual frame as a .png file, I stuck them all in a folder, and named it stoneanimation2.atlas .

This is the code I tried:

SKTextureAtlas *atlas = [SKTextureAtlas atlasNamed:@"stoneanimation2"];


    SKTexture *stone2 = [atlas textureNamed:@"stone2.png"];
    SKTexture *stone3 = [atlas textureNamed:@"stone3.png"];
    SKTexture *stone4 = [atlas textureNamed:@"stone4.png"];
    SKTexture *stone5 = [atlas textureNamed:@"stone5.png"];
    SKTexture *stone6 = [atlas textureNamed:@"stone6.png"];
    SKTexture *stone7 = [atlas textureNamed:@"stone7.png"];
    SKTexture *stone8 = [atlas textureNamed:@"stone8.png"];
    SKTexture *stone9 = [atlas textureNamed:@"stone9.png"];
    SKTexture *stone10 = [atlas textureNamed:@"stone10.png"];
    SKTexture *stone11 = [atlas textureNamed:@"stone11.png"];
    SKTexture *stone12 = [atlas textureNamed:@"stone12.png"];
    SKTexture *stone13 = [atlas textureNamed:@"stone13.png"];
    SKTexture *stone14 = [atlas textureNamed:@"stone14.png"];
    SKTexture *stone15 = [atlas textureNamed:@"stone15.png"];
    SKTexture *stone16 = [atlas textureNamed:@"stone16.png"];
    SKTexture *stone17 = [atlas textureNamed:@"stone17.png"];
    SKTexture *stone18 = [atlas textureNamed:@"stone18.png"];
    SKTexture *stone20 = [atlas textureNamed:@"stone20.png"];
    SKTexture *stone21 = [atlas textureNamed:@"stone21.png"];
    SKTexture *stone22 = [atlas textureNamed:@"stone22.png"];
    SKTexture *stone23 = [atlas textureNamed:@"stone23.png"];
    SKTexture *stone24 = [atlas textureNamed:@"stone24.png"];
    SKTexture *stone25 = [atlas textureNamed:@"stone25.png"];
    SKTexture *stone26 = [atlas textureNamed:@"stone26.png"];
    SKTexture *stone27 = [atlas textureNamed:@"stone27.png"];
    SKTexture *stone28 = [atlas textureNamed:@"stone28.png"];

    NSArray *atlasTexture = @[stone2,stone3,stone4,stone5,stone6,stone7,stone8,stone9,stone10,stone11,stone12,stone13,stone14,stone15,stone16,stone17,stone18,stone20,stone21,stone22,stone23,stone24,stone25,stone26,stone27,stone28];

    stoneAnimation = [SKAction animateWithTextures:atlasTexture timePerFrame:.01];

It worked before, when I only had about 10 frames. But I decided to add more, and I think it messed something up with the atlas itself, because Xcode says "SpriteKit Texture Atlas Generator Error" This is the error message:

Command /Applications/Xcode.app/Contents/Developer/Tools/../usr/bin/TextureAtlas failed with exit code 11

Every time that I completely make a new atlas, or just rename it, to see if that works, I get the same error. Also, in build settings, I have "Enable Atlas Generator" set to "YES". And I have tried reseting the IOS simulator, and everything I can think of! Please Help!


回答1:


This error happened to me when I had too many large images in my texture atlas. After splitting it into two separate atlases, the game built fine.




回答2:


I figured out that my problem was that the texture atlas was not imported correctly, I think it was because I imported it before correctly and then changed it. So I got a ? by the texture atlas in the project navigator. I didn't need to change any code, all I did was right click the texture atlas and click: source control > add selected file.

It had nothing to do with my code




回答3:


Add property NSArray *_stoneFrames;

-(void)addObject
 {
  NSMutableArray *stoneAnimationFrames = [NSMutableArray array];
  SKTextureAtlas *stoneAnimatedAtlas = [SKTextureAtlas atlasNamed:@"stoneanimation2"];
  int numImages = stoneAnimatedAtlas.textureNames.count;
  for (int i=1; i <= numImages; i++) {
    NSString *textureName = [NSString stringWithFormat:@"stone%d", i];
    SKTexture *temp = [stoneAnimatedAtlas textureNamed:textureName];
    [stoneAnimationFrames addObject:temp];
  }
 _stoneFrames = stoneAnimationFrames;
 SKTexture *temp = _stoneFrames[0];
 _stone = [SKSpriteNode spriteNodeWithTexture:temp];
 [self addChild:_stone];
 [self animateStone];
}

-(void)animateStone
 {
      [_stone runAction:[SKAction repeatActionForever:
                  [SKAction animateWithTextures:_stoneFrames
                                   timePerFrame:0.1f
                                         resize:NO
                                        restore:YES]] withKey:@"animated Stone"];
    return;
}

You can also checkout this blog post http://www.raywenderlich.com/45152/sprite-kit-tutorial-animations-and-texture-atlases



来源:https://stackoverflow.com/questions/22213422/textureatlas-tool-not-reading-texture-atlas-spritekit-texture-atlas-generator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!