|
cocos2d-iphone
1.0.1
Improved Cocos2D API Reference (iOS version) for Kobold2D developers
|
#include <CCTextureCache.h>
Public Member Functions | |
| CCTexture2D * | addImage: (NSString *fileimage) |
| void | addImageAsync:target:selector: (NSString *filename,[target] id target,[selector] SEL selector) |
| CCTexture2D * | addCGImage:forKey: (CGImageRef image,[forKey] NSString *key) |
| CCTexture2D * | textureForKey: (NSString *key) |
| void | removeAllTextures () |
| void | removeUnusedTextures () |
| void | removeTexture: (CCTexture2D *tex) |
| void | removeTextureForKey: (NSString *textureKeyName) |
| void | dumpCachedTextureInfo () |
| CCTexture2D * | addPVRTCImage:bpp:hasAlpha:width: (NSString *fileimage,[bpp] int bpp,[hasAlpha] BOOL alpha,[width] int w) |
| CCTexture2D * | addPVRImage: (NSString *filename) |
Static Public Member Functions | |
| CCTextureCache * | sharedTextureCache () |
| void | purgeSharedTextureCache () |
Protected Attributes | |
| NSMutableDictionary * | textures_ |
| NSLock * | dictLock_ |
| NSLock * | contextLock_ |
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
| CCTexture2D* CCTextureCache::addCGImage:forKey: | ( | CGImageRef | image, |
| [forKey] NSString * | key | ||
| ) | [virtual] |
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.
| CCTexture2D* CCTextureCache::addImage: | ( | NSString * | fileimage | ) | [virtual] |
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 CCTextureCache::addImageAsync:target:selector: | ( | NSString * | filename, |
| [target] id | target, | ||
| [selector] SEL | selector | ||
| ) | [virtual] |
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
| CCTexture2D* CCTextureCache(PVRSupport)::addPVRImage: | ( | NSString * | filename | ) | [virtual] |
Returns a Texture2D object given an PVR 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* CCTextureCache(PVRSupport)::addPVRTCImage:bpp:hasAlpha:width: | ( | NSString * | fileimage, |
| [bpp] int | bpp, | ||
| [hasAlpha] BOOL | alpha, | ||
| [width] int | w | ||
| ) | [virtual] |
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
IMPORTANT: This method is only defined on iOS. It is not supported on the Mac version.
| void CCTextureCache(Debug)::dumpCachedTextureInfo | ( | ) | [virtual] |
Output to CCLOG the current contents of this CCTextureCache This will attempt to calculate the size of each texture, and the total texture memory in use
| void CCTextureCache::purgeSharedTextureCache | ( | ) | [static, virtual] |
purges the cache. It releases the retained instance.
| void CCTextureCache::removeAllTextures | ( | ) | [virtual] |
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 CCTextureCache::removeTexture: | ( | CCTexture2D * | tex | ) | [virtual] |
Deletes a texture from the cache given a texture
| void CCTextureCache::removeTextureForKey: | ( | NSString * | textureKeyName | ) | [virtual] |
Deletes a texture from the cache given a its key name
| void CCTextureCache::removeUnusedTextures | ( | ) | [virtual] |
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
| CCTextureCache * CCTextureCache::sharedTextureCache | ( | ) | [static, virtual] |
Retruns ths shared instance of the cache
| CCTexture2D * CCTextureCache::textureForKey: | ( | NSString * | key | ) | [virtual] |
Returns an already created texture. Returns nil if the texture doesn't exist.