If you are using a singleton to store all your animations, I suggest organizing it with these examples in mind.
Singleton Header File
-(void)loadPlayer0Atlas;
@property (strong) SKTextureAtlas *player0Atlas;
@property (strong) SKAction *player0_walk;
@property (strong) SKAction *player0_jump;
@property (strong) SKAction *player0_shoot;
Singleton Implementation File
-(void)loadPlayer0Atlas {
if(self.player0Atlas == nil) {
NSLog(@"loading player0AtlasLoaded");
self.player0Atlas = [SKTextureAtlas atlasNamed:PLAYER0ATLAS_ATLAS_NAME];
[SKTextureAtlas preloadTextureAtlases:[NSArray arrayWithObject:self.player0Atlas] withCompletionHandler:^{
[self loadPlayer0Assets];
}];
} else {
NSLog(@"no load needed for player0AtlasLoaded");
[[NSNotificationCenter defaultCenter]postNotificationName:@"player0AtlasLoaded" object:self];
}
}
-(void)loadPlayer0Assets {
self.player0_walk = [SKAction repeatActionForever:[SKAction animateWithTextures:PLAYER0ATLAS_ANIM_WALK timePerFrame:0.1]];
self.player0_jump = [SKAction animateWithTextures:PLAYER0ATLAS_ANIM_JUMP timePerFrame:0.05];
self.player0_shoot = [SKAction repeatActionForever:[SKAction animateWithTextures:PLAYER0ATLAS_ANIM_SHOOT timePerFrame:0.1]];
[[NSNotificationCenter defaultCenter]postNotificationName:@"player0AtlasLoaded" object:self];
}
The strong class properties keep a reference to your atlas and animations. You can call the loadPlayer0Atlas method to load the atlas and animations. Once loaded, a NSNotification message is delivered letting you know in your (for example) GameScene.
You would call the animations like this:
[playerNode runAction:[singleton player0_walk] withKey:@"animation"];