0

I have some encrypted images.. They are pretty heavy, so I want to preload them by adding them to CCTextureCache. However CCTextureCache does not accept CCTexture2D as a parameter.. What can I do?

CCTexture2D *img = [[[CCTexture2D alloc] initWithImage:[UIImage imageWithContentsOfEncryptedFile:path]] autorelease];

        [[CCTextureCache sharedTextureCache] addImage:img]; // not accepted!!
user123
  • 2,711
  • 5
  • 21
  • 25

1 Answers1

1

Two options:

  • add a method to cache CCTexture2D* objects with a key (unique string)
  • save the UIImage to disk (in Application Support directory), then load it as normal with cocos2d

The latter option will cause a notable delay due to the save & load process. I'd recommend the first approach. Most of the code you need to write that function is already in CCTextureCache, I believe there may even be just the method you need that only needs to be made public in the interface.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217