.png animation slow performance in spritekit

混江龙づ霸主 提交于 2019-12-06 10:01:25

This is one of many ways to preload:

@implementation GameScene {
SKTextureAtlas *myAtlas1;
BOOL loadingComplete;
}

-(id)initWithSize:(CGSize)size {
    if (self = [super initWithSize:size]) {

    // the usual stuff...

    loadingComplete = false;
    [self loadMyAtlas1];
    }   

    return self;
}

-(void)loadMyAtlas1 {
    myAtlas1 = [SKTextureAtlas atlasNamed:@"MyAtlasName"];
    [SKTextureAtlas preloadTextureAtlases:[NSArray arrayWithObject:myAtlas1] withCompletionHandler:^{
    [self finishedLoading];
    }];
}

-(void)finishedLoading {
    // other stuff you might do here
    loadingComplete = true;
}

-(void)update:(CFTimeInterval)currentTime {
    if(loadingComplete) {
        // run game code
    } else {
        // wait for the water to boil
    }
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!