Public Member Functions | Static Public Member Functions

CCTextureCache Class Reference

#import <CCTextureCache.h>

List of all members.

Public Member Functions

(CCTexture2D *) - addImage:
(void) - addImageAsync:target:selector:
(CCTexture2D *) - addPVRTCImage:bpp:hasAlpha:width:
(CCTexture2D *) - addPVRTCImage:
(CCTexture2D *) - addCGImage:forKey:
(void) - removeAllTextures
(void) - removeUnusedTextures
(void) - removeTexture:
(void) - removeTextureForKey:

Static Public Member Functions

(CCTextureCache *) + sharedTextureCache
(void) + purgeSharedTextureCache

Detailed Description

Singleton that handles the loading of textures Once the texture is loaded, the next time it will return a reference of the previously loaded texture reducing GPU & CPU memory

Definition at line 35 of file CCTextureCache.h.


Member Function Documentation

- (CCTexture2D*) addCGImage: (CGImageRef)  image
forKey: (NSString *)  key 

Returns a Texture2D object given an CGImageRef image If the image was not previously loaded, it will create a new CCTexture2D object and it will return it. Otherwise it will return a reference of a previously loaded image The "key" parameter will be used as the "key" for the cache. If "key" is nil, then a new texture will be created each time.

Since:
v0.8
- (CCTexture2D*) addImage: (NSString *)  fileimage  

Returns a Texture2D object given an file image If the file image was not previously loaded, it will create a new CCTexture2D object and it will return it. It will use the filename as a key. Otherwise it will return a reference of a previosly loaded image. Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif

- (void) addImageAsync: (NSString *)  filename
target: (id)  target
selector: (SEL)  selector 

Returns a Texture2D object given a file image If the file image was not previously loaded, it will create a new CCTexture2D object and it will return it. Otherwise it will load a texture in a new thread, and when the image is loaded, the callback will be called with the Texture2D as a parameter. The callback will be called from the main thread, so it is safe to create any cocos2d object from the callback. Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif

Since:
v0.8
- (CCTexture2D*) addPVRTCImage: (NSString *)  filename  

Returns a Texture2D object given an PVRTC filename If the file image was not previously loaded, it will create a new CCTexture2D object and it will return it. Otherwise it will return a reference of a previosly loaded image

- (CCTexture2D*) addPVRTCImage: (NSString *)  fileimage
bpp: (int)  bpp
hasAlpha: (BOOL)  alpha
width: (int)  w 

Returns a Texture2D object given an PVRTC RAW filename If the file image was not previously loaded, it will create a new CCTexture2D object and it will return it. Otherwise it will return a reference of a previosly loaded image

It can only load square images: width == height, and it must be a power of 2 (128,256,512...) bpp can only be 2 or 4. 2 means more compression but lower quality. hasAlpha: whether or not the image contains alpha channel

+ (void) purgeSharedTextureCache  

purges the cache. It releases the retained instance.

Since:
v0.99.0
- (void) removeAllTextures  

Purges the dictionary of loaded textures. Call this method if you receive the "Memory Warning" In the short term: it will free some resources preventing your app from being killed In the medium term: it will allocate more resources In the long term: it will be the same

- (void) removeTexture: (CCTexture2D *)  tex  

Deletes a texture from the cache given a texture

- (void) removeTextureForKey: (NSString *)  textureKeyName  

Deletes a texture from the cache given a its key name

Since:
v0.99.4
- (void) removeUnusedTextures  

Removes unused textures Textures that have a retain count of 1 will be deleted It is convinient to call this method after when starting a new Scene

Since:
v0.8
+ (CCTextureCache *) sharedTextureCache  

Retruns ths shared instance of the cache


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

cocos2d for iPhone 0.99.4 API Reference - Generated using Doxygen 1.7.1