문제

I dragged a texture atlas into my project. The pictures are named correctly ("heliani_1-9") The animation is running smooth, except for 3 frames, which are displayed as big red cross on a white ground. (See screenshot enclosed)

enter image description here

What is wrong with my code?

Cheers

#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
도움이 되었습니까?

해결책

Go to the product menu, and you will see the Clean option.

Now, hold down the option button on your keyboard and the text should change to Clean build folder...

Choose that option, and it will additionally delete the derivative data folder that caches alot of things including the texture atlas, and I've found to cause problems like you have described. If you rename files in the atlas, thats typically when I have experienced this issue myself.

I don't like that this option is something you kind of have to work for, would be nice to have this second option there WITHOUT having to hold down the option key.

If this doesn't solve the problem, you truly have a naming problem imo.

Note You can also delete the derivative data folders from the Organizer window.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top