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,160 @@
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: CCGLView.h
19
+ Abstract: Convenience class that wraps the CAEAGLLayer from CoreAnimation into a
20
+ UIView subclass.
21
+
22
+ Version: 1.3
23
+
24
+ Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
25
+ ("Apple") in consideration of your agreement to the following terms, and your
26
+ use, installation, modification or redistribution of this Apple software
27
+ constitutes acceptance of these terms. If you do not agree with these terms,
28
+ please do not use, install, modify or redistribute this Apple software.
29
+
30
+ In consideration of your agreement to abide by the following terms, and subject
31
+ to these terms, Apple grants you a personal, non-exclusive license, under
32
+ Apple's copyrights in this original Apple software (the "Apple Software"), to
33
+ use, reproduce, modify and redistribute the Apple Software, with or without
34
+ modifications, in source and/or binary forms; provided that if you redistribute
35
+ the Apple Software in its entirety and without modifications, you must retain
36
+ this notice and the following text and disclaimers in all such redistributions
37
+ of the Apple Software.
38
+ Neither the name, trademarks, service marks or logos of Apple Inc. may be used
39
+ to endorse or promote products derived from the Apple Software without specific
40
+ prior written permission from Apple. Except as expressly stated in this notice,
41
+ no other rights or licenses, express or implied, are granted by Apple herein,
42
+ including but not limited to any patent rights that may be infringed by your
43
+ derivative works or by other works in which the Apple Software may be
44
+ incorporated.
45
+
46
+ The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
47
+ WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
48
+ WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49
+ PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
50
+ COMBINATION WITH YOUR PRODUCTS.
51
+
52
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
53
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
54
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55
+ ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
56
+ DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
57
+ CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
58
+ APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59
+
60
+ Copyright (C) 2008 Apple Inc. All Rights Reserved.
61
+
62
+ */
63
+
64
+ // Only compile this code on iOS. These files should NOT be included on your Mac project.
65
+ // But in case they are included, it won't be compiled.
66
+ #import "../../ccMacros.h"
67
+ #ifdef __CC_PLATFORM_IOS
68
+
69
+ #import <UIKit/UIKit.h>
70
+ #import <OpenGLES/EAGL.h>
71
+ #import <OpenGLES/EAGLDrawable.h>
72
+ #import <OpenGLES/ES2/gl.h>
73
+ #import <OpenGLES/ES2/glext.h>
74
+
75
+ #import "CCESRenderer.h"
76
+
77
+ //CLASSES:
78
+
79
+ @class CCGLView;
80
+
81
+ //PROTOCOLS:
82
+
83
+ @protocol CCTouchDelegate <NSObject>
84
+ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
85
+ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
86
+ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
87
+ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
88
+ @end
89
+
90
+ //CLASS INTERFACE:
91
+
92
+ /** CCGLView Class.
93
+ * This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
94
+ * The view content is basically an EAGL surface you render your OpenGL scene into.
95
+ * Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
96
+ */
97
+ @interface CCGLView : UIView
98
+ {
99
+ id<CCESRenderer> renderer_;
100
+ EAGLContext *context_; // weak ref
101
+
102
+ NSString *pixelformat_;
103
+ GLuint depthFormat_;
104
+ BOOL preserveBackbuffer_;
105
+
106
+ CGSize size_;
107
+ BOOL discardFramebufferSupported_;
108
+ id<CCTouchDelegate> touchDelegate_;
109
+
110
+ //fsaa addition
111
+ BOOL multisampling_;
112
+ unsigned int requestedSamples_;
113
+ }
114
+
115
+ /** creates an initializes an CCGLView with a frame and 0-bit depth buffer, and a RGB565 color buffer. */
116
+ + (id) viewWithFrame:(CGRect)frame;
117
+ /** creates an initializes an CCGLView with a frame, a color buffer format, and 0-bit depth buffer. */
118
+ + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format;
119
+ /** creates an initializes an CCGLView with a frame, a color buffer format, and a depth buffer. */
120
+ + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth;
121
+ /** creates an initializes an CCGLView with a frame, a color buffer format, a depth buffer format, a sharegroup, and multisamping */
122
+ + (id) viewWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)multisampling numberOfSamples:(unsigned int)samples;
123
+
124
+ /** Initializes an CCGLView with a frame and 0-bit depth buffer, and a RGB565 color buffer */
125
+ - (id) initWithFrame:(CGRect)frame; //These also set the current context
126
+ /** Initializes an CCGLView with a frame, a color buffer format, and 0-bit depth buffer */
127
+ - (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format;
128
+ /** Initializes an CCGLView with a frame, a color buffer format, a depth buffer format, a sharegroup and multisampling support */
129
+ - (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GLuint)depth preserveBackbuffer:(BOOL)retained sharegroup:(EAGLSharegroup*)sharegroup multiSampling:(BOOL)sampling numberOfSamples:(unsigned int)nSamples;
130
+
131
+ /** pixel format: it could be RGBA8 (32-bit) or RGB565 (16-bit) */
132
+ @property(nonatomic,readonly) NSString* pixelFormat;
133
+ /** depth format of the render buffer: 0, 16 or 24 bits*/
134
+ @property(nonatomic,readonly) GLuint depthFormat;
135
+
136
+ /** returns surface size in pixels */
137
+ @property(nonatomic,readonly) CGSize surfaceSize;
138
+
139
+ /** OpenGL context */
140
+ @property(nonatomic,readonly) EAGLContext *context;
141
+
142
+ @property(nonatomic,readwrite) BOOL multiSampling;
143
+
144
+ /** touch delegate */
145
+ @property(nonatomic,readwrite,assign) id<CCTouchDelegate> touchDelegate;
146
+
147
+ /** CCGLView uses double-buffer. This method swaps the buffers */
148
+ -(void) swapBuffers;
149
+
150
+ /** uses and locks the OpenGL context */
151
+ -(void) lockOpenGLContext;
152
+
153
+ /** unlocks the openGL context */
154
+ -(void) unlockOpenGLContext;
155
+
156
+ - (CGPoint) convertPointFromViewToSurface:(CGPoint)point;
157
+ - (CGRect) convertRectFromViewToSurface:(CGRect)rect;
158
+ @end
159
+
160
+ #endif // __CC_PLATFORM_IOS
@@ -0,0 +1,44 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2009 On-Core
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ */
25
+
26
+
27
+ #import "Platforms/CCGL.h"
28
+ #import <Foundation/Foundation.h>
29
+
30
+ @class CCTexture2D;
31
+
32
+ /** FBO class that grabs the the contents of the screen */
33
+ @interface CCGrabber : NSObject
34
+ {
35
+ GLuint fbo_;
36
+ GLint oldFBO_;
37
+ GLfloat oldClearColor_[4];
38
+ }
39
+
40
+ -(void)grab:(CCTexture2D*)texture;
41
+ -(void)beforeRender:(CCTexture2D*)texture;
42
+ -(void)afterRender:(CCTexture2D*)texture;
43
+
44
+ @end
@@ -0,0 +1,130 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2009 On-Core
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ */
25
+
26
+
27
+ #import <Foundation/Foundation.h>
28
+
29
+ #import "CCNode.h"
30
+ #import "CCCamera.h"
31
+ #import "ccTypes.h"
32
+ #import "CCDirector.h"
33
+ #import "kazmath/mat4.h"
34
+
35
+ @class CCTexture2D;
36
+ @class CCGrabber;
37
+ @class CCGLProgram;
38
+
39
+ /** Base class for other
40
+ */
41
+ @interface CCGridBase : NSObject
42
+ {
43
+ BOOL active_;
44
+ int reuseGrid_;
45
+ ccGridSize gridSize_;
46
+ CCTexture2D *texture_;
47
+ CGPoint step_;
48
+ CCGrabber *grabber_;
49
+ BOOL isTextureFlipped_;
50
+
51
+ CCGLProgram *shaderProgram_;
52
+
53
+ ccDirectorProjection directorProjection_;
54
+ }
55
+
56
+ /** wheter or not the grid is active */
57
+ @property (nonatomic,readwrite) BOOL active;
58
+ /** number of times that the grid will be reused */
59
+ @property (nonatomic,readwrite) int reuseGrid;
60
+ /** size of the grid */
61
+ @property (nonatomic,readonly) ccGridSize gridSize;
62
+ /** pixels between the grids */
63
+ @property (nonatomic,readwrite) CGPoint step;
64
+ /** texture used */
65
+ @property (nonatomic, retain) CCTexture2D *texture;
66
+ /** grabber used */
67
+ @property (nonatomic, retain) CCGrabber *grabber;
68
+ /** is texture flipped */
69
+ @property (nonatomic, readwrite) BOOL isTextureFlipped;
70
+ /** shader program */
71
+ @property (nonatomic, readwrite, assign) CCGLProgram *shaderProgram;
72
+
73
+ +(id) gridWithSize:(ccGridSize)gridSize texture:(CCTexture2D*)texture flippedTexture:(BOOL)flipped;
74
+ +(id) gridWithSize:(ccGridSize)gridSize;
75
+
76
+ -(id) initWithSize:(ccGridSize)gridSize texture:(CCTexture2D*)texture flippedTexture:(BOOL)flipped;
77
+ -(id)initWithSize:(ccGridSize)gridSize;
78
+ -(void)beforeDraw;
79
+ -(void)afterDraw:(CCNode*)target;
80
+ -(void)blit;
81
+ -(void)reuse;
82
+
83
+ -(void)calculateVertexPoints;
84
+
85
+ @end
86
+
87
+ ////////////////////////////////////////////////////////////
88
+
89
+ /**
90
+ CCGrid3D is a 3D grid implementation. Each vertex has 3 dimensions: x,y,z
91
+ */
92
+ @interface CCGrid3D : CCGridBase
93
+ {
94
+ GLvoid *texCoordinates;
95
+ GLvoid *vertices;
96
+ GLvoid *originalVertices;
97
+ GLushort *indices;
98
+ }
99
+
100
+ /** returns the vertex at a given position */
101
+ -(ccVertex3F)vertex:(ccGridSize)pos;
102
+ /** returns the original (non-transformed) vertex at a given position */
103
+ -(ccVertex3F)originalVertex:(ccGridSize)pos;
104
+ /** sets a new vertex at a given position */
105
+ -(void)setVertex:(ccGridSize)pos vertex:(ccVertex3F)vertex;
106
+
107
+ @end
108
+
109
+ ////////////////////////////////////////////////////////////
110
+
111
+ /**
112
+ CCTiledGrid3D is a 3D grid implementation. It differs from Grid3D in that
113
+ the tiles can be separated from the grid.
114
+ */
115
+ @interface CCTiledGrid3D : CCGridBase
116
+ {
117
+ GLvoid *texCoordinates;
118
+ GLvoid *vertices;
119
+ GLvoid *originalVertices;
120
+ GLushort *indices;
121
+ }
122
+
123
+ /** returns the tile at the given position */
124
+ -(ccQuad3)tile:(ccGridSize)pos;
125
+ /** returns the original tile (untransformed) at the given position */
126
+ -(ccQuad3)originalTile:(ccGridSize)pos;
127
+ /** sets a new tile */
128
+ -(void)setTile:(ccGridSize)pos coords:(ccQuad3)coords;
129
+
130
+ @end
@@ -0,0 +1,68 @@
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
+
28
+ #import "CCAtlasNode.h"
29
+ #import "CCTextureAtlas.h"
30
+
31
+ /** CCLabelAtlas is a subclass of CCAtlasNode.
32
+
33
+ It can be as a replacement of CCLabel since it is MUCH faster.
34
+
35
+ CCLabelAtlas versus CCLabel:
36
+ - CCLabelAtlas is MUCH faster than CCLabel
37
+ - CCLabelAtlas "characters" have a fixed height and width
38
+ - CCLabelAtlas "characters" can be anything you want since they are taken from an image file
39
+
40
+ A more flexible class is CCLabelBMFont. It supports variable width characters and it also has a nice editor.
41
+ */
42
+ @interface CCLabelAtlas : CCAtlasNode <CCLabelProtocol>
43
+ {
44
+ // string to render
45
+ NSString *string_;
46
+
47
+ // the first char in the charmap
48
+ NSUInteger mapStartChar_;
49
+ }
50
+
51
+
52
+ /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element in points and the starting char of the atlas */
53
+ +(id) labelWithString:(NSString*) string charMapFile: (NSString*) charmapfile itemWidth:(NSUInteger)w itemHeight:(NSUInteger)h startCharMap:(NSUInteger)firstElement;
54
+
55
+ /** creates the CCLabelAtlas with a string and a configuration file
56
+ @since v2.0
57
+ */
58
+ +(id) labelWithString:(NSString*) string fntFile:(NSString*)fontFile;
59
+
60
+ /** initializes the CCLabelAtlas with a string, a char map file(the atlas), the width and height in points of each element and the starting char of the atlas */
61
+ -(id) initWithString:(NSString*) string charMapFile: (NSString*) charmapfile itemWidth:(NSUInteger)w itemHeight:(NSUInteger)h startCharMap:(NSUInteger)firstElement;
62
+
63
+ /** initializes the CCLabelAtlas with a string and a configuration file
64
+ @since v2.0
65
+ */
66
+ -(id) initWithString:(NSString*) string fntFile:(NSString*)fontFile;
67
+
68
+ @end
@@ -0,0 +1,216 @@
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
+ * Portions of this code are based and inspired on:
26
+ * http://www.71squared.co.uk/2009/04/iphone-game-programming-tutorial-4-bitmap-font-class
27
+ * by Michael Daley
28
+ *
29
+ * Use any of these editors to generate BMFonts:
30
+ * http://glyphdesigner.71squared.com/ (Commercial, Mac OS X)
31
+ * http://www.n4te.com/hiero/hiero.jnlp (Free, Java)
32
+ * http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java)
33
+ * http://www.angelcode.com/products/bmfont/ (Free, Windows only)
34
+ */
35
+
36
+ #import "CCSpriteBatchNode.h"
37
+ #import "Support/uthash.h"
38
+
39
+ enum {
40
+ kCCLabelAutomaticWidth = -1,
41
+ };
42
+
43
+ struct _KerningHashElement;
44
+
45
+ /** @struct ccBMFontDef
46
+ BMFont definition
47
+ */
48
+ typedef struct _BMFontDef {
49
+ //! ID of the character
50
+ unichar charID;
51
+ //! origin and size of the font
52
+ CGRect rect;
53
+ //! The X amount the image should be offset when drawing the image (in pixels)
54
+ short xOffset;
55
+ //! The Y amount the image should be offset when drawing the image (in pixels)
56
+ short yOffset;
57
+ //! The amount to move the current position after drawing the character (in pixels)
58
+ short xAdvance;
59
+ } ccBMFontDef;
60
+
61
+ /** @struct ccBMFontPadding
62
+ BMFont padding
63
+ @since v0.8.2
64
+ */
65
+ typedef struct _BMFontPadding {
66
+ /// padding left
67
+ int left;
68
+ /// padding top
69
+ int top;
70
+ /// padding right
71
+ int right;
72
+ /// padding bottom
73
+ int bottom;
74
+ } ccBMFontPadding;
75
+
76
+
77
+ /** CCBMFontConfiguration has parsed configuration of the the .fnt file
78
+ @since v0.8
79
+ */
80
+ @interface CCBMFontConfiguration : NSObject
81
+ {
82
+ // atlas name
83
+ NSString *atlasName_;
84
+
85
+ // XXX: Creating a public interface so that the bitmapFontArray[] is accesible
86
+ @public
87
+
88
+ // BMFont definitions
89
+ struct _FontDefHashElement *fontDefDictionary_;
90
+
91
+ // FNTConfig: Common Height. Should be signed (issue #1343)
92
+ NSInteger commonHeight_;
93
+
94
+ // Padding
95
+ ccBMFontPadding padding_;
96
+
97
+ // values for kerning
98
+ struct _KerningHashElement *kerningDictionary_;
99
+ }
100
+
101
+ // atlasName
102
+ @property (nonatomic, readwrite, retain) NSString *atlasName;
103
+
104
+ /** allocates a CCBMFontConfiguration with a FNT file */
105
+ +(id) configurationWithFNTFile:(NSString*)FNTfile;
106
+ /** initializes a CCBMFontConfiguration with a FNT file */
107
+ -(id) initWithFNTfile:(NSString*)FNTfile;
108
+ @end
109
+
110
+
111
+ /** CCLabelBMFont is a subclass of CCSpriteBatchNode
112
+
113
+ Features:
114
+ - Treats each character like a CCSprite. This means that each individual character can be:
115
+ - rotated
116
+ - scaled
117
+ - translated
118
+ - tinted
119
+ - chage the opacity
120
+ - It can be used as part of a menu item.
121
+ - anchorPoint can be used to align the "label"
122
+ - Supports AngelCode text format
123
+
124
+ Limitations:
125
+ - All inner characters are using an anchorPoint of (0.5f, 0.5f) and it is not recommend to change it
126
+ because it might affect the rendering
127
+
128
+ CCLabelBMFont implements the protocol CCLabelProtocol, like CCLabel and CCLabelAtlas.
129
+ CCLabelBMFont has the flexibility of CCLabel, the speed of CCLabelAtlas and all the features of CCSprite.
130
+ If in doubt, use CCLabelBMFont instead of CCLabelAtlas / CCLabel.
131
+
132
+ Supported editors:
133
+ - http://glyphdesigner.71squared.com/
134
+ - http://www.bmglyph.com/
135
+ - http://www.n4te.com/hiero/hiero.jnlp
136
+ - http://slick.cokeandcode.com/demos/hiero.jnlp
137
+ - http://www.angelcode.com/products/bmfont/
138
+
139
+ @since v0.8
140
+ */
141
+
142
+ @interface CCLabelBMFont : CCSpriteBatchNode <CCLabelProtocol, CCRGBAProtocol>
143
+ {
144
+ // string to render
145
+ NSString *string_;
146
+
147
+ // name of fntFile
148
+ NSString *fntFile_;
149
+
150
+ // initial string without line breaks
151
+ NSString *initialString_;
152
+ // max width until a line break is added
153
+ float width_;
154
+ // alignment of all lines
155
+ CCTextAlignment alignment_;
156
+
157
+ CCBMFontConfiguration *configuration_;
158
+
159
+ // texture RGBA
160
+ GLubyte opacity_;
161
+ ccColor3B color_;
162
+ BOOL opacityModifyRGB_;
163
+
164
+ // offset of the texture atlas
165
+ CGPoint imageOffset_;
166
+ }
167
+
168
+ /** Purges the cached data.
169
+ Removes from memory the cached configurations and the atlas name dictionary.
170
+ @since v0.99.3
171
+ */
172
+ +(void) purgeCachedData;
173
+
174
+ /** alignment used for the label */
175
+ @property (nonatomic,assign,readonly) CCTextAlignment alignment;
176
+ /** fntFile used for the font */
177
+ @property (nonatomic,retain) NSString* fntFile;
178
+ /** conforms to CCRGBAProtocol protocol */
179
+ @property (nonatomic,readwrite) GLubyte opacity;
180
+ /** conforms to CCRGBAProtocol protocol */
181
+ @property (nonatomic,readwrite) ccColor3B color;
182
+
183
+
184
+ /** creates a BMFont label with an initial string and the FNT file. */
185
+ +(id) labelWithString:(NSString*)string fntFile:(NSString*)fntFile;
186
+ /** creates a BMFont label with an initial string, the FNT file, width, and alignment option */
187
+ +(id) labelWithString:(NSString*)string fntFile:(NSString*)fntFile width:(float)width alignment:(CCTextAlignment)alignment;
188
+ /** creates a BMFont label with an initial string, the FNT file, width, alignment option and the offset of where the glpyhs start on the .PNG image */
189
+ +(id) labelWithString:(NSString*)string fntFile:(NSString*)fntFile width:(float)width alignment:(CCTextAlignment)alignment imageOffset:(CGPoint)offset;
190
+
191
+ /** init a BMFont label with an initial string and the FNT file */
192
+ -(id) initWithString:(NSString*)string fntFile:(NSString*)fntFile;
193
+ /** init a BMFont label with an initial string and the FNT file, width, and alignment option*/
194
+ -(id) initWithString:(NSString*)string fntFile:(NSString*)fntFile width:(float)width alignment:(CCTextAlignment)alignment;
195
+ /** init a BMFont label with an initial string and the FNT file, width, alignment option and the offset of where the glyphs start on the .PNG image */
196
+ -(id) initWithString:(NSString*)string fntFile:(NSString*)fntFile width:(float)width alignment:(CCTextAlignment)alignment imageOffset:(CGPoint)offset;
197
+
198
+ /** updates the font chars based on the string to render */
199
+ -(void) createFontChars;
200
+
201
+ /** set label width */
202
+ - (void)setWidth:(float)width;
203
+
204
+ /** set label alignment */
205
+ - (void)setAlignment:(CCTextAlignment)alignment;
206
+
207
+ @end
208
+
209
+ /** Free function that parses a FNT file a place it on the cache
210
+ */
211
+ CCBMFontConfiguration * FNTConfigLoadFile( NSString *file );
212
+ /** Purges the FNT config cache
213
+ */
214
+ void FNTConfigRemoveCache( void );
215
+
216
+