joybox 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +6 -0
  4. data/Gemfile.lock +27 -0
  5. data/LICENSE +22 -0
  6. data/README.md +86 -0
  7. data/Rakefile +14 -0
  8. data/app/app_delegate.rb +49 -0
  9. data/app/layers/box2d_layer.rb +109 -0
  10. data/app/layers/cocos2d_layer.rb +14 -0
  11. data/app/layers/cocos_motion_layer.rb +145 -0
  12. data/app/layers/menu_layer.rb +59 -0
  13. data/joybox.gemspec +25 -0
  14. data/lib/joybox.rb +47 -0
  15. data/lib/joybox/box2d/body.rb +106 -0
  16. data/lib/joybox/box2d/world.rb +79 -0
  17. data/lib/joybox/cocos2d/actions/actions.rb +7 -0
  18. data/lib/joybox/cocos2d/actions/move.rb +31 -0
  19. data/lib/joybox/cocos2d/actions/repeat.rb +24 -0
  20. data/lib/joybox/cocos2d/actions/rotate.rb +31 -0
  21. data/lib/joybox/cocos2d/actions/scale.rb +31 -0
  22. data/lib/joybox/cocos2d/actions/sequence.rb +22 -0
  23. data/lib/joybox/cocos2d/actions/skew.rb +36 -0
  24. data/lib/joybox/cocos2d/cocos2d.rb +15 -0
  25. data/lib/joybox/cocos2d/common/cg_point.rb +37 -0
  26. data/lib/joybox/cocos2d/common/color.rb +49 -0
  27. data/lib/joybox/cocos2d/common/gc_size.rb +39 -0
  28. data/lib/joybox/cocos2d/common/ns_set.rb +5 -0
  29. data/lib/joybox/cocos2d/common/numeric.rb +14 -0
  30. data/lib/joybox/cocos2d/common/screen.rb +39 -0
  31. data/lib/joybox/cocos2d/common/ui_touch.rb +15 -0
  32. data/lib/joybox/cocos2d/configuration/configuration.rb +68 -0
  33. data/lib/joybox/cocos2d/configuration/file_utils.rb +33 -0
  34. data/lib/joybox/cocos2d/configuration/gl_view.rb +44 -0
  35. data/lib/joybox/cocos2d/configuration/texture_2d.rb +27 -0
  36. data/lib/joybox/cocos2d/core/layer.rb +87 -0
  37. data/lib/joybox/cocos2d/core/node.rb +26 -0
  38. data/lib/joybox/cocos2d/core/physics_sprite.rb +52 -0
  39. data/lib/joybox/cocos2d/core/scene.rb +24 -0
  40. data/lib/joybox/cocos2d/core/sprite.rb +43 -0
  41. data/lib/joybox/cocos2d/core/sprite_batch.rb +24 -0
  42. data/lib/joybox/cocos2d/director.rb +43 -0
  43. data/lib/joybox/cocos2d/macros.rb +234 -0
  44. data/lib/joybox/cocos2d/ui/label.rb +34 -0
  45. data/lib/joybox/cocos2d/ui/menu.rb +25 -0
  46. data/lib/joybox/cocos2d/ui/menu_image.rb +22 -0
  47. data/lib/joybox/cocos2d/ui/menu_label.rb +45 -0
  48. data/lib/joybox/cocos2d/ui/ui.rb +7 -0
  49. data/lib/joybox/version.rb +3 -0
  50. data/resources/box2d/blocks_sprite_sheet.png +0 -0
  51. data/resources/cocos_motion/dot.png +0 -0
  52. data/resources/cocos_motion/dot_selected.png +0 -0
  53. data/resources/cocos_motion/grossini.png +0 -0
  54. data/resources/cocos_motion/grossinis_sister.png +0 -0
  55. data/resources/cocos_motion/grossinis_sister_two.png +0 -0
  56. data/resources/cocos_motion/left_arrow.png +0 -0
  57. data/resources/cocos_motion/left_arrow_selected.png +0 -0
  58. data/resources/cocos_motion/right_arrow.png +0 -0
  59. data/resources/cocos_motion/right_arrow_selected.png +0 -0
  60. data/resources/fps_images-hd.png +0 -0
  61. data/resources/fps_images-ipadhd.png +0 -0
  62. data/resources/fps_images.png +0 -0
  63. data/spec/lib/joybox/cocos2d/cocos2d_spec.rb +7 -0
  64. data/spec/lib/joybox/cocos2d/macros_spec.rb +37 -0
  65. data/spec/main_spec.rb +9 -0
  66. data/vendor/Box2D.framework/Box2D +0 -0
  67. data/vendor/Box2D.framework/Box2D.framework.bridgesupport +166 -0
  68. data/vendor/Box2D.framework/Versions/A/Box2D +0 -0
  69. data/vendor/Box2D.framework/Versions/A/Headers/Collision/B2DContactListener.h +25 -0
  70. data/vendor/Box2D.framework/Versions/A/Headers/Collision/Shapes/B2DEdgeShape.h +17 -0
  71. data/vendor/Box2D.framework/Versions/A/Headers/Collision/Shapes/B2DPolygonShape.h +16 -0
  72. data/vendor/Box2D.framework/Versions/A/Headers/Collision/Shapes/B2DShape.h +15 -0
  73. data/vendor/Box2D.framework/Versions/A/Headers/Dynamics/B2DBody.h +43 -0
  74. data/vendor/Box2D.framework/Versions/A/Headers/Dynamics/B2DWorld.h +41 -0
  75. data/vendor/Box2D.framework/Versions/A/Resources/Box2DConfig.cmake +3 -0
  76. data/vendor/Box2D.framework/Versions/A/Resources/CMakeLists.txt +205 -0
  77. data/vendor/Cocos2D/Cocos2D.bridgesupport +7808 -0
  78. data/vendor/Cocos2D/include/CCAction.h +195 -0
  79. data/vendor/Cocos2D/include/CCActionCamera.h +73 -0
  80. data/vendor/Cocos2D/include/CCActionCatmullRom.h +139 -0
  81. data/vendor/Cocos2D/include/CCActionEase.h +159 -0
  82. data/vendor/Cocos2D/include/CCActionGrid.h +165 -0
  83. data/vendor/Cocos2D/include/CCActionGrid3D.h +205 -0
  84. data/vendor/Cocos2D/include/CCActionInstant.h +227 -0
  85. data/vendor/Cocos2D/include/CCActionInterval.h +431 -0
  86. data/vendor/Cocos2D/include/CCActionManager.h +113 -0
  87. data/vendor/Cocos2D/include/CCActionPageTurn3D.h +42 -0
  88. data/vendor/Cocos2D/include/CCActionProgressTimer.h +59 -0
  89. data/vendor/Cocos2D/include/CCActionTiledGrid.h +211 -0
  90. data/vendor/Cocos2D/include/CCActionTween.h +62 -0
  91. data/vendor/Cocos2D/include/CCAnimation.h +150 -0
  92. data/vendor/Cocos2D/include/CCAnimationCache.h +74 -0
  93. data/vendor/Cocos2D/include/CCArray.h +119 -0
  94. data/vendor/Cocos2D/include/CCAtlasNode.h +96 -0
  95. data/vendor/Cocos2D/include/CCCamera.h +98 -0
  96. data/vendor/Cocos2D/include/CCConfiguration.h +126 -0
  97. data/vendor/Cocos2D/include/CCDirector.h +344 -0
  98. data/vendor/Cocos2D/include/CCDirectorIOS.h +104 -0
  99. data/vendor/Cocos2D/include/CCDrawingPrimitives.h +139 -0
  100. data/vendor/Cocos2D/include/CCES2Renderer.h +83 -0
  101. data/vendor/Cocos2D/include/CCESRenderer.h +54 -0
  102. data/vendor/Cocos2D/include/CCFileUtils.h +188 -0
  103. data/vendor/Cocos2D/include/CCGL.h +72 -0
  104. data/vendor/Cocos2D/include/CCGLProgram.h +150 -0
  105. data/vendor/Cocos2D/include/CCGLView.h +160 -0
  106. data/vendor/Cocos2D/include/CCGrabber.h +44 -0
  107. data/vendor/Cocos2D/include/CCGrid.h +130 -0
  108. data/vendor/Cocos2D/include/CCLabelAtlas.h +68 -0
  109. data/vendor/Cocos2D/include/CCLabelBMFont.h +216 -0
  110. data/vendor/Cocos2D/include/CCLabelTTF.h +132 -0
  111. data/vendor/Cocos2D/include/CCLayer.h +280 -0
  112. data/vendor/Cocos2D/include/CCMenu.h +100 -0
  113. data/vendor/Cocos2D/include/CCMenuItem.h +423 -0
  114. data/vendor/Cocos2D/include/CCMotionStreak.h +87 -0
  115. data/vendor/Cocos2D/include/CCNS.h +54 -0
  116. data/vendor/Cocos2D/include/CCNode+Debug.h +39 -0
  117. data/vendor/Cocos2D/include/CCNode.h +569 -0
  118. data/vendor/Cocos2D/include/CCParallaxNode.h +50 -0
  119. data/vendor/Cocos2D/include/CCParticleBatchNode.h +99 -0
  120. data/vendor/Cocos2D/include/CCParticleExamples.h +95 -0
  121. data/vendor/Cocos2D/include/CCParticleSystem.h +453 -0
  122. data/vendor/Cocos2D/include/CCParticleSystemQuad.h +73 -0
  123. data/vendor/Cocos2D/include/CCProfiling.h +89 -0
  124. data/vendor/Cocos2D/include/CCProgressTimer.h +94 -0
  125. data/vendor/Cocos2D/include/CCProtocols.h +132 -0
  126. data/vendor/Cocos2D/include/CCRenderTexture.h +139 -0
  127. data/vendor/Cocos2D/include/CCScene.h +43 -0
  128. data/vendor/Cocos2D/include/CCScheduler.h +230 -0
  129. data/vendor/Cocos2D/include/CCShaderCache.h +60 -0
  130. data/vendor/Cocos2D/include/CCSprite.h +288 -0
  131. data/vendor/Cocos2D/include/CCSpriteBatchNode.h +138 -0
  132. data/vendor/Cocos2D/include/CCSpriteFrame.h +126 -0
  133. data/vendor/Cocos2D/include/CCSpriteFrameCache.h +121 -0
  134. data/vendor/Cocos2D/include/CCTMXLayer.h +164 -0
  135. data/vendor/Cocos2D/include/CCTMXObjectGroup.h +67 -0
  136. data/vendor/Cocos2D/include/CCTMXTiledMap.h +145 -0
  137. data/vendor/Cocos2D/include/CCTMXXMLParser.h +217 -0
  138. data/vendor/Cocos2D/include/CCTexture2D.h +357 -0
  139. data/vendor/Cocos2D/include/CCTextureAtlas.h +188 -0
  140. data/vendor/Cocos2D/include/CCTextureCache.h +146 -0
  141. data/vendor/Cocos2D/include/CCTexturePVR.h +129 -0
  142. data/vendor/Cocos2D/include/CCTileMapAtlas.h +83 -0
  143. data/vendor/Cocos2D/include/CCTouchDelegateProtocol.h +75 -0
  144. data/vendor/Cocos2D/include/CCTouchDispatcher.h +120 -0
  145. data/vendor/Cocos2D/include/CCTouchHandler.h +93 -0
  146. data/vendor/Cocos2D/include/CCTransition.h +296 -0
  147. data/vendor/Cocos2D/include/CCTransitionPageTurn.h +60 -0
  148. data/vendor/Cocos2D/include/CCTransitionProgress.h +62 -0
  149. data/vendor/Cocos2D/include/CCVertex.h +36 -0
  150. data/vendor/Cocos2D/include/CGPointExtension.h +344 -0
  151. data/vendor/Cocos2D/include/CocosDenshion/CDAudioManager.h +243 -0
  152. data/vendor/Cocos2D/include/CocosDenshion/CDConfig.h +60 -0
  153. data/vendor/Cocos2D/include/CocosDenshion/CDOpenALSupport.h +77 -0
  154. data/vendor/Cocos2D/include/CocosDenshion/CDXPropertyModifierAction.h +45 -0
  155. data/vendor/Cocos2D/include/CocosDenshion/CocosDenshion.h +440 -0
  156. data/vendor/Cocos2D/include/CocosDenshion/SimpleAudioEngine.h +90 -0
  157. data/vendor/Cocos2D/include/NSThread+performBlock.h +22 -0
  158. data/vendor/Cocos2D/include/OpenGL_Internal.h +86 -0
  159. data/vendor/Cocos2D/include/RubyMotionSchedule.h +7 -0
  160. data/vendor/Cocos2D/include/TGAlib.h +55 -0
  161. data/vendor/Cocos2D/include/TransformUtils.h +36 -0
  162. data/vendor/Cocos2D/include/ZipUtils.h +91 -0
  163. data/vendor/Cocos2D/include/base64.h +33 -0
  164. data/vendor/Cocos2D/include/ccCArray.h +229 -0
  165. data/vendor/Cocos2D/include/ccConfig.h +245 -0
  166. data/vendor/Cocos2D/include/ccDeprecated.h +300 -0
  167. data/vendor/Cocos2D/include/ccGLStateCache.h +138 -0
  168. data/vendor/Cocos2D/include/ccMacros.h +353 -0
  169. data/vendor/Cocos2D/include/ccShader_PositionColor_frag.h +12 -0
  170. data/vendor/Cocos2D/include/ccShader_PositionColor_vert.h +17 -0
  171. data/vendor/Cocos2D/include/ccShader_PositionTextureA8Color_frag.h +16 -0
  172. data/vendor/Cocos2D/include/ccShader_PositionTextureA8Color_vert.h +21 -0
  173. data/vendor/Cocos2D/include/ccShader_PositionTextureColorAlphaTest_frag.h +23 -0
  174. data/vendor/Cocos2D/include/ccShader_PositionTextureColor_frag.h +14 -0
  175. data/vendor/Cocos2D/include/ccShader_PositionTextureColor_vert.h +22 -0
  176. data/vendor/Cocos2D/include/ccShader_PositionTexture_frag.h +13 -0
  177. data/vendor/Cocos2D/include/ccShader_PositionTexture_uColor_frag.h +16 -0
  178. data/vendor/Cocos2D/include/ccShader_PositionTexture_uColor_vert.h +18 -0
  179. data/vendor/Cocos2D/include/ccShader_PositionTexture_vert.h +17 -0
  180. data/vendor/Cocos2D/include/ccShader_Position_uColor_frag.h +12 -0
  181. data/vendor/Cocos2D/include/ccShader_Position_uColor_vert.h +19 -0
  182. data/vendor/Cocos2D/include/ccShaders.h +45 -0
  183. data/vendor/Cocos2D/include/ccTypes.h +374 -0
  184. data/vendor/Cocos2D/include/ccUtils.h +36 -0
  185. data/vendor/Cocos2D/include/cocos2d.h +178 -0
  186. data/vendor/Cocos2D/include/kazmath/GL/mat4stack.h +51 -0
  187. data/vendor/Cocos2D/include/kazmath/GL/matrix.h +58 -0
  188. data/vendor/Cocos2D/include/kazmath/aabb.h +53 -0
  189. data/vendor/Cocos2D/include/kazmath/kazmath.h +39 -0
  190. data/vendor/Cocos2D/include/kazmath/mat3.h +75 -0
  191. data/vendor/Cocos2D/include/kazmath/mat4.h +93 -0
  192. data/vendor/Cocos2D/include/kazmath/neon_matrix_impl.h +41 -0
  193. data/vendor/Cocos2D/include/kazmath/plane.h +70 -0
  194. data/vendor/Cocos2D/include/kazmath/quaternion.h +113 -0
  195. data/vendor/Cocos2D/include/kazmath/ray2.h +50 -0
  196. data/vendor/Cocos2D/include/kazmath/utility.h +74 -0
  197. data/vendor/Cocos2D/include/kazmath/vec2.h +64 -0
  198. data/vendor/Cocos2D/include/kazmath/vec3.h +68 -0
  199. data/vendor/Cocos2D/include/kazmath/vec4.h +68 -0
  200. data/vendor/Cocos2D/include/uthash.h +972 -0
  201. data/vendor/Cocos2D/include/utlist.h +490 -0
  202. data/vendor/Cocos2D/libCocosDenshion.a +0 -0
  203. data/vendor/Cocos2D/libcocos2d.a +0 -0
  204. metadata +277 -0
@@ -0,0 +1,188 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2008-2010 Ricardo Quesada
5
+ * Copyright (c) 2011 Zynga Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ */
26
+
27
+ #import "CCTexture2D.h"
28
+ #import "ccTypes.h"
29
+ #import "ccConfig.h"
30
+
31
+ /** A class that implements a Texture Atlas.
32
+ Supported features:
33
+ * The atlas file can be a PVRTC, PNG or any other fomrat supported by Texture2D
34
+ * Quads can be udpated in runtime
35
+ * Quads can be added in runtime
36
+ * Quads can be removed in runtime
37
+ * Quads can be re-ordered in runtime
38
+ * The TextureAtlas capacity can be increased or decreased in runtime
39
+ * OpenGL component: V3F, C4B, T2F.
40
+ The quads are rendered using an OpenGL ES VBO.
41
+ To render the quads using an interleaved vertex array list, you should modify the ccConfig.h file
42
+ */
43
+ @interface CCTextureAtlas : NSObject
44
+ {
45
+ NSUInteger totalQuads_;
46
+ NSUInteger capacity_;
47
+ ccV3F_C4B_T2F_Quad *quads_; // quads to be rendered
48
+ GLushort *indices_;
49
+ CCTexture2D *texture_;
50
+
51
+ GLuint buffersVBO_[2]; //0: vertex 1: indices
52
+ BOOL dirty_; //indicates whether or not the array buffer of the VBO needs to be updated
53
+
54
+ #if CC_TEXTURE_ATLAS_USE_VAO
55
+ GLuint VAOname_;
56
+ #endif
57
+ }
58
+
59
+ /** quantity of quads that are going to be drawn */
60
+ @property (nonatomic,readonly) NSUInteger totalQuads;
61
+ /** quantity of quads that can be stored with the current texture atlas size */
62
+ @property (nonatomic,readonly) NSUInteger capacity;
63
+ /** Texture of the texture atlas */
64
+ @property (nonatomic,retain) CCTexture2D *texture;
65
+ /** Quads that are going to be rendered */
66
+ @property (nonatomic,readwrite) ccV3F_C4B_T2F_Quad *quads;
67
+
68
+ /** creates a TextureAtlas with an filename and with an initial capacity for Quads.
69
+ * The TextureAtlas capacity can be increased in runtime.
70
+ */
71
+ +(id) textureAtlasWithFile:(NSString*)file capacity:(NSUInteger)capacity;
72
+
73
+ /** initializes a TextureAtlas with a filename and with a certain capacity for Quads.
74
+ * The TextureAtlas capacity can be increased in runtime.
75
+ *
76
+ * WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
77
+ */
78
+ -(id) initWithFile: (NSString*) file capacity:(NSUInteger)capacity;
79
+
80
+ /** creates a TextureAtlas with a previously initialized Texture2D object, and
81
+ * with an initial capacity for n Quads.
82
+ * The TextureAtlas capacity can be increased in runtime.
83
+ */
84
+ +(id) textureAtlasWithTexture:(CCTexture2D *)tex capacity:(NSUInteger)capacity;
85
+
86
+ /** initializes a TextureAtlas with a previously initialized Texture2D object, and
87
+ * with an initial capacity for Quads.
88
+ * The TextureAtlas capacity can be increased in runtime.
89
+ *
90
+ * WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
91
+ */
92
+ -(id) initWithTexture:(CCTexture2D *)tex capacity:(NSUInteger)capacity;
93
+
94
+ /** updates a Quad (texture, vertex and color) at a certain index
95
+ * index must be between 0 and the atlas capacity - 1
96
+ @since v0.8
97
+ */
98
+ -(void) updateQuad:(ccV3F_C4B_T2F_Quad*)quad atIndex:(NSUInteger)index;
99
+
100
+ /** Inserts a Quad (texture, vertex and color) at a certain index
101
+ index must be between 0 and the atlas capacity - 1
102
+ @since v0.8
103
+ */
104
+ -(void) insertQuad:(ccV3F_C4B_T2F_Quad*)quad atIndex:(NSUInteger)index;
105
+
106
+ /** Inserts a c array of quads at a given index
107
+ index must be between 0 and the atlas capacity - 1
108
+ this method doesn't enlarge the array when amount + index > totalQuads
109
+ @since v1.1
110
+ */
111
+ -(void) insertQuads:(ccV3F_C4B_T2F_Quad*)quads atIndex:(NSUInteger)index amount:(NSUInteger)amount;
112
+
113
+ /** Removes the quad that is located at a certain index and inserts it at a new index
114
+ This operation is faster than removing and inserting in a quad in 2 different steps
115
+ @since v0.7.2
116
+ */
117
+ -(void) insertQuadFromIndex:(NSUInteger)fromIndex atIndex:(NSUInteger)newIndex;
118
+
119
+ /** removes a quad at a given index number.
120
+ The capacity remains the same, but the total number of quads to be drawn is reduced in 1
121
+ @since v0.7.2
122
+ */
123
+ -(void) removeQuadAtIndex:(NSUInteger) index;
124
+
125
+ /** removes a amount of quads starting from index
126
+ @since 1.1
127
+ */
128
+ - (void) removeQuadsAtIndex:(NSUInteger) index amount:(NSUInteger) amount;
129
+
130
+ /** removes all Quads.
131
+ The TextureAtlas capacity remains untouched. No memory is freed.
132
+ The total number of quads to be drawn will be 0
133
+ @since v0.7.2
134
+ */
135
+ -(void) removeAllQuads;
136
+
137
+ /** resize the capacity of the CCTextureAtlas.
138
+ * The new capacity can be lower or higher than the current one
139
+ * It returns YES if the resize was successful.
140
+ * If it fails to resize the capacity it will return NO with a new capacity of 0.
141
+ */
142
+ -(BOOL) resizeCapacity: (NSUInteger) n;
143
+
144
+ /**
145
+ Used internally by CCParticleBatchNode
146
+ don't use this unless you know what you're doing
147
+ @since 1.1
148
+ */
149
+ - (void) increaseTotalQuadsWith:(NSUInteger) amount;
150
+
151
+ /** Moves an amount of quads from oldIndex at newIndex
152
+ @since v1.1
153
+ */
154
+ -(void) moveQuadsFromIndex:(NSUInteger)oldIndex amount:(NSUInteger) amount atIndex:(NSUInteger)newIndex;
155
+
156
+ /**
157
+ Moves quads from index till totalQuads to the newIndex
158
+ Used internally by CCParticleBatchNode
159
+ This method doesn't enlarge the array if newIndex + quads to be moved > capacity
160
+ @since 1.1
161
+ */
162
+ - (void) moveQuadsFromIndex:(NSUInteger) index to:(NSUInteger) newIndex;
163
+
164
+ /**
165
+ Ensures that after a realloc quads are still empty
166
+ Used internally by CCParticleBatchNode
167
+ @since 1.1
168
+ */
169
+ - (void) fillWithEmptyQuadsFromIndex:(NSUInteger) index amount:(NSUInteger) amount;
170
+
171
+ /** draws n quads
172
+ * n can't be greater than the capacity of the Atlas
173
+ */
174
+
175
+ -(void) drawNumberOfQuads: (NSUInteger) n;
176
+
177
+ /** draws n quads from an index (offset).
178
+ n + start can't be greater than the capacity of the atlas
179
+
180
+ @since v1.0
181
+ */
182
+ -(void) drawNumberOfQuads: (NSUInteger) n fromIndex: (NSUInteger) start;
183
+
184
+ /** draws all the Atlas's Quads
185
+ */
186
+ -(void) drawQuads;
187
+
188
+ @end
@@ -0,0 +1,146 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2008-2010 Ricardo Quesada
5
+ * Copyright (c) 2011 Zynga Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ */
26
+
27
+ #import "ccMacros.h"
28
+
29
+ #ifdef __CC_PLATFORM_IOS
30
+ #import <CoreGraphics/CGImage.h>
31
+ #endif
32
+
33
+ #import <Foundation/Foundation.h>
34
+
35
+ @class CCTexture2D;
36
+
37
+ /** Singleton that handles the loading of textures
38
+ * Once the texture is loaded, the next time it will return
39
+ * a reference of the previously loaded texture reducing GPU & CPU memory
40
+ */
41
+ @interface CCTextureCache : NSObject
42
+ {
43
+ NSMutableDictionary *textures_;
44
+
45
+ dispatch_queue_t _loadingQueue;
46
+ dispatch_queue_t _dictQueue;
47
+ }
48
+
49
+ /** Retruns ths shared instance of the cache */
50
+ + (CCTextureCache *) sharedTextureCache;
51
+
52
+ /** purges the cache. It releases the retained instance.
53
+ @since v0.99.0
54
+ */
55
+ +(void)purgeSharedTextureCache;
56
+
57
+
58
+ /** Returns a Texture2D object given an file image
59
+ * If the file image was not previously loaded, it will create a new CCTexture2D
60
+ * object and it will return it. It will use the filename as a key.
61
+ * Otherwise it will return a reference of a previosly loaded image.
62
+ * Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif
63
+ */
64
+ -(CCTexture2D*) addImage: (NSString*) fileimage;
65
+
66
+ /** Asynchronously, load a texture2d from a file.
67
+ * If the file image was previously loaded, it will use it.
68
+ * 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.
69
+ * The callback will be called in the cocos2d thread, so it is safe to create any cocos2d object from the callback.
70
+ * Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif
71
+ * @since v0.8
72
+ */
73
+ -(void) addImageAsync:(NSString*) filename target:(id)target selector:(SEL)selector;
74
+
75
+ /** Asynchronously, load a texture2d from a file.
76
+ * If the file image was previously loaded, it will use it.
77
+ * Otherwise it will load a texture in a new thread, and when the image is loaded, the block will be called.
78
+ * The callback will be called in the cocos2d thread, so it is safe to create any cocos2d object from the callback.
79
+ * Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif
80
+ * @since v2.0
81
+ */
82
+ -(void) addImageAsync:(NSString*) filename withBlock:(void(^)(CCTexture2D *tex))block;
83
+
84
+
85
+ /** Returns a Texture2D object given an CGImageRef image
86
+ * If the image was not previously loaded, it will create a new CCTexture2D object and it will return it.
87
+ * Otherwise it will return a reference of a previously loaded image
88
+ * The "key" parameter will be used as the "key" for the cache.
89
+ * If "key" is nil, then a new texture will be created each time.
90
+ * @since v0.8
91
+ */
92
+ -(CCTexture2D*) addCGImage: (CGImageRef) image forKey: (NSString *)key;
93
+
94
+ /** Returns an already created texture. Returns nil if the texture doesn't exist.
95
+ @since v0.99.5
96
+ */
97
+ -(CCTexture2D *) textureForKey:(NSString *)key;
98
+
99
+ /** Purges the dictionary of loaded textures.
100
+ * Call this method if you receive the "Memory Warning"
101
+ * In the short term: it will free some resources preventing your app from being killed
102
+ * In the medium term: it will allocate more resources
103
+ * In the long term: it will be the same
104
+ */
105
+ -(void) removeAllTextures;
106
+
107
+ /** Removes unused textures
108
+ * Textures that have a retain count of 1 will be deleted
109
+ * It is convinient to call this method after when starting a new Scene
110
+ * @since v0.8
111
+ */
112
+ -(void) removeUnusedTextures;
113
+
114
+ /** Deletes a texture from the cache given a texture
115
+ */
116
+ -(void) removeTexture: (CCTexture2D*) tex;
117
+
118
+ /** Deletes a texture from the cache given a its key name
119
+ @since v0.99.4
120
+ */
121
+ -(void) removeTextureForKey: (NSString*) textureKeyName;
122
+
123
+ @end
124
+
125
+
126
+ @interface CCTextureCache (PVRSupport)
127
+
128
+ /** Returns a Texture2D object given an PVR filename.
129
+ * If the file image was not previously loaded, it will create a new CCTexture2D
130
+ * object and it will return it. Otherwise it will return a reference of a previosly loaded image
131
+ *
132
+ */
133
+ -(CCTexture2D*) addPVRImage:(NSString*) filename;
134
+
135
+ @end
136
+
137
+
138
+ @interface CCTextureCache (Debug)
139
+ /** Output to CCLOG the current contents of this CCTextureCache
140
+ * This will attempt to calculate the size of each texture, and the total texture memory in use
141
+ *
142
+ * @since v1.0
143
+ */
144
+ -(void) dumpCachedTextureInfo;
145
+
146
+ @end
@@ -0,0 +1,129 @@
1
+ /*
2
+
3
+ File: PVRTexture.h
4
+ Abstract: The PVRTexture class is responsible for loading .pvr files.
5
+
6
+ Version: 1.0
7
+
8
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
9
+ ("Apple") in consideration of your agreement to the following terms, and your
10
+ use, installation, modification or redistribution of this Apple software
11
+ constitutes acceptance of these terms. If you do not agree with these terms,
12
+ please do not use, install, modify or redistribute this Apple software.
13
+
14
+ In consideration of your agreement to abide by the following terms, and subject
15
+ to these terms, Apple grants you a personal, non-exclusive license, under
16
+ Apple's copyrights in this original Apple software (the "Apple Software"), to
17
+ use, reproduce, modify and redistribute the Apple Software, with or without
18
+ modifications, in source and/or binary forms; provided that if you redistribute
19
+ the Apple Software in its entirety and without modifications, you must retain
20
+ this notice and the following text and disclaimers in all such redistributions
21
+ of the Apple Software.
22
+ Neither the name, trademarks, service marks or logos of Apple Inc. may be used
23
+ to endorse or promote products derived from the Apple Software without specific
24
+ prior written permission from Apple. Except as expressly stated in this notice,
25
+ no other rights or licenses, express or implied, are granted by Apple herein,
26
+ including but not limited to any patent rights that may be infringed by your
27
+ derivative works or by other works in which the Apple Software may be
28
+ incorporated.
29
+
30
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
31
+ WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
32
+ WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33
+ PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
34
+ COMBINATION WITH YOUR PRODUCTS.
35
+
36
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
37
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
38
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39
+ ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
40
+ DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
41
+ CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
42
+ APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
+
44
+ Copyright (C) 2008 Apple Inc. All Rights Reserved.
45
+
46
+ */
47
+
48
+ #import <Foundation/Foundation.h>
49
+
50
+ #import "Platforms/CCGL.h"
51
+ #import "CCTexture2D.h"
52
+
53
+
54
+ #pragma mark -
55
+ #pragma mark CCTexturePVR
56
+
57
+ struct CCPVRMipmap {
58
+ unsigned char *address;
59
+ unsigned int len;
60
+ };
61
+
62
+ enum {
63
+ CC_PVRMIPMAP_MAX = 16,
64
+ };
65
+
66
+ /** CCTexturePVR
67
+
68
+ Object that loads PVR images.
69
+
70
+ Supported PVR formats:
71
+ - RGBA8888
72
+ - BGRA8888
73
+ - RGBA4444
74
+ - RGBA5551
75
+ - RGB565
76
+ - A8
77
+ - I8
78
+ - AI88
79
+ - PVRTC 4BPP
80
+ - PVRTC 2BPP
81
+
82
+ Limitations:
83
+ Pre-generated mipmaps, such as PVR textures with mipmap levels embedded in file,
84
+ are only supported if all individual sprites are of _square_ size.
85
+ To use mipmaps with non-square textures, instead call CCTexture2D#generateMipmap on the sheet texture itself
86
+ (and to save space, save the PVR sprite sheet without mip maps included).
87
+ */
88
+ @interface CCTexturePVR : NSObject
89
+ {
90
+ struct CCPVRMipmap mipmaps_[CC_PVRMIPMAP_MAX]; // pointer to mipmap images
91
+ NSUInteger numberOfMipmaps_; // number of mipmap used
92
+
93
+ unsigned int tableFormatIndex_;
94
+ uint32_t width_, height_;
95
+ GLuint name_;
96
+ BOOL hasAlpha_;
97
+
98
+ // cocos2d integration
99
+ BOOL retainName_;
100
+ CCTexture2DPixelFormat format_;
101
+ }
102
+
103
+ /** initializes a CCTexturePVR with a path */
104
+ - (id)initWithContentsOfFile:(NSString *)path;
105
+ /** initializes a CCTexturePVR with an URL */
106
+ - (id)initWithContentsOfURL:(NSURL *)url;
107
+ /** creates and initializes a CCTexturePVR with a path */
108
+ + (id)pvrTextureWithContentsOfFile:(NSString *)path;
109
+ /** creates and initializes a CCTexturePVR with an URL */
110
+ + (id)pvrTextureWithContentsOfURL:(NSURL *)url;
111
+
112
+ /** texture id name */
113
+ @property (nonatomic,readonly) GLuint name;
114
+ /** texture width */
115
+ @property (nonatomic,readonly) uint32_t width;
116
+ /** texture height */
117
+ @property (nonatomic,readonly) uint32_t height;
118
+ /** whether or not the texture has alpha */
119
+ @property (nonatomic,readonly) BOOL hasAlpha;
120
+ /** how many mipmaps the texture has. 1 means one level (level 0 */
121
+ @property (nonatomic, readonly) NSUInteger numberOfMipmaps;
122
+
123
+ // cocos2d integration
124
+ @property (nonatomic,readwrite) BOOL retainName;
125
+ @property (nonatomic,readonly) CCTexture2DPixelFormat format;
126
+
127
+ @end
128
+
129
+