I'm trying to create a preload, but i don't know how to implement the code of this topic in cocos2d iphone v3. Since CCTextureCache has changed to CCTexture, and doesn't have sharedTextureCache property anymore.
@interface TextureHelper : NSObject
+ (void) preloadTextures;
+ (CCTexture2D *) textureForImageNamed:(NSString *) imageName;
@end
@implementation TextureHelper
+ (CCTexture2D *) textureForImageNamed:(NSString *) imageName {
return [[CCTextureCache sharedTextureCache] textureForKey:imageName];
}
+ (void) preloadTextures {
// or could read from a directory...
NSArray *imageNames = @[
@"myImage1.png",
@"myImage2.png"
];
for (NSString *imageName in imageNames)
[[CCTextureCache sharedTextureCache] addImage:imageName];
}
@end