Hiding the images from your game

Sometimes it is needed to hide certain images in your game from opportunists. One possible way of doing it, is to subclass CCTextureCache and override the addImage method.

For example:

//pseudo code
-(CCTexture2D*) addImage:(NSString*)path
{
   if( file_exists( path + ".enc" )  {
       mem = decrypt( path + ".enc", secretKey );
       uiimage = [[UIImage alloc] initWithData:mem];
       texture = [[CCTexture2D alloc] initWithImage:uiimage];
   }
}

Basically, if it finds an encrypted file, it will decrypt it with a secret key. So the .app bundle will have the crypted images, and opportunists won’t be able to look at them easily.

User mhussa created a sample project that includes these ideas. The project includes:

  • CCEncryptedTextureCache.m (subclass of CCTextureCache )
  • CryptUtils.cpp (helper functions to encrypt/decrypt files)
  • The ‘Encrypt’ build phase: It encrypts files at build time. You don’t need to encrypt them manually!

To customize which files to encrypt, you have to edit the ‘Encrypt’ build phase:

  • Xcode -> Targets -> CCRadialTransitionDemo -> Encrypt
  • Right click over ‘Encrypt’ -> Get Info

For further info regarding mhussa’s implementation, please read: How to use CCEncryptedTextureCache

Download: Xcode CCEncryptedTextureCache project

0 Responses to “Hiding the images from your game”


  • No Comments

Leave a Reply




Social Widgets powered by AB-WebLog.com.