CCSpriteFrameCache Class Reference
Inherits from | NSObject |
Declared in | CCSpriteFrameCache.h |
Overview
Singleton that handles the loading of the sprite frames. It saves in a cache the sprite frames.
Tasks
Other Methods
-
+ sharedSpriteFrameCache
Retruns ths shared instance of the Sprite Frame cache
-
+ purgeSharedSpriteFrameCache
Purges the cache. It releases all the Sprite Frames and the retained instance.
-
– addSpriteFramesWithFile:
Adds multiple Sprite Frames from a plist file. A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png . If you want to use another texture, you should use the addSpriteFramesWithFile:texture method.
-
– addSpriteFramesWithFile:textureFilename:
Adds multiple Sprite Frames from a plist file. The texture filename will be associated with the created sprite frames.
-
– addSpriteFramesWithFile:texture:
Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames.
-
– addSpriteFrame:name:
Adds an sprite frame with a given name. If the name already exists, then the contents of the old name will be replaced with the new one.
-
– removeSpriteFrames
Purges the dictionary of loaded sprite frames. 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.
-
– removeUnusedSpriteFrames
Removes unused sprite frames. Sprite Frames that have a retain count of 1 will be deleted. It is convenient to call this method after when starting a new Scene.
-
– removeSpriteFrameByName:
Deletes an sprite frame from the sprite frame cache.
-
– removeSpriteFramesFromFile:
Removes multiple Sprite Frames from a plist file. Sprite Frames stored in this file will be removed. It is convenient to call this method when a specific texture needs to be removed.
-
– removeSpriteFramesFromTexture:
Removes all Sprite Frames associated with the specified textures. It is convenient to call this method when a specific texture needs to be removed.
-
– spriteFrameByName:
Returns an Sprite Frame that was previously added. If the name is not found it will return nil. You should retain the returned copy if you are going to use it.
Other Methods
-
– addSpriteFramesWithDictionary:texture:
Adds multiple Sprite Frames with a dictionary. The texture will be associated with the created sprite frames.
-
– createSpriteWithFrameName:
Creates an sprite with the name of an sprite frame. The created sprite will contain the texture, rect and offset of the sprite frame. It returns an autorelease object. (Deprecated: use [CCSprite spriteWithSpriteFrameName:name]. This method will be removed on final v0.9)
Deprecated Methods
Class Methods
Instance Methods
addSpriteFrame:name:
Adds an sprite frame with a given name. If the name already exists, then the contents of the old name will be replaced with the new one.
- (void)addSpriteFrame:(CCSpriteFrame *)frame name:(NSString *)frameName
Declared In
CCSpriteFrameCache.h
addSpriteFramesWithDictionary:texture:
Adds multiple Sprite Frames with a dictionary. The texture will be associated with the created sprite frames.
- (void)addSpriteFramesWithDictionary:(NSDictionary *)dictionary texture:(CCTexture2D *)texture
Declared In
CCSpriteFrameCache.h
addSpriteFramesWithFile:
Adds multiple Sprite Frames from a plist file. A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png . If you want to use another texture, you should use the addSpriteFramesWithFile:texture method.
- (void)addSpriteFramesWithFile:(NSString *)plist
Declared In
CCSpriteFrameCache.h
addSpriteFramesWithFile:texture:
Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames.
- (void)addSpriteFramesWithFile:(NSString *)plist texture:(CCTexture2D *)texture
Declared In
CCSpriteFrameCache.h
addSpriteFramesWithFile:textureFilename:
Adds multiple Sprite Frames from a plist file. The texture filename will be associated with the created sprite frames.
- (void)addSpriteFramesWithFile:(NSString *)plist textureFilename:(NSString *)filename
Declared In
CCSpriteFrameCache.h
createSpriteWithFrameName:
Creates an sprite with the name of an sprite frame. The created sprite will contain the texture, rect and offset of the sprite frame. It returns an autorelease object. (Deprecated: use [CCSprite spriteWithSpriteFrameName:name]. This method will be removed on final v0.9)
- (CCSprite *)createSpriteWithFrameName:(NSString *)name
Declared In
CCSpriteFrameCache.h
removeSpriteFrameByName:
Deletes an sprite frame from the sprite frame cache.
- (void)removeSpriteFrameByName:(NSString *)name
Declared In
CCSpriteFrameCache.h
removeSpriteFrames
Purges the dictionary of loaded sprite frames. 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)removeSpriteFrames
Declared In
CCSpriteFrameCache.h
removeSpriteFramesFromFile:
Removes multiple Sprite Frames from a plist file. Sprite Frames stored in this file will be removed. It is convenient to call this method when a specific texture needs to be removed.
- (void)removeSpriteFramesFromFile:(NSString *)plist
Availability
Declared In
CCSpriteFrameCache.h
removeSpriteFramesFromTexture:
Removes all Sprite Frames associated with the specified textures. It is convenient to call this method when a specific texture needs to be removed.
- (void)removeSpriteFramesFromTexture:(CCTexture2D *)texture
Availability
Declared In
CCSpriteFrameCache.h