diff options
Diffstat (limited to 'libs/cocos2d/CCSpriteFrameCache.h')
-rwxr-xr-x | libs/cocos2d/CCSpriteFrameCache.h | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/libs/cocos2d/CCSpriteFrameCache.h b/libs/cocos2d/CCSpriteFrameCache.h new file mode 100755 index 0000000..d3119a6 --- /dev/null +++ b/libs/cocos2d/CCSpriteFrameCache.h | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org | ||
3 | * | ||
4 | * Copyright (c) 2009 Jason Booth | ||
5 | * | ||
6 | * Copyright (c) 2009 Robert J Payne | ||
7 | * | ||
8 | * Copyright (c) 2008-2010 Ricardo Quesada | ||
9 | * Copyright (c) 2011 Zynga Inc. | ||
10 | * | ||
11 | * | ||
12 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
13 | * of this software and associated documentation files (the "Software"), to deal | ||
14 | * in the Software without restriction, including without limitation the rights | ||
15 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
16 | * copies of the Software, and to permit persons to whom the Software is | ||
17 | * furnished to do so, subject to the following conditions: | ||
18 | * | ||
19 | * The above copyright notice and this permission notice shall be included in | ||
20 | * all copies or substantial portions of the Software. | ||
21 | * | ||
22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
28 | * THE SOFTWARE. | ||
29 | * | ||
30 | */ | ||
31 | |||
32 | |||
33 | /* | ||
34 | * To create sprite frames and texture atlas, use this tool: | ||
35 | * http://zwoptex.zwopple.com/ | ||
36 | */ | ||
37 | |||
38 | #import <Foundation/Foundation.h> | ||
39 | |||
40 | #import "CCSpriteFrame.h" | ||
41 | #import "CCTexture2D.h" | ||
42 | |||
43 | @class CCSprite; | ||
44 | |||
45 | /** Singleton that handles the loading of the sprite frames. | ||
46 | It saves in a cache the sprite frames. | ||
47 | @since v0.9 | ||
48 | */ | ||
49 | @interface CCSpriteFrameCache : NSObject | ||
50 | { | ||
51 | NSMutableDictionary *spriteFrames_; | ||
52 | NSMutableDictionary *spriteFramesAliases_; | ||
53 | } | ||
54 | |||
55 | /** Retruns ths shared instance of the Sprite Frame cache */ | ||
56 | + (CCSpriteFrameCache *) sharedSpriteFrameCache; | ||
57 | |||
58 | /** Purges the cache. It releases all the Sprite Frames and the retained instance. | ||
59 | */ | ||
60 | +(void)purgeSharedSpriteFrameCache; | ||
61 | |||
62 | |||
63 | /** Adds multiple Sprite Frames with a dictionary. The texture will be associated with the created sprite frames. | ||
64 | */ | ||
65 | -(void) addSpriteFramesWithDictionary:(NSDictionary*)dictionary texture:(CCTexture2D*)texture; | ||
66 | |||
67 | /** Adds multiple Sprite Frames from a plist file. | ||
68 | * A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png | ||
69 | * If you want to use another texture, you should use the addSpriteFramesWithFile:texture method. | ||
70 | */ | ||
71 | -(void) addSpriteFramesWithFile:(NSString*)plist; | ||
72 | |||
73 | /** Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames. | ||
74 | */ | ||
75 | -(void) addSpriteFramesWithFile:(NSString*)plist texture:(CCTexture2D*)texture; | ||
76 | |||
77 | /** Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames. | ||
78 | @since v0.99.5 | ||
79 | */ | ||
80 | -(void) addSpriteFramesWithFile:(NSString*)plist textureFile:(NSString*)textureFileName; | ||
81 | |||
82 | /** Adds an sprite frame with a given name. | ||
83 | If the name already exists, then the contents of the old name will be replaced with the new one. | ||
84 | */ | ||
85 | -(void) addSpriteFrame:(CCSpriteFrame*)frame name:(NSString*)frameName; | ||
86 | |||
87 | |||
88 | /** Purges the dictionary of loaded sprite frames. | ||
89 | * Call this method if you receive the "Memory Warning". | ||
90 | * In the short term: it will free some resources preventing your app from being killed. | ||
91 | * In the medium term: it will allocate more resources. | ||
92 | * In the long term: it will be the same. | ||
93 | */ | ||
94 | -(void) removeSpriteFrames; | ||
95 | |||
96 | /** Removes unused sprite frames. | ||
97 | * Sprite Frames that have a retain count of 1 will be deleted. | ||
98 | * It is convinient to call this method after when starting a new Scene. | ||
99 | */ | ||
100 | -(void) removeUnusedSpriteFrames; | ||
101 | |||
102 | /** Deletes an sprite frame from the sprite frame cache. | ||
103 | */ | ||
104 | -(void) removeSpriteFrameByName:(NSString*)name; | ||
105 | |||
106 | /** Removes multiple Sprite Frames from a plist file. | ||
107 | * Sprite Frames stored in this file will be removed. | ||
108 | * It is convinient to call this method when a specific texture needs to be removed. | ||
109 | * @since v0.99.5 | ||
110 | */ | ||
111 | - (void) removeSpriteFramesFromFile:(NSString*) plist; | ||
112 | |||
113 | /** Removes multiple Sprite Frames from NSDictionary. | ||
114 | * @since v0.99.5 | ||
115 | */ | ||
116 | - (void) removeSpriteFramesFromDictionary:(NSDictionary*) dictionary; | ||
117 | |||
118 | /** Removes all Sprite Frames associated with the specified textures. | ||
119 | * It is convinient to call this method when a specific texture needs to be removed. | ||
120 | * @since v0.995. | ||
121 | */ | ||
122 | - (void) removeSpriteFramesFromTexture:(CCTexture2D*) texture; | ||
123 | |||
124 | /** Returns an Sprite Frame that was previously added. | ||
125 | If the name is not found it will return nil. | ||
126 | You should retain the returned copy if you are going to use it. | ||
127 | */ | ||
128 | -(CCSpriteFrame*) spriteFrameByName:(NSString*)name; | ||
129 | |||
130 | /** Creates an sprite with the name of an sprite frame. | ||
131 | The created sprite will contain the texture, rect and offset of the sprite frame. | ||
132 | It returns an autorelease object. | ||
133 | @deprecated use [CCSprite spriteWithSpriteFrameName:name]. This method will be removed on final v0.9 | ||
134 | */ | ||
135 | -(CCSprite*) createSpriteWithFrameName:(NSString*)name DEPRECATED_ATTRIBUTE; | ||
136 | |||
137 | @end | ||