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,67 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2010 Neophit
5
+ *
6
+ * Copyright (c) 2010 Ricardo Quesada
7
+ * Copyright (c) 2011 Zynga Inc.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in
17
+ * all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ * THE SOFTWARE.
26
+ *
27
+ *
28
+ * TMX Tiled Map support:
29
+ * http://www.mapeditor.org
30
+ *
31
+ */
32
+
33
+ #import "CCNode.h"
34
+
35
+
36
+ @class CCTMXObjectGroup;
37
+
38
+
39
+ /** CCTMXObjectGroup represents the TMX object group.
40
+ @since v0.99.0
41
+ */
42
+ @interface CCTMXObjectGroup : NSObject
43
+ {
44
+ NSString *groupName_;
45
+ CGPoint positionOffset_;
46
+ NSMutableArray *objects_;
47
+ NSMutableDictionary *properties_;
48
+ }
49
+
50
+ /** name of the group */
51
+ @property (nonatomic,readwrite,retain) NSString *groupName;
52
+ /** offset position of child objects */
53
+ @property (nonatomic,readwrite,assign) CGPoint positionOffset;
54
+ /** array of the objects */
55
+ @property (nonatomic,readwrite,retain) NSMutableArray *objects;
56
+ /** list of properties stored in a dictionary */
57
+ @property (nonatomic,readwrite,retain) NSMutableDictionary *properties;
58
+
59
+ /** return the value for the specific property name */
60
+ -(id) propertyNamed:(NSString *)propertyName;
61
+
62
+ /** return the dictionary for the specific object name.
63
+ It will return the 1st object found on the array for the given name.
64
+ */
65
+ -(NSMutableDictionary*) objectNamed:(NSString *)objectName;
66
+
67
+ @end
@@ -0,0 +1,145 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2009-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
+ * TMX Tiled Map support:
27
+ * http://www.mapeditor.org
28
+ *
29
+ */
30
+
31
+ #import "CCNode.h"
32
+
33
+ @class CCTMXLayer;
34
+ @class CCTMXObjectGroup;
35
+
36
+ /** Possible oritentations of the TMX map */
37
+ enum
38
+ {
39
+ /** Orthogonal orientation */
40
+ CCTMXOrientationOrtho,
41
+
42
+ /** Hexagonal orientation */
43
+ CCTMXOrientationHex,
44
+
45
+ /** Isometric orientation */
46
+ CCTMXOrientationIso,
47
+ };
48
+
49
+ /** CCTMXTiledMap knows how to parse and render a TMX map.
50
+
51
+ It adds support for the TMX tiled map format used by http://www.mapeditor.org
52
+ It supports isometric, hexagonal and orthogonal tiles.
53
+ It also supports object groups, objects, and properties.
54
+
55
+ Features:
56
+ - Each tile will be treated as an CCSprite
57
+ - The sprites are created on demand. They will be created only when you call "[layer tileAt:]"
58
+ - Each tile can be rotated / moved / scaled / tinted / "opacitied", since each tile is a CCSprite
59
+ - Tiles can be added/removed in runtime
60
+ - The z-order of the tiles can be modified in runtime
61
+ - Each tile has an anchorPoint of (0,0)
62
+ - The anchorPoint of the TMXTileMap is (0,0)
63
+ - The TMX layers will be added as a child
64
+ - The TMX layers will be aliased by default
65
+ - The tileset image will be loaded using the CCTextureCache
66
+ - Each tile will have a unique tag
67
+ - Each tile will have a unique z value. top-left: z=1, bottom-right: z=max z
68
+ - Each object group will be treated as an NSMutableArray
69
+ - Object class which will contain all the properties in a dictionary
70
+ - Properties can be assigned to the Map, Layer, Object Group, and Object
71
+
72
+ Limitations:
73
+ - It only supports one tileset per layer.
74
+ - Embeded images are not supported
75
+ - It only supports the XML format (the JSON format is not supported)
76
+
77
+ Technical description:
78
+ Each layer is created using an CCTMXLayer (subclass of CCSpriteBatchNode). If you have 5 layers, then 5 CCTMXLayer will be created,
79
+ unless the layer visibility is off. In that case, the layer won't be created at all.
80
+ You can obtain the layers (CCTMXLayer objects) at runtime by:
81
+ - [map getChildByTag: tag_number]; // 0=1st layer, 1=2nd layer, 2=3rd layer, etc...
82
+ - [map layerNamed: name_of_the_layer];
83
+
84
+ Each object group is created using a CCTMXObjectGroup which is a subclass of NSMutableArray.
85
+ You can obtain the object groups at runtime by:
86
+ - [map objectGroupNamed: name_of_the_object_group];
87
+
88
+ Each object is a CCTMXObject.
89
+
90
+ Each property is stored as a key-value pair in an NSMutableDictionary.
91
+ You can obtain the properties at runtime by:
92
+
93
+ [map propertyNamed: name_of_the_property];
94
+ [layer propertyNamed: name_of_the_property];
95
+ [objectGroup propertyNamed: name_of_the_property];
96
+ [object propertyNamed: name_of_the_property];
97
+
98
+ @since v0.8.1
99
+ */
100
+ @interface CCTMXTiledMap : CCNode
101
+ {
102
+ CGSize mapSize_;
103
+ CGSize tileSize_;
104
+ int mapOrientation_;
105
+ NSMutableArray *objectGroups_;
106
+ NSMutableDictionary *properties_;
107
+ NSMutableDictionary *tileProperties_;
108
+ }
109
+
110
+ /** the map's size property measured in tiles */
111
+ @property (nonatomic,readonly) CGSize mapSize;
112
+ /** the tiles's size property measured in pixels */
113
+ @property (nonatomic,readonly) CGSize tileSize;
114
+ /** map orientation */
115
+ @property (nonatomic,readonly) int mapOrientation;
116
+ /** object groups */
117
+ @property (nonatomic,readwrite,retain) NSMutableArray *objectGroups;
118
+ /** properties */
119
+ @property (nonatomic,readwrite,retain) NSMutableDictionary *properties;
120
+
121
+ /** creates a TMX Tiled Map with a TMX file.*/
122
+ +(id) tiledMapWithTMXFile:(NSString*)tmxFile;
123
+
124
+ /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */
125
+ +(id) tiledMapWithXML:(NSString*)tmxString resourcePath:(NSString*)resourcePath;
126
+
127
+ /** initializes a TMX Tiled Map with a TMX file */
128
+ -(id) initWithTMXFile:(NSString*)tmxFile;
129
+
130
+ /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */
131
+ -(id) initWithXML:(NSString*)tmxString resourcePath:(NSString*)resourcePath;
132
+
133
+ /** return the TMXLayer for the specific layer */
134
+ -(CCTMXLayer*) layerNamed:(NSString *)layerName;
135
+
136
+ /** return the TMXObjectGroup for the secific group */
137
+ -(CCTMXObjectGroup*) objectGroupNamed:(NSString *)groupName;
138
+
139
+ /** return the value for the specific property name */
140
+ -(id) propertyNamed:(NSString *)propertyName;
141
+
142
+ /** return properties dictionary for tile GID */
143
+ -(NSDictionary*)propertiesForGID:(unsigned int)GID;
144
+ @end
145
+
@@ -0,0 +1,217 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2009-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
+ * TMX Tiled Map support:
27
+ * http://www.mapeditor.org
28
+ *
29
+ */
30
+
31
+ /*
32
+ * Internal TMX parser
33
+ *
34
+ * IMPORTANT: These classed should not be documented using doxygen strings
35
+ * since the user should not use them.
36
+ *
37
+ */
38
+
39
+
40
+ #import <Foundation/Foundation.h>
41
+
42
+ #import "ccMacros.h"
43
+
44
+ enum {
45
+ TMXLayerAttribNone = 1 << 0,
46
+ TMXLayerAttribBase64 = 1 << 1,
47
+ TMXLayerAttribGzip = 1 << 2,
48
+ TMXLayerAttribZlib = 1 << 3,
49
+ };
50
+
51
+ enum {
52
+ TMXPropertyNone,
53
+ TMXPropertyMap,
54
+ TMXPropertyLayer,
55
+ TMXPropertyObjectGroup,
56
+ TMXPropertyObject,
57
+ TMXPropertyTile
58
+ };
59
+
60
+ typedef enum ccTMXTileFlags_ {
61
+ kCCTMXTileHorizontalFlag = 0x80000000,
62
+ kCCTMXTileVerticalFlag = 0x40000000,
63
+ kCCTMXTileDiagonalFlag = 0x20000000,
64
+
65
+ kCCFlipedAll = (kCCTMXTileHorizontalFlag|kCCTMXTileVerticalFlag|kCCTMXTileDiagonalFlag),
66
+ kCCFlippedMask = ~(kCCFlipedAll),
67
+ } ccTMXTileFlags;
68
+
69
+ // Bits on the far end of the 32-bit global tile ID (GID's) are used for tile flags
70
+
71
+ /* CCTMXLayerInfo contains the information about the layers like:
72
+ - Layer name
73
+ - Layer size
74
+ - Layer opacity at creation time (it can be modified at runtime)
75
+ - Whether the layer is visible (if it is not visible, then the CCNode won't be created)
76
+
77
+ This information is obtained from the TMX file.
78
+ */
79
+ @interface CCTMXLayerInfo : NSObject
80
+ {
81
+ NSString *name_;
82
+ CGSize layerSize_;
83
+ unsigned int *tiles_;
84
+ BOOL visible_;
85
+ unsigned char opacity_;
86
+ BOOL ownTiles_;
87
+ unsigned int minGID_;
88
+ unsigned int maxGID_;
89
+ NSMutableDictionary *properties_;
90
+ CGPoint offset_;
91
+ }
92
+
93
+ @property (nonatomic,readwrite,retain) NSString *name;
94
+ @property (nonatomic,readwrite) CGSize layerSize;
95
+ @property (nonatomic,readwrite) unsigned int *tiles;
96
+ @property (nonatomic,readwrite) BOOL visible;
97
+ @property (nonatomic,readwrite) unsigned char opacity;
98
+ @property (nonatomic,readwrite) BOOL ownTiles;
99
+ @property (nonatomic,readwrite) unsigned int minGID;
100
+ @property (nonatomic,readwrite) unsigned int maxGID;
101
+ @property (nonatomic,readwrite,retain) NSMutableDictionary *properties;
102
+ @property (nonatomic,readwrite) CGPoint offset;
103
+ @end
104
+
105
+ /* CCTMXTilesetInfo contains the information about the tilesets like:
106
+ - Tileset name
107
+ - Tilset spacing
108
+ - Tileset margin
109
+ - size of the tiles
110
+ - Image used for the tiles
111
+ - Image size
112
+
113
+ This information is obtained from the TMX file.
114
+ */
115
+ @interface CCTMXTilesetInfo : NSObject
116
+ {
117
+ NSString *name_;
118
+ unsigned int firstGid_;
119
+ CGSize tileSize_;
120
+ unsigned int spacing_;
121
+ unsigned int margin_;
122
+
123
+ // filename containing the tiles (should be spritesheet / texture atlas)
124
+ NSString *sourceImage_;
125
+
126
+ // size in pixels of the image
127
+ CGSize imageSize_;
128
+ }
129
+ @property (nonatomic,readwrite,retain) NSString *name;
130
+ @property (nonatomic,readwrite,assign) unsigned int firstGid;
131
+ @property (nonatomic,readwrite,assign) CGSize tileSize;
132
+ @property (nonatomic,readwrite,assign) unsigned int spacing;
133
+ @property (nonatomic,readwrite,assign) unsigned int margin;
134
+ @property (nonatomic,readwrite,retain) NSString *sourceImage;
135
+ @property (nonatomic,readwrite,assign) CGSize imageSize;
136
+
137
+ -(CGRect) rectForGID:(unsigned int)gid;
138
+ @end
139
+
140
+ /* CCTMXMapInfo contains the information about the map like:
141
+ - Map orientation (hexagonal, isometric or orthogonal)
142
+ - Tile size
143
+ - Map size
144
+
145
+ And it also contains:
146
+ - Layers (an array of TMXLayerInfo objects)
147
+ - Tilesets (an array of TMXTilesetInfo objects)
148
+ - ObjectGroups (an array of TMXObjectGroupInfo objects)
149
+
150
+ This information is obtained from the TMX file.
151
+
152
+ */
153
+ @interface CCTMXMapInfo : NSObject <NSXMLParserDelegate>
154
+ {
155
+ NSMutableString *currentString;
156
+ BOOL storingCharacters;
157
+ int layerAttribs;
158
+ int parentElement;
159
+ unsigned int parentGID_;
160
+
161
+
162
+ // tmx filename
163
+ NSString *filename_;
164
+
165
+ // tmx resource path
166
+ NSString *resources_;
167
+
168
+ // map orientation
169
+ int orientation_;
170
+
171
+ // map width & height
172
+ CGSize mapSize_;
173
+
174
+ // tiles width & height
175
+ CGSize tileSize_;
176
+
177
+ // Layers
178
+ NSMutableArray *layers_;
179
+
180
+ // tilesets
181
+ NSMutableArray *tilesets_;
182
+
183
+ // ObjectGroups
184
+ NSMutableArray *objectGroups_;
185
+
186
+ // properties
187
+ NSMutableDictionary *properties_;
188
+
189
+ // tile properties
190
+ NSMutableDictionary *tileProperties_;
191
+ }
192
+
193
+ @property (nonatomic,readwrite,assign) int orientation;
194
+ @property (nonatomic,readwrite,assign) CGSize mapSize;
195
+ @property (nonatomic,readwrite,assign) CGSize tileSize;
196
+ @property (nonatomic,readwrite,retain) NSMutableArray *layers;
197
+ @property (nonatomic,readwrite,retain) NSMutableArray *tilesets;
198
+ @property (nonatomic,readwrite,retain) NSString *filename;
199
+ @property (nonatomic,readwrite,retain) NSString *resources;
200
+ @property (nonatomic,readwrite,retain) NSMutableArray *objectGroups;
201
+ @property (nonatomic,readwrite,retain) NSMutableDictionary *properties;
202
+ @property (nonatomic,readwrite,retain) NSMutableDictionary *tileProperties;
203
+
204
+ /** creates a TMX Format with a tmx file */
205
+ +(id) formatWithTMXFile:(NSString*)tmxFile;
206
+
207
+ /** creates a TMX Format with an XML string and a TMX resource path */
208
+ +(id) formatWithXML:(NSString*)tmxString resourcePath:(NSString*)resourcePath;
209
+
210
+ /** initializes a TMX format with a tmx file */
211
+ -(id) initWithTMXFile:(NSString*)tmxFile;
212
+
213
+ /** initializes a TMX format with an XML string and a TMX resource path */
214
+ -(id) initWithXML:(NSString*)tmxString resourcePath:(NSString*)resourcePath;
215
+
216
+ @end
217
+
@@ -0,0 +1,357 @@
1
+ /*
2
+
3
+ ===== IMPORTANT =====
4
+
5
+ This is sample code demonstrating API, technology or techniques in development.
6
+ Although this sample code has been reviewed for technical accuracy, it is not
7
+ final. Apple is supplying this information to help you plan for the adoption of
8
+ the technologies and programming interfaces described herein. This information
9
+ is subject to change, and software implemented based on this sample code should
10
+ be tested with final operating system software and final documentation. Newer
11
+ versions of this sample code may be provided with future seeds of the API or
12
+ technology. For information about updates to this and other developer
13
+ documentation, view the New & Updated sidebars in subsequent documentation
14
+ seeds.
15
+
16
+ =====================
17
+
18
+ File: Texture2D.h
19
+ Abstract: Creates OpenGL 2D textures from images or text.
20
+
21
+ Version: 1.6
22
+
23
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
24
+ ("Apple") in consideration of your agreement to the following terms, and your
25
+ use, installation, modification or redistribution of this Apple software
26
+ constitutes acceptance of these terms. If you do not agree with these terms,
27
+ please do not use, install, modify or redistribute this Apple software.
28
+
29
+ In consideration of your agreement to abide by the following terms, and subject
30
+ to these terms, Apple grants you a personal, non-exclusive license, under
31
+ Apple's copyrights in this original Apple software (the "Apple Software"), to
32
+ use, reproduce, modify and redistribute the Apple Software, with or without
33
+ modifications, in source and/or binary forms; provided that if you redistribute
34
+ the Apple Software in its entirety and without modifications, you must retain
35
+ this notice and the following text and disclaimers in all such redistributions
36
+ of the Apple Software.
37
+ Neither the name, trademarks, service marks or logos of Apple Inc. may be used
38
+ to endorse or promote products derived from the Apple Software without specific
39
+ prior written permission from Apple. Except as expressly stated in this notice,
40
+ no other rights or licenses, express or implied, are granted by Apple herein,
41
+ including but not limited to any patent rights that may be infringed by your
42
+ derivative works or by other works in which the Apple Software may be
43
+ incorporated.
44
+
45
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
46
+ WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
47
+ WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
48
+ PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
49
+ COMBINATION WITH YOUR PRODUCTS.
50
+
51
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
52
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
53
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54
+ ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
55
+ DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
56
+ CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
57
+ APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58
+
59
+ Copyright (C) 2008 Apple Inc. All Rights Reserved.
60
+
61
+ */
62
+
63
+ #import <Foundation/Foundation.h> // for NSObject
64
+
65
+ #import "ccTypes.h"
66
+ #import "ccMacros.h"
67
+
68
+ #import "Platforms/CCGL.h" // OpenGL stuff
69
+ #import "Platforms/CCNS.h" // Next-Step stuff
70
+
71
+ //CONSTANTS:
72
+
73
+ /** @typedef CCTexture2DPixelFormat
74
+ Possible texture pixel formats
75
+ */
76
+ typedef enum {
77
+ //! 32-bit texture: RGBA8888
78
+ kCCTexture2DPixelFormat_RGBA8888,
79
+ //! 32-bit texture without Alpha channel. Don't use it.
80
+ kCCTexture2DPixelFormat_RGB888,
81
+ //! 16-bit texture without Alpha channel
82
+ kCCTexture2DPixelFormat_RGB565,
83
+ //! 8-bit textures used as masks
84
+ kCCTexture2DPixelFormat_A8,
85
+ //! 8-bit intensity texture
86
+ kCCTexture2DPixelFormat_I8,
87
+ //! 16-bit textures used as masks
88
+ kCCTexture2DPixelFormat_AI88,
89
+ //! 16-bit textures: RGBA4444
90
+ kCCTexture2DPixelFormat_RGBA4444,
91
+ //! 16-bit textures: RGB5A1
92
+ kCCTexture2DPixelFormat_RGB5A1,
93
+ //! 4-bit PVRTC-compressed texture: PVRTC4
94
+ kCCTexture2DPixelFormat_PVRTC4,
95
+ //! 2-bit PVRTC-compressed texture: PVRTC2
96
+ kCCTexture2DPixelFormat_PVRTC2,
97
+
98
+ //! Default texture format: RGBA8888
99
+ kCCTexture2DPixelFormat_Default = kCCTexture2DPixelFormat_RGBA8888,
100
+
101
+ } CCTexture2DPixelFormat;
102
+
103
+
104
+ @class CCGLProgram;
105
+
106
+ /** CCTexture2D class.
107
+ * This class allows to easily create OpenGL 2D textures from images, text or raw data.
108
+ * The created CCTexture2D object will always have power-of-two dimensions.
109
+ * Depending on how you create the CCTexture2D object, the actual image area of the texture might be smaller than the texture dimensions i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0).
110
+ * Be aware that the content of the generated textures will be upside-down!
111
+ */
112
+ @interface CCTexture2D : NSObject
113
+ {
114
+ GLuint name_;
115
+ CGSize size_;
116
+ NSUInteger width_,
117
+ height_;
118
+ CCTexture2DPixelFormat format_;
119
+ GLfloat maxS_,
120
+ maxT_;
121
+ BOOL hasPremultipliedAlpha_;
122
+ BOOL hasMipmaps_;
123
+
124
+ #ifdef __CC_PLATFORM_IOS
125
+ ccResolutionType resolutionType_;
126
+ #endif
127
+
128
+ // needed for drawAtRect, drawInPoint
129
+ CCGLProgram *shaderProgram_;
130
+
131
+ }
132
+ /** Intializes with a texture2d with data */
133
+ - (id) initWithData:(const void*)data pixelFormat:(CCTexture2DPixelFormat)pixelFormat pixelsWide:(NSUInteger)width pixelsHigh:(NSUInteger)height contentSize:(CGSize)size;
134
+
135
+ /** These functions are needed to create mutable textures */
136
+ - (void) releaseData:(void*)data;
137
+ - (void*) keepData:(void*)data length:(NSUInteger)length;
138
+
139
+ /** pixel format of the texture */
140
+ @property(nonatomic,readonly) CCTexture2DPixelFormat pixelFormat;
141
+ /** width in pixels */
142
+ @property(nonatomic,readonly) NSUInteger pixelsWide;
143
+ /** hight in pixels */
144
+ @property(nonatomic,readonly) NSUInteger pixelsHigh;
145
+
146
+ /** texture name */
147
+ @property(nonatomic,readonly) GLuint name;
148
+
149
+ /** returns content size of the texture in pixels */
150
+ @property(nonatomic,readonly, nonatomic) CGSize contentSizeInPixels;
151
+
152
+ /** texture max S */
153
+ @property(nonatomic,readwrite) GLfloat maxS;
154
+ /** texture max T */
155
+ @property(nonatomic,readwrite) GLfloat maxT;
156
+ /** whether or not the texture has their Alpha premultiplied */
157
+ @property(nonatomic,readonly) BOOL hasPremultipliedAlpha;
158
+
159
+ /** shader program used by drawAtPoint and drawInRect */
160
+ @property(nonatomic,readwrite,retain) CCGLProgram *shaderProgram;
161
+
162
+ #ifdef __CC_PLATFORM_IOS
163
+ /** Returns the resolution type of the texture.
164
+ Is it a RetinaDisplay texture, an iPad texture or an standard texture ?
165
+ Only valid on iOS. Not valid on OS X.
166
+
167
+ Should be a readonly property. It is readwrite as a hack.
168
+
169
+ @since v1.1
170
+ */
171
+ @property (nonatomic, readwrite) ccResolutionType resolutionType;
172
+ #endif
173
+
174
+ /** returns the content size of the texture in points */
175
+ -(CGSize) contentSize;
176
+
177
+
178
+ @end
179
+
180
+ /**
181
+ Drawing extensions to make it easy to draw basic quads using a CCTexture2D object.
182
+ These functions require GL_TEXTURE_2D and both GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY client states to be enabled.
183
+ */
184
+ @interface CCTexture2D (Drawing)
185
+ /** draws a texture at a given point */
186
+ - (void) drawAtPoint:(CGPoint)point;
187
+ /** draws a texture inside a rect */
188
+ - (void) drawInRect:(CGRect)rect;
189
+ @end
190
+
191
+ /**
192
+ Extensions to make it easy to create a CCTexture2D object from an image file.
193
+ Note that RGBA type textures will have their alpha premultiplied - use the blending mode (GL_ONE, GL_ONE_MINUS_SRC_ALPHA).
194
+ */
195
+ @interface CCTexture2D (Image)
196
+ /** Initializes a texture from a CGImage object */
197
+ #ifdef __CC_PLATFORM_IOS
198
+ - (id) initWithCGImage:(CGImageRef)cgImage resolutionType:(ccResolutionType)resolution;
199
+ #elif defined(__CC_PLATFORM_MAC)
200
+ - (id) initWithCGImage:(CGImageRef)cgImage;
201
+ #endif
202
+ @end
203
+
204
+ /**
205
+ Extensions to make it easy to create a CCTexture2D object from a string of text.
206
+ Note that the generated textures are of type A8 - use the blending mode (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).
207
+ */
208
+ @interface CCTexture2D (Text)
209
+ /** Initializes a texture from a string with dimensions, alignment, line break mode, font name and font size
210
+ Supported lineBreakModes:
211
+ - iOS: all UILineBreakMode supported modes
212
+ - Mac: Only NSLineBreakByWordWrapping is supported.
213
+ @since v1.0
214
+ */
215
+ - (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment lineBreakMode:(CCLineBreakMode)lineBreakMode fontName:(NSString*)name fontSize:(CGFloat)size;
216
+ /** Initializes a texture from a string with dimensions, alignment, font name and font size */
217
+ - (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions hAlignment:(CCTextAlignment)alignment vAlignment:(CCVerticalTextAlignment) vertAlignment fontName:(NSString*)name fontSize:(CGFloat)size;
218
+ /** Initializes a texture from a string with font name and font size */
219
+ - (id) initWithString:(NSString*)string fontName:(NSString*)name fontSize:(CGFloat)size;
220
+ @end
221
+
222
+
223
+ /**
224
+ Extensions to make it easy to create a CCTexture2D object from a PVRTC file
225
+ Note that the generated textures don't have their alpha premultiplied - use the blending mode (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).
226
+ */
227
+ @interface CCTexture2D (PVRSupport)
228
+ /** Initializes a texture from a PVR file.
229
+
230
+ Supported PVR formats:
231
+ - BGRA 8888
232
+ - RGBA 8888
233
+ - RGBA 4444
234
+ - RGBA 5551
235
+ - RBG 565
236
+ - A 8
237
+ - I 8
238
+ - AI 8
239
+ - PVRTC 2BPP
240
+ - PVRTC 4BPP
241
+
242
+ By default PVR images are treated as if they alpha channel is NOT premultiplied. You can override this behavior with this class method:
243
+ - PVRImagesHavePremultipliedAlpha:(BOOL)haveAlphaPremultiplied;
244
+
245
+ IMPORTANT: This method is only defined on iOS. It is not supported on the Mac version.
246
+
247
+ */
248
+ -(id) initWithPVRFile: (NSString*) file;
249
+
250
+ /** treats (or not) PVR files as if they have alpha premultiplied.
251
+ Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is
252
+ possible load them as if they have (or not) the alpha channel premultiplied.
253
+
254
+ By default it is disabled.
255
+
256
+ @since v0.99.5
257
+ */
258
+ +(void) PVRImagesHavePremultipliedAlpha:(BOOL)haveAlphaPremultiplied;
259
+ @end
260
+
261
+ /**
262
+ Extension to set the Min / Mag filter
263
+ */
264
+ typedef struct _ccTexParams {
265
+ GLuint minFilter;
266
+ GLuint magFilter;
267
+ GLuint wrapS;
268
+ GLuint wrapT;
269
+ } ccTexParams;
270
+
271
+ @interface CCTexture2D (GLFilter)
272
+ /** sets the min filter, mag filter, wrap s and wrap t texture parameters.
273
+ If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}.
274
+
275
+ @warning Calling this method could allocate additional texture memory.
276
+
277
+ @since v0.8
278
+ */
279
+ -(void) setTexParameters: (ccTexParams*) texParams;
280
+
281
+ /** sets antialias texture parameters:
282
+ - GL_TEXTURE_MIN_FILTER = GL_LINEAR
283
+ - GL_TEXTURE_MAG_FILTER = GL_LINEAR
284
+
285
+ @warning Calling this method could allocate additional texture memory.
286
+
287
+ @since v0.8
288
+ */
289
+ - (void) setAntiAliasTexParameters;
290
+
291
+ /** sets alias texture parameters:
292
+ - GL_TEXTURE_MIN_FILTER = GL_NEAREST
293
+ - GL_TEXTURE_MAG_FILTER = GL_NEAREST
294
+
295
+ @warning Calling this method could allocate additional texture memory.
296
+
297
+ @since v0.8
298
+ */
299
+ - (void) setAliasTexParameters;
300
+
301
+
302
+ /** Generates mipmap images for the texture.
303
+ It only works if the texture size is POT (power of 2).
304
+ @since v0.99.0
305
+ */
306
+ -(void) generateMipmap;
307
+
308
+
309
+ @end
310
+
311
+ @interface CCTexture2D (PixelFormat)
312
+ /** sets the default pixel format for CGImages that contains alpha channel.
313
+ If the CGImage contains alpha channel, then the options are:
314
+ - generate 32-bit textures: kCCTexture2DPixelFormat_RGBA8888 (default one)
315
+ - generate 16-bit textures: kCCTexture2DPixelFormat_RGBA4444
316
+ - generate 16-bit textures: kCCTexture2DPixelFormat_RGB5A1
317
+ - generate 24-bit textures: kCCTexture2DPixelFormat_RGB888 (no alpha)
318
+ - generate 16-bit textures: kCCTexture2DPixelFormat_RGB565 (no alpha)
319
+ - generate 8-bit textures: kCCTexture2DPixelFormat_A8 (only use it if you use just 1 color)
320
+
321
+ How does it work ?
322
+ - If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture)
323
+ - If the image is an RGB (without Alpha) then: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used.
324
+
325
+ This parameter is not valid for PVR / PVR.CCZ images.
326
+
327
+ @since v0.8
328
+ */
329
+ +(void) setDefaultAlphaPixelFormat:(CCTexture2DPixelFormat)format;
330
+
331
+ /** returns the alpha pixel format
332
+ @since v0.8
333
+ */
334
+ +(CCTexture2DPixelFormat) defaultAlphaPixelFormat;
335
+
336
+ /** returns the bits-per-pixel of the in-memory OpenGL texture
337
+ @since v1.0
338
+ */
339
+ -(NSUInteger) bitsPerPixelForFormat;
340
+
341
+ /** returns the pixel format in a NSString.
342
+ @since v2.0
343
+ */
344
+ -(NSString*) stringForFormat;
345
+
346
+
347
+ /** Helper functions that returns bits per pixels for a given format.
348
+ @since v2.0
349
+ */
350
+ +(NSUInteger) bitsPerPixelForFormat:(CCTexture2DPixelFormat)format;
351
+
352
+ @end
353
+
354
+
355
+
356
+
357
+