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,54 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 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
+ // Common layer for NS (Next-Step) stuff
28
+ //
29
+
30
+ #import "../ccMacros.h"
31
+
32
+ #import <Foundation/Foundation.h> // for NSObject
33
+
34
+ #ifdef __CC_PLATFORM_IOS
35
+
36
+ #define CCRectFromString(__r__) CGRectFromString(__r__)
37
+ #define CCPointFromString(__p__) CGPointFromString(__p__)
38
+ #define CCSizeFromString(__s__) CGSizeFromString(__s__)
39
+ #define CCNSSizeToCGSize
40
+ #define CCNSRectToCGRect
41
+ #define CCNSPointToCGPoint
42
+
43
+
44
+ #elif defined(__CC_PLATFORM_MAC)
45
+
46
+ #define CCRectFromString(__r__) NSRectToCGRect( NSRectFromString(__r__) )
47
+ #define CCPointFromString(__p__) NSPointToCGPoint( NSPointFromString(__p__) )
48
+ #define CCSizeFromString(__s__) NSSizeToCGSize( NSSizeFromString(__s__) )
49
+ #define CCNSSizeToCGSize NSSizeToCGSize
50
+ #define CCNSRectToCGRect NSRectToCGRect
51
+ #define CCNSPointToCGPoint NSPointToCGPoint
52
+ #endif
53
+
54
+
@@ -0,0 +1,39 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2012 Zynga Inc.
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
+ #import "CCNode.h"
26
+
27
+ #ifdef DEBUG
28
+
29
+ /** Debugging extensions of CCNode.
30
+ They are available when the DEBUG macro is defined at compile time
31
+ */
32
+ @interface CCNode (Debug)
33
+
34
+ /** prints on the debug console the scene graph */
35
+ -(void) walkSceneGraph:(NSUInteger)level;
36
+
37
+ @end
38
+
39
+ #endif // DEBUG
@@ -0,0 +1,569 @@
1
+ /*
2
+ * cocos2d for iPhone: http://www.cocos2d-iphone.org
3
+ *
4
+ * Copyright (c) 2009 Valentin Milea
5
+ *
6
+ * Copyright (c) 2008-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
+ #import "Platforms/CCGL.h"
29
+ #import "ccTypes.h"
30
+ #import "CCProtocols.h"
31
+ #import "ccConfig.h"
32
+ #import "ccGLStateCache.h"
33
+ #import "Support/CCArray.h"
34
+ #import "kazmath/kazmath.h"
35
+
36
+ enum {
37
+ kCCNodeTagInvalid = -1,
38
+ };
39
+
40
+ @class CCCamera;
41
+ @class CCGridBase;
42
+ @class CCGLProgram;
43
+ @class CCScheduler;
44
+ @class CCActionManager;
45
+ @class CCAction;
46
+
47
+ /** CCNode is the main element. Anything thats gets drawn or contains things that get drawn is a CCNode.
48
+ The most popular CCNodes are: CCScene, CCLayer, CCSprite, CCMenu.
49
+
50
+ The main features of a CCNode are:
51
+ - They can contain other CCNode nodes (addChild, getChildByTag, removeChild, etc)
52
+ - They can schedule periodic callback (schedule, unschedule, etc)
53
+ - They can execute actions (runAction, stopAction, etc)
54
+
55
+ Some CCNode nodes provide extra functionality for them or their children.
56
+
57
+ Subclassing a CCNode usually means (one/all) of:
58
+ - overriding init to initialize resources and schedule callbacks
59
+ - create callbacks to handle the advancement of time
60
+ - overriding draw to render the node
61
+
62
+ Features of CCNode:
63
+ - position
64
+ - scale (x, y)
65
+ - rotation (in degrees, clockwise)
66
+ - CCCamera (an interface to gluLookAt )
67
+ - CCGridBase (to do mesh transformations)
68
+ - anchor point
69
+ - size
70
+ - visible
71
+ - z-order
72
+ - openGL z position
73
+
74
+ Default values:
75
+ - rotation: 0
76
+ - position: (x=0,y=0)
77
+ - scale: (x=1,y=1)
78
+ - contentSize: (x=0,y=0)
79
+ - anchorPoint: (x=0,y=0)
80
+
81
+ Limitations:
82
+ - A CCNode is a "void" object. It doesn't have a texture
83
+
84
+ Order in transformations with grid disabled
85
+ -# The node will be translated (position)
86
+ -# The node will be rotated (rotation)
87
+ -# The node will be skewed (skewX, skewY)
88
+ -# The node will be scaled (scale, scaleX, scaleY)
89
+ -# The node will be moved according to the camera values (camera)
90
+
91
+ Order in transformations with grid enabled
92
+ -# The node will be translated (position)
93
+ -# The node will be rotated (rotation)
94
+ -# The node will be skewed (skewX, skewY)
95
+ -# The node will be scaled (scale, scaleX, scaleY)
96
+ -# The grid will capture the screen
97
+ -# The node will be moved according to the camera values (camera)
98
+ -# The grid will render the captured screen
99
+
100
+ Camera:
101
+ - Each node has a camera. By default it points to the center of the CCNode.
102
+ */
103
+ @interface CCNode : NSObject
104
+ {
105
+ // rotation angle
106
+ float rotation_;
107
+
108
+ // scaling factors
109
+ float scaleX_, scaleY_;
110
+
111
+ // openGL real Z vertex
112
+ float vertexZ_;
113
+
114
+ // position of the node
115
+ CGPoint position_;
116
+
117
+ // skew angles
118
+ float skewX_, skewY_;
119
+
120
+ // anchor point in points
121
+ CGPoint anchorPointInPoints_;
122
+ // anchor point normalized (NOT in points)
123
+ CGPoint anchorPoint_;
124
+
125
+ // untransformed size of the node
126
+ CGSize contentSize_;
127
+
128
+ // transform
129
+ CGAffineTransform transform_, inverse_;
130
+
131
+ // a Camera
132
+ CCCamera *camera_;
133
+
134
+ // a Grid
135
+ CCGridBase *grid_;
136
+
137
+ // z-order value
138
+ NSInteger zOrder_;
139
+
140
+ // array of children
141
+ CCArray *children_;
142
+
143
+ // weakref to parent
144
+ CCNode *parent_;
145
+
146
+ // a tag. any number you want to assign to the node
147
+ NSInteger tag_;
148
+
149
+ // user data field
150
+ void *userData_;
151
+ id userObject_;
152
+
153
+ // Shader
154
+ CCGLProgram *shaderProgram_;
155
+
156
+ // Server side state
157
+ ccGLServerState glServerState_;
158
+
159
+ // used to preserve sequence while sorting children with the same zOrder
160
+ NSUInteger orderOfArrival_;
161
+
162
+ // scheduler used to schedule timers and updates
163
+ CCScheduler *scheduler_;
164
+
165
+ // ActionManager used to handle all the actions
166
+ CCActionManager *actionManager_;
167
+
168
+ // Is running
169
+ BOOL isRunning_;
170
+
171
+ BOOL isTransformDirty_;
172
+ BOOL isInverseDirty_;
173
+
174
+ // is visible
175
+ BOOL visible_;
176
+ // If YES, the Anchor Point will be (0,0) when you position the CCNode.
177
+ // Used by CCLayer and CCScene
178
+ BOOL ignoreAnchorPointForPosition_;
179
+
180
+ BOOL isReorderChildDirty_;
181
+ }
182
+
183
+ /** The z order of the node relative to its "siblings": children of the same parent */
184
+ @property(nonatomic,assign) NSInteger zOrder;
185
+ /** The real openGL Z vertex.
186
+ Differences between openGL Z vertex and cocos2d Z order:
187
+ - OpenGL Z modifies the Z vertex, and not the Z order in the relation between parent-children
188
+ - OpenGL Z might require to set 2D projection
189
+ - cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: vertexZ = 0
190
+ @warning: Use it at your own risk since it might break the cocos2d parent-children z order
191
+ @since v0.8
192
+ */
193
+ @property (nonatomic,readwrite) float vertexZ;
194
+
195
+ /** The X skew angle of the node in degrees.
196
+ This angle describes the shear distortion in the X direction.
197
+ Thus, it is the angle between the Y axis and the left edge of the shape
198
+ The default skewX angle is 0. Positive values distort the node in a CW direction.
199
+ */
200
+ @property(nonatomic,readwrite,assign) float skewX;
201
+
202
+ /** The Y skew angle of the node in degrees.
203
+ This angle describes the shear distortion in the Y direction.
204
+ Thus, it is the angle between the X axis and the bottom edge of the shape
205
+ The default skewY angle is 0. Positive values distort the node in a CCW direction.
206
+ */
207
+ @property(nonatomic,readwrite,assign) float skewY;
208
+ /** The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. */
209
+ @property(nonatomic,readwrite,assign) float rotation;
210
+ /** The scale factor of the node. 1.0 is the default scale factor. It modifies the X and Y scale at the same time. */
211
+ @property(nonatomic,readwrite,assign) float scale;
212
+ /** The scale factor of the node. 1.0 is the default scale factor. It only modifies the X scale factor. */
213
+ @property(nonatomic,readwrite,assign) float scaleX;
214
+ /** The scale factor of the node. 1.0 is the default scale factor. It only modifies the Y scale factor. */
215
+ @property(nonatomic,readwrite,assign) float scaleY;
216
+ /** Position (x,y) of the node in points. (0,0) is the left-bottom corner. */
217
+ @property(nonatomic,readwrite,assign) CGPoint position;
218
+ /** A CCCamera object that lets you move the node using a gluLookAt */
219
+ @property(nonatomic,readonly) CCCamera* camera;
220
+ /** Array of children */
221
+ @property(nonatomic,readonly) CCArray *children;
222
+ /** A CCGrid object that is used when applying effects */
223
+ @property(nonatomic,readwrite,retain) CCGridBase* grid;
224
+ /** Whether of not the node is visible. Default is YES */
225
+ @property(nonatomic,readwrite,assign) BOOL visible;
226
+ /** anchorPoint is the point around which all transformations and positioning manipulations take place.
227
+ It's like a pin in the node where it is "attached" to its parent.
228
+ The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
229
+ But you can use values higher than (1,1) and lower than (0,0) too.
230
+ The default anchorPoint is (0,0). It starts in the bottom-left corner. CCSprite and other subclasses have a different default anchorPoint.
231
+ @since v0.8
232
+ */
233
+ @property(nonatomic,readwrite) CGPoint anchorPoint;
234
+ /** The anchorPoint in absolute pixels.
235
+ Since v0.8 you can only read it. If you wish to modify it, use anchorPoint instead
236
+ */
237
+ @property(nonatomic,readonly) CGPoint anchorPointInPoints;
238
+
239
+ /** The untransformed size of the node in Points
240
+ The contentSize remains the same no matter the node is scaled or rotated.
241
+ All nodes has a size. Layer and Scene has the same size of the screen.
242
+ @since v0.8
243
+ */
244
+ @property (nonatomic,readwrite) CGSize contentSize;
245
+
246
+ /** whether or not the node is running */
247
+ @property(nonatomic,readonly) BOOL isRunning;
248
+ /** A weak reference to the parent */
249
+ @property(nonatomic,readwrite,assign) CCNode* parent;
250
+ /** If YES, the Anchor Point will be (0,0) when you position the CCNode.
251
+ Used by CCLayer and CCScene.
252
+ */
253
+ @property(nonatomic,readwrite,assign) BOOL ignoreAnchorPointForPosition;
254
+ /** A tag used to identify the node easily */
255
+ @property(nonatomic,readwrite,assign) NSInteger tag;
256
+ /** A custom user data pointer */
257
+ @property(nonatomic,readwrite,assign) void* userData;
258
+ /** Similar to userData, but instead of holding a void* it holds an id */
259
+ @property(nonatomic,readwrite,retain) id userObject;
260
+
261
+ /** Shader Program
262
+ @since v2.0
263
+ */
264
+ @property(nonatomic,readwrite,retain) CCGLProgram *shaderProgram;
265
+
266
+ /** used internally for zOrder sorting, don't change this manually */
267
+ @property(nonatomic,readwrite) NSUInteger orderOfArrival;
268
+
269
+ /** GL server side state
270
+ @since v2.0
271
+ */
272
+ @property (nonatomic, readwrite) ccGLServerState glServerState;
273
+
274
+ /** CCActionManager used by all the actions.
275
+ IMPORTANT: If you set a new CCActionManager, then previously created actions are going to be removed.
276
+ @since v2.0
277
+ */
278
+ @property (nonatomic, readwrite, retain) CCActionManager *actionManager;
279
+
280
+ /** CCScheduler used to schedule all "updates" and timers.
281
+ IMPORTANT: If you set a new CCScheduler, then previously created timers/update are going to be removed.
282
+ @since v2.0
283
+ */
284
+ @property (nonatomic, readwrite, retain) CCScheduler *scheduler;
285
+
286
+ // initializators
287
+ /** allocates and initializes a node.
288
+ The node will be created as "autorelease".
289
+ */
290
+ +(id) node;
291
+ /** initializes the node */
292
+ -(id) init;
293
+
294
+
295
+ // scene managment
296
+
297
+ /** Event that is called every time the CCNode enters the 'stage'.
298
+ If the CCNode enters the 'stage' with a transition, this event is called when the transition starts.
299
+ During onEnter you can't access a sibling node.
300
+ If you override onEnter, you shall call [super onEnter].
301
+ */
302
+ -(void) onEnter;
303
+
304
+ /** Event that is called when the CCNode enters in the 'stage'.
305
+ If the CCNode enters the 'stage' with a transition, this event is called when the transition finishes.
306
+ If you override onEnterTransitionDidFinish, you shall call [super onEnterTransitionDidFinish].
307
+ @since v0.8
308
+ */
309
+ -(void) onEnterTransitionDidFinish;
310
+
311
+ /** Event that is called every time the CCNode leaves the 'stage'.
312
+ If the CCNode leaves the 'stage' with a transition, this event is called when the transition finishes.
313
+ During onExit you can't access a sibling node.
314
+ If you override onExit, you shall call [super onExit].
315
+ */
316
+ -(void) onExit;
317
+
318
+ /** callback that is called every time the CCNode leaves the 'stage'.
319
+ If the CCNode leaves the 'stage' with a transition, this callback is called when the transition starts.
320
+ */
321
+ -(void) onExitTransitionDidStart;
322
+
323
+ // composition: ADD
324
+
325
+ /** Adds a child to the container with z-order as 0.
326
+ If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
327
+ @since v0.7.1
328
+ */
329
+ -(void) addChild: (CCNode*)node;
330
+
331
+ /** Adds a child to the container with a z-order.
332
+ If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
333
+ @since v0.7.1
334
+ */
335
+ -(void) addChild: (CCNode*)node z:(NSInteger)z;
336
+
337
+ /** Adds a child to the container with z order and tag.
338
+ If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
339
+ @since v0.7.1
340
+ */
341
+ -(void) addChild: (CCNode*)node z:(NSInteger)z tag:(NSInteger)tag;
342
+
343
+ // composition: REMOVE
344
+
345
+ /** Remove itself from its parent node. If cleanup is YES, then also remove all actions and callbacks.
346
+ If the node orphan, then nothing happens.
347
+ @since v0.99.3
348
+ */
349
+ -(void) removeFromParentAndCleanup:(BOOL)cleanup;
350
+
351
+ /** Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.
352
+ @since v0.7.1
353
+ */
354
+ -(void) removeChild: (CCNode*)node cleanup:(BOOL)cleanup;
355
+
356
+ /** Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter
357
+ @since v0.7.1
358
+ */
359
+ -(void) removeChildByTag:(NSInteger) tag cleanup:(BOOL)cleanup;
360
+
361
+ /** Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
362
+ @since v0.7.1
363
+ */
364
+ -(void) removeAllChildrenWithCleanup:(BOOL)cleanup;
365
+
366
+ // composition: GET
367
+ /** Gets a child from the container given its tag
368
+ @return returns a CCNode object
369
+ @since v0.7.1
370
+ */
371
+ -(CCNode*) getChildByTag:(NSInteger) tag;
372
+
373
+ /** Reorders a child according to a new z value.
374
+ * The child MUST be already added.
375
+ */
376
+ -(void) reorderChild:(CCNode*)child z:(NSInteger)zOrder;
377
+
378
+ /** performance improvement, Sort the children array once before drawing, instead of every time when a child is added or reordered
379
+ don't call this manually unless a child added needs to be removed in the same frame */
380
+ - (void) sortAllChildren;
381
+
382
+ /** Event that is called when the running node is no longer running (eg: its CCScene is being removed from the "stage" ).
383
+ On cleanup you should break any possible circular references.
384
+ CCNode's cleanup removes any possible scheduled timer and/or any possible action.
385
+ If you override cleanup, you shall call [super cleanup]
386
+ @since v0.8
387
+ */
388
+ -(void) cleanup;
389
+
390
+ // draw
391
+
392
+ /** Override this method to draw your own node.
393
+ You should use cocos2d's GL API to enable/disable the GL state / shaders.
394
+ For further info, please see ccGLstate.h.
395
+ You shall NOT call [super draw];
396
+ */
397
+ -(void) draw;
398
+
399
+ /** recursive method that visit its children and draw them */
400
+ -(void) visit;
401
+
402
+ // transformations
403
+
404
+ /** performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes. */
405
+ -(void) transform;
406
+
407
+ /** performs OpenGL view-matrix transformation of its ancestors.
408
+ Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO) it is necessary to transform the ancestors again.
409
+ @since v0.7.2
410
+ */
411
+ -(void) transformAncestors;
412
+
413
+ /** returns a "local" axis aligned bounding box of the node in points.
414
+ The returned box is relative only to its parent.
415
+ The returned box is in Points.
416
+
417
+ @since v0.8.2
418
+ */
419
+ - (CGRect) boundingBox;
420
+
421
+ // actions
422
+
423
+ /** Executes an action, and returns the action that is executed.
424
+ The node becomes the action's target.
425
+ @warning Starting from v0.8 actions don't retain their target anymore.
426
+ @since v0.7.1
427
+ @return An Action pointer
428
+ */
429
+ -(CCAction*) runAction: (CCAction*) action;
430
+ /** Removes all actions from the running action list */
431
+ -(void) stopAllActions;
432
+ /** Removes an action from the running action list */
433
+ -(void) stopAction: (CCAction*) action;
434
+ /** Removes an action from the running action list given its tag
435
+ @since v0.7.1
436
+ */
437
+ -(void) stopActionByTag:(NSInteger) tag;
438
+ /** Gets an action from the running action list given its tag
439
+ @since v0.7.1
440
+ @return the Action the with the given tag
441
+ */
442
+ -(CCAction*) getActionByTag:(NSInteger) tag;
443
+ /** Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays).
444
+ * Composable actions are counted as 1 action. Example:
445
+ * If you are running 1 Sequence of 7 actions, it will return 1.
446
+ * If you are running 7 Sequences of 2 actions, it will return 7.
447
+ */
448
+ -(NSUInteger) numberOfRunningActions;
449
+
450
+ // timers
451
+
452
+ /** check whether a selector is scheduled. */
453
+ //-(BOOL) isScheduled: (SEL) selector;
454
+
455
+ /** schedules the "update" method. It will use the order number 0. This method will be called every frame.
456
+ Scheduled methods with a lower order value will be called before the ones that have a higher order value.
457
+ Only one "udpate" method could be scheduled per node.
458
+
459
+ @since v0.99.3
460
+ */
461
+ -(void) scheduleUpdate;
462
+
463
+ /** schedules the "update" selector with a custom priority. This selector will be called every frame.
464
+ Scheduled selectors with a lower priority will be called before the ones that have a higher value.
465
+ Only one "udpate" selector could be scheduled per node (You can't have 2 'update' selectors).
466
+
467
+ @since v0.99.3
468
+ */
469
+ -(void) scheduleUpdateWithPriority:(NSInteger)priority;
470
+
471
+ /* unschedules the "update" method.
472
+
473
+ @since v0.99.3
474
+ */
475
+ -(void) unscheduleUpdate;
476
+
477
+
478
+ /** schedules a selector.
479
+ The scheduled selector will be ticked every frame
480
+ */
481
+ -(void) schedule: (SEL) s;
482
+ /** schedules a custom selector with an interval time in seconds.
483
+ If time is 0 it will be ticked every frame.
484
+ If time is 0, it is recommended to use 'scheduleUpdate' instead.
485
+
486
+ If the selector is already scheduled, then the interval parameter will be updated without scheduling it again.
487
+ */
488
+ -(void) schedule: (SEL) s interval:(ccTime)seconds;
489
+ /**
490
+ repeat will execute the action repeat + 1 times, for a continues action use kCCRepeatForever
491
+ delay is the amount of time the action will wait before execution
492
+ */
493
+ -(void) schedule:(SEL)selector interval:(ccTime)interval repeat: (uint) repeat delay:(ccTime) delay;
494
+
495
+ /**
496
+ Schedules a selector that runs only once, with a delay of 0 or larger
497
+ */
498
+ - (void) scheduleOnce:(SEL) selector delay:(ccTime) delay;
499
+
500
+ /** unschedules a custom selector.*/
501
+ -(void) unschedule: (SEL) s;
502
+
503
+ /** unschedule all scheduled selectors: custom selectors, and the 'update' selector.
504
+ Actions are not affected by this method.
505
+ @since v0.99.3
506
+ */
507
+ -(void) unscheduleAllSelectors;
508
+
509
+ /** resumes all scheduled selectors and actions.
510
+ Called internally by onEnter
511
+ */
512
+ -(void) resumeSchedulerAndActions;
513
+ /** pauses all scheduled selectors and actions.
514
+ Called internally by onExit
515
+ */
516
+ -(void) pauseSchedulerAndActions;
517
+
518
+
519
+ // transformation methods
520
+
521
+ /** Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
522
+ The matrix is in Pixels.
523
+ @since v0.7.1
524
+ */
525
+ - (CGAffineTransform)nodeToParentTransform;
526
+ /** Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
527
+ The matrix is in Pixels.
528
+ @since v0.7.1
529
+ */
530
+ - (CGAffineTransform)parentToNodeTransform;
531
+ /** Retrusn the world affine transform matrix. The matrix is in Pixels.
532
+ @since v0.7.1
533
+ */
534
+ - (CGAffineTransform)nodeToWorldTransform;
535
+ /** Returns the inverse world affine transform matrix. The matrix is in Pixels.
536
+ @since v0.7.1
537
+ */
538
+ - (CGAffineTransform)worldToNodeTransform;
539
+ /** Converts a Point to node (local) space coordinates. The result is in Points.
540
+ @since v0.7.1
541
+ */
542
+ - (CGPoint)convertToNodeSpace:(CGPoint)worldPoint;
543
+ /** Converts a Point to world space coordinates. The result is in Points.
544
+ @since v0.7.1
545
+ */
546
+ - (CGPoint)convertToWorldSpace:(CGPoint)nodePoint;
547
+ /** Converts a Point to node (local) space coordinates. The result is in Points.
548
+ treating the returned/received node point as anchor relative.
549
+ @since v0.7.1
550
+ */
551
+ - (CGPoint)convertToNodeSpaceAR:(CGPoint)worldPoint;
552
+ /** Converts a local Point to world space coordinates.The result is in Points.
553
+ treating the returned/received node point as anchor relative.
554
+ @since v0.7.1
555
+ */
556
+ - (CGPoint)convertToWorldSpaceAR:(CGPoint)nodePoint;
557
+
558
+ #ifdef __CC_PLATFORM_IOS
559
+ /** Converts a UITouch to node (local) space coordinates. The result is in Points.
560
+ @since v0.7.1
561
+ */
562
+ - (CGPoint)convertTouchToNodeSpace:(UITouch *)touch;
563
+ /** Converts a UITouch to node (local) space coordinates. The result is in Points.
564
+ This method is AR (Anchor Relative)..
565
+ @since v0.7.1
566
+ */
567
+ - (CGPoint)convertTouchToNodeSpaceAR:(UITouch *)touch;
568
+ #endif // __CC_PLATFORM_IOS
569
+ @end