ccb 0.0.1

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 (335) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.md +31 -0
  4. data/bin/ccb +4 -0
  5. data/lib/ccb/builder/project_builder.rb +14 -0
  6. data/lib/ccb/builder/scene_builder.rb +9 -0
  7. data/lib/ccb/builder/templates/project/GameConfig.js.tt +21 -0
  8. data/lib/ccb/builder/templates/project/_cocos-project.json +4 -0
  9. data/lib/ccb/builder/templates/project/folder/CMakeLists.txt +295 -0
  10. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/Base64Images.js +32 -0
  11. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/CCBoot.js +2271 -0
  12. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/CCDebugger.js +336 -0
  13. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCAction.js +694 -0
  14. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionCamera.js +293 -0
  15. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionCatmullRom.js +605 -0
  16. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionEase.js +3681 -0
  17. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionInstant.js +757 -0
  18. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionInterval.js +3554 -0
  19. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionTween.js +166 -0
  20. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionGrid.js +372 -0
  21. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionGrid3D.js +1257 -0
  22. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionPageTurn3D.js +113 -0
  23. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionTiledGrid.js +1289 -0
  24. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/audio/CCAudio.js +1024 -0
  25. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/clipping-nodes/CCClippingNode.js +224 -0
  26. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js +227 -0
  27. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js +226 -0
  28. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/ZipUtils.js +82 -0
  29. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/base64.js +95 -0
  30. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/gzip.js +731 -0
  31. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/zlib.min.js +55 -0
  32. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCActionManager.js +378 -0
  33. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCCamera.js +290 -0
  34. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCConfiguration.js +294 -0
  35. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDirector.js +1019 -0
  36. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDirectorWebGL.js +329 -0
  37. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDrawingPrimitivesCanvas.js +438 -0
  38. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDrawingPrimitivesWebGL.js +464 -0
  39. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCScheduler.js +744 -0
  40. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js +127 -0
  41. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCAtlasNode.js +294 -0
  42. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js +138 -0
  43. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js +145 -0
  44. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCNode.js +2386 -0
  45. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +504 -0
  46. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +254 -0
  47. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/cocoa/CCAffineTransform.js +259 -0
  48. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/cocoa/CCGeometry.js +327 -0
  49. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEvent.js +449 -0
  50. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEventExtension.js +126 -0
  51. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEventListener.js +519 -0
  52. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEventManager.js +1025 -0
  53. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCTouch.js +175 -0
  54. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/CCLabelTTF.js +829 -0
  55. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +420 -0
  56. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js +101 -0
  57. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/LabelTTFPropertyDefine.js +88 -0
  58. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/layers/CCLayer.js +642 -0
  59. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +434 -0
  60. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/layers/CCLayerWebGLRenderCmd.js +248 -0
  61. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCClass.js +333 -0
  62. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCCommon.js +303 -0
  63. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCConfig.js +303 -0
  64. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCEGLView.js +1245 -0
  65. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCInputExtension.js +135 -0
  66. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCInputManager.js +616 -0
  67. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCLoaders.js +142 -0
  68. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCMacro.js +830 -0
  69. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCSAXParser.js +160 -0
  70. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCScreen.js +155 -0
  71. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCTypes.js +374 -0
  72. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCTypesPropertyDefine.js +165 -0
  73. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCTypesWebGL.js +689 -0
  74. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCVisibleRect.js +100 -0
  75. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/miniFramework.js +264 -0
  76. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/renderer/RendererCanvas.js +274 -0
  77. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/renderer/RendererWebGL.js +137 -0
  78. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/scenes/CCLoaderScene.js +149 -0
  79. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/scenes/CCScene.js +62 -0
  80. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCAnimation.js +477 -0
  81. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCAnimationCache.js +213 -0
  82. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCBakeSprite.js +71 -0
  83. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSprite.js +1014 -0
  84. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteBatchNode.js +676 -0
  85. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js +101 -0
  86. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +243 -0
  87. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +518 -0
  88. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteFrame.js +420 -0
  89. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteFrameCache.js +341 -0
  90. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +493 -0
  91. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/SpritesPropertyDefine.js +67 -0
  92. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/support/CCPointExtension.js +515 -0
  93. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/support/CCVertex.js +170 -0
  94. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/support/TransformUtils.js +62 -0
  95. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/CCTexture2D.js +455 -0
  96. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/CCTextureAtlas.js +653 -0
  97. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/CCTextureCache.js +371 -0
  98. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/TexturesPropertyDefine.js +221 -0
  99. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/TexturesWebGL.js +899 -0
  100. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/utils/BinaryLoader.js +151 -0
  101. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/effects/CCGrabber.js +110 -0
  102. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/effects/CCGrid.js +737 -0
  103. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/aabb.js +68 -0
  104. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/gl/mat4stack.js +59 -0
  105. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/gl/matrix.js +169 -0
  106. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/mat3.js +329 -0
  107. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/mat4.js +810 -0
  108. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/plane.js +184 -0
  109. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/quaternion.js +497 -0
  110. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/ray2.js +163 -0
  111. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/utility.js +76 -0
  112. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/vec2.js +107 -0
  113. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/vec3.js +205 -0
  114. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/vec4.js +158 -0
  115. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelAtlas.js +239 -0
  116. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js +95 -0
  117. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js +132 -0
  118. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelBMFont.js +958 -0
  119. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js +142 -0
  120. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js +87 -0
  121. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/menus/CCMenu.js +600 -0
  122. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/menus/CCMenuItem.js +1422 -0
  123. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/motion-streak/CCMotionStreak.js +517 -0
  124. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js +66 -0
  125. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/node-grid/CCNodeGrid.js +129 -0
  126. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/node-grid/CCNodeGridWebGLRenderCmd.js +98 -0
  127. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/parallax/CCParallaxNode.js +252 -0
  128. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/parallax/CCParallaxNodeRenderCmd.js +69 -0
  129. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCPNGReader.js +330 -0
  130. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleBatchNode.js +527 -0
  131. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleBatchNodeCanvasRenderCmd.js +38 -0
  132. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js +74 -0
  133. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleExamples.js +1006 -0
  134. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleSystem.js +2294 -0
  135. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js +217 -0
  136. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js +402 -0
  137. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCTIFFReader.js +692 -0
  138. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsDebugNode.js +212 -0
  139. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsDebugNodeCanvasRenderCmd.js +52 -0
  140. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js +53 -0
  141. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsSprite.js +447 -0
  142. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js +93 -0
  143. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js +87 -0
  144. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCActionProgressTimer.js +227 -0
  145. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCProgressTimer.js +345 -0
  146. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js +270 -0
  147. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js +486 -0
  148. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/render-texture/CCRenderTexture.js +395 -0
  149. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js +105 -0
  150. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +367 -0
  151. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCGLProgram.js +767 -0
  152. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCGLStateCache.js +340 -0
  153. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCShaderCache.js +301 -0
  154. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCShaders.js +280 -0
  155. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shape-nodes/CCDrawNode.js +940 -0
  156. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js +129 -0
  157. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shape-nodes/CCDrawNodeWebGLRenderCmd.js +41 -0
  158. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/text-input/CCIMEDispatcher.js +526 -0
  159. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/text-input/CCTextFieldTTF.js +472 -0
  160. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTGAlib.js +437 -0
  161. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXLayer.js +914 -0
  162. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +232 -0
  163. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js +67 -0
  164. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXObjectGroup.js +146 -0
  165. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXTiledMap.js +479 -0
  166. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXXMLParser.js +950 -0
  167. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/transitions/CCTransition.js +1971 -0
  168. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/transitions/CCTransitionPageTurn.js +152 -0
  169. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/transitions/CCTransitionProgress.js +458 -0
  170. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBAnimationManager.js +770 -0
  171. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBKeyframe.js +60 -0
  172. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBReader.js +1129 -0
  173. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBReaderUtil.js +61 -0
  174. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBRelativePositioning.js +90 -0
  175. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBSequence.js +114 -0
  176. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBValue.js +81 -0
  177. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCControlLoader.js +318 -0
  178. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCNodeLoader.js +905 -0
  179. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCNodeLoaderLibrary.js +101 -0
  180. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCSpriteLoader.js +544 -0
  181. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccpool/CCPool.js +146 -0
  182. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/CCProtectedNode.js +305 -0
  183. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +246 -0
  184. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +159 -0
  185. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIScale9Sprite.js +1105 -0
  186. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js +142 -0
  187. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js +129 -0
  188. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIWidget.js +2059 -0
  189. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIWidgetRenderCmd.js +100 -0
  190. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UIHBox.js +80 -0
  191. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayout.js +1558 -0
  192. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js +179 -0
  193. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutComponent.js +585 -0
  194. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutManager.js +457 -0
  195. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutParameter.js +576 -0
  196. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js +240 -0
  197. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UIRelativeBox.js +79 -0
  198. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UIVBox.js +79 -0
  199. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/system/CocosGUI.js +62 -0
  200. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/system/UIHelper.js +164 -0
  201. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIButton.js +987 -0
  202. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UICheckBox.js +737 -0
  203. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIImageView.js +337 -0
  204. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UILoadingBar.js +432 -0
  205. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIRichText.js +579 -0
  206. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UISlider.js +762 -0
  207. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIText.js +512 -0
  208. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UITextAtlas.js +229 -0
  209. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UITextBMFont.js +216 -0
  210. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UITextField.js +915 -0
  211. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +602 -0
  212. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +657 -0
  213. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +1884 -0
  214. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/CocoStudio.js +68 -0
  215. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionFrame.js +528 -0
  216. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionManager.js +112 -0
  217. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionNode.js +417 -0
  218. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionObject.js +263 -0
  219. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCArmature.js +579 -0
  220. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js +190 -0
  221. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js +167 -0
  222. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCBone.js +711 -0
  223. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +669 -0
  224. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/animation/CCProcessBase.js +365 -0
  225. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/animation/CCTween.js +448 -0
  226. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/datas/CCDatas.js +807 -0
  227. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCDecorativeDisplay.js +118 -0
  228. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCDisplayFactory.js +220 -0
  229. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCDisplayManager.js +465 -0
  230. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCSkin.js +215 -0
  231. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js +58 -0
  232. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js +146 -0
  233. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/physics/CCColliderDetector.js +397 -0
  234. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +325 -0
  235. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCArmatureDefine.js +45 -0
  236. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +1223 -0
  237. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js +68 -0
  238. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCTransformHelp.js +183 -0
  239. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCTweenFunction.js +501 -0
  240. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCUtilMath.js +69 -0
  241. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComAttribute.js +210 -0
  242. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComAudio.js +285 -0
  243. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComController.js +76 -0
  244. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComRender.js +91 -0
  245. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComponent.js +136 -0
  246. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComponentContainer.js +159 -0
  247. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/load.js +221 -0
  248. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/action-1.x.js +238 -0
  249. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/action-2.x.js +266 -0
  250. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/compatible.js +251 -0
  251. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/scene-1.x.js +262 -0
  252. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/timelineParser-1.x.js +292 -0
  253. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +1288 -0
  254. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/uiParser-1.x.js +680 -0
  255. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/timeline/ActionTimeline.js +448 -0
  256. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/timeline/Frame.js +1268 -0
  257. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/timeline/Timeline.js +321 -0
  258. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/ObjectFactory.js +99 -0
  259. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/TriggerBase.js +49 -0
  260. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/TriggerMng.js +301 -0
  261. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/TriggerObj.js +263 -0
  262. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/editbox/CCEditBox.js +716 -0
  263. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/editbox/CCdomNode.js +657 -0
  264. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControl.js +381 -0
  265. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlButton.js +688 -0
  266. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlColourPicker.js +187 -0
  267. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlHuePicker.js +218 -0
  268. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlPotentiometer.js +300 -0
  269. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js +257 -0
  270. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlSlider.js +308 -0
  271. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlStepper.js +390 -0
  272. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlSwitch.js +425 -0
  273. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlUtils.js +177 -0
  274. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCInvocation.js +65 -0
  275. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCMenuPassive.js +415 -0
  276. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCScale9Sprite.js +1099 -0
  277. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js +142 -0
  278. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js +129 -0
  279. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCScrollView.js +827 -0
  280. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js +79 -0
  281. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCScrollViewWebGLRenderCmd.js +108 -0
  282. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCSorting.js +239 -0
  283. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCTableView.js +718 -0
  284. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeleton.js +357 -0
  285. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeletonAnimation.js +340 -0
  286. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeletonCanvasRenderCmd.js +165 -0
  287. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeletonWebGLRenderCmd.js +165 -0
  288. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/Spine.js +2239 -0
  289. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/box2d/box2d.js +10882 -0
  290. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/chipmunk/chipmunk.js +6196 -0
  291. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/pluginx/Plugin.js +254 -0
  292. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/pluginx/platform/facebook.js +557 -0
  293. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/pluginx/platform/facebook_sdk.js +151 -0
  294. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/socketio/socket.io.min.js +2 -0
  295. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/jsb_apis.js +618 -0
  296. data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/moduleConfig.json +453 -0
  297. data/lib/ccb/builder/templates/project/folder/project.json +42 -0
  298. data/lib/ccb/builder/templates/project/folder/res/CloseNormal.png +0 -0
  299. data/lib/ccb/builder/templates/project/folder/res/CloseSelected.png +0 -0
  300. data/lib/ccb/builder/templates/project/folder/res/HelloWorld.png +0 -0
  301. data/lib/ccb/builder/templates/project/folder/res/favicon.ico +0 -0
  302. data/lib/ccb/builder/templates/project/folder/res/gameOver/cocos2d-html5.png +0 -0
  303. data/lib/ccb/builder/templates/project/folder/res/gameOver/gameOver.png +0 -0
  304. data/lib/ccb/builder/templates/project/folder/res/mainMenu/bg.png +0 -0
  305. data/lib/ccb/builder/templates/project/folder/res/mainMenu/menu.png +0 -0
  306. data/lib/ccb/builder/templates/project/folder/res/setting/menuTitle.png +0 -0
  307. data/lib/ccb/builder/templates/project/folder/res/shared/arial-14.fnt +182 -0
  308. data/lib/ccb/builder/templates/project/folder/res/shared/arial-14.png +0 -0
  309. data/lib/ccb/builder/templates/project/folder/res/sound/music/bgMusic.mp3 +0 -0
  310. data/lib/ccb/builder/templates/project/folder/src/about/layer/ABBackgroundLayer.js +23 -0
  311. data/lib/ccb/builder/templates/project/folder/src/about/layer/ABTouchLayer.js +51 -0
  312. data/lib/ccb/builder/templates/project/folder/src/about/scene/About.js +36 -0
  313. data/lib/ccb/builder/templates/project/folder/src/config/Level.js +7 -0
  314. data/lib/ccb/builder/templates/project/folder/src/gameOver/layer/GOBackgroundLayer.js +50 -0
  315. data/lib/ccb/builder/templates/project/folder/src/gameOver/layer/GOTouchLayer.js +51 -0
  316. data/lib/ccb/builder/templates/project/folder/src/gameOver/scene/GameOver.js +38 -0
  317. data/lib/ccb/builder/templates/project/folder/src/gamePlay/classes/LevelManager.js +21 -0
  318. data/lib/ccb/builder/templates/project/folder/src/gamePlay/layer/GPBackgroundLayer.js +25 -0
  319. data/lib/ccb/builder/templates/project/folder/src/gamePlay/layer/GPTouchLayer.js +51 -0
  320. data/lib/ccb/builder/templates/project/folder/src/gamePlay/scene/GamePlay.js +44 -0
  321. data/lib/ccb/builder/templates/project/folder/src/mainMenu/layer/MMBackgroundLayer.js +43 -0
  322. data/lib/ccb/builder/templates/project/folder/src/mainMenu/layer/MMMainMenuLayer.js +38 -0
  323. data/lib/ccb/builder/templates/project/folder/src/mainMenu/layer/MMTouchLayer.js +96 -0
  324. data/lib/ccb/builder/templates/project/folder/src/mainMenu/scene/MainMenu.js +45 -0
  325. data/lib/ccb/builder/templates/project/folder/src/resource.js +29 -0
  326. data/lib/ccb/builder/templates/project/folder/src/setting/layer/STBackgroundLayer.js +25 -0
  327. data/lib/ccb/builder/templates/project/folder/src/setting/layer/STTouchLayer.js +89 -0
  328. data/lib/ccb/builder/templates/project/folder/src/setting/scene/Setting.js +40 -0
  329. data/lib/ccb/builder/templates/project/index.html.tt +27 -0
  330. data/lib/ccb/builder/templates/project/main.js.tt +62 -0
  331. data/lib/ccb/cli.rb +32 -0
  332. data/lib/ccb/ext/method_hooker.rb +68 -0
  333. data/lib/ccb/ext/string_extention.rb +7 -0
  334. data/lib/ccb.rb +1 -0
  335. metadata +449 -0
@@ -0,0 +1,3554 @@
1
+ /****************************************************************************
2
+ Copyright (c) 2008-2010 Ricardo Quesada
3
+ Copyright (c) 2011-2012 cocos2d-x.org
4
+ Copyright (c) 2013-2014 Chukong Technologies Inc.
5
+
6
+ http://www.cocos2d-x.org
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+ ****************************************************************************/
26
+
27
+ /**
28
+ * <p> An interval action is an action that takes place within a certain period of time. <br/>
29
+ * It has an start time, and a finish time. The finish time is the parameter<br/>
30
+ * duration plus the start time.</p>
31
+ *
32
+ * <p>These CCActionInterval actions have some interesting properties, like:<br/>
33
+ * - They can run normally (default) <br/>
34
+ * - They can run reversed with the reverse method <br/>
35
+ * - They can run with the time altered with the Accelerate, AccelDeccel and Speed actions. </p>
36
+ *
37
+ * <p>For example, you can simulate a Ping Pong effect running the action normally and<br/>
38
+ * then running it again in Reverse mode. </p>
39
+ *
40
+ * @class
41
+ * @extends cc.FiniteTimeAction
42
+ * @param {Number} d duration in seconds
43
+ * @example
44
+ * var actionInterval = new cc.ActionInterval(3);
45
+ */
46
+ cc.ActionInterval = cc.FiniteTimeAction.extend(/** @lends cc.ActionInterval# */{
47
+ _elapsed:0,
48
+ _firstTick:false,
49
+ _easeList: null,
50
+ _timesForRepeat:1,
51
+ _repeatForever: false,
52
+ _repeatMethod: false,//Compatible with repeat class, Discard after can be deleted
53
+ _speed: 1,
54
+ _speedMethod: false,//Compatible with speed class, Discard after can be deleted
55
+
56
+ /**
57
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
58
+ * @param {Number} d duration in seconds
59
+ */
60
+ ctor:function (d) {
61
+ this._speed = 1;
62
+ this._timesForRepeat = 1;
63
+ this._repeatForever = false;
64
+ this.MAX_VALUE = 2;
65
+ this._repeatMethod = false;//Compatible with repeat class, Discard after can be deleted
66
+ this._speedMethod = false;//Compatible with repeat class, Discard after can be deleted
67
+ cc.FiniteTimeAction.prototype.ctor.call(this);
68
+ d !== undefined && this.initWithDuration(d);
69
+ },
70
+
71
+ /**
72
+ * How many seconds had elapsed since the actions started to run.
73
+ * @return {Number}
74
+ */
75
+ getElapsed:function () {
76
+ return this._elapsed;
77
+ },
78
+
79
+ /**
80
+ * Initializes the action.
81
+ * @param {Number} d duration in seconds
82
+ * @return {Boolean}
83
+ */
84
+ initWithDuration:function (d) {
85
+ this._duration = (d === 0) ? cc.FLT_EPSILON : d;
86
+ // prevent division by 0
87
+ // This comparison could be in step:, but it might decrease the performance
88
+ // by 3% in heavy based action games.
89
+ this._elapsed = 0;
90
+ this._firstTick = true;
91
+ return true;
92
+ },
93
+
94
+ /**
95
+ * Returns true if the action has finished.
96
+ * @return {Boolean}
97
+ */
98
+ isDone:function () {
99
+ return (this._elapsed >= this._duration);
100
+ },
101
+
102
+ /**
103
+ * Some additional parameters of cloning.
104
+ * @param {cc.Action} action
105
+ * @private
106
+ */
107
+ _cloneDecoration: function(action){
108
+ action._repeatForever = this._repeatForever;
109
+ action._speed = this._speed;
110
+ action._timesForRepeat = this._timesForRepeat;
111
+ action._easeList = this._easeList;
112
+ action._speedMethod = this._speedMethod;
113
+ action._repeatMethod = this._repeatMethod;
114
+ },
115
+
116
+ _reverseEaseList: function(action){
117
+ if(this._easeList){
118
+ action._easeList = [];
119
+ for(var i=0; i<this._easeList.length; i++){
120
+ action._easeList.push(this._easeList[i].reverse());
121
+ }
122
+ }
123
+ },
124
+
125
+ /**
126
+ * Returns a new clone of the action.
127
+ * @returns {cc.ActionInterval}
128
+ */
129
+ clone:function () {
130
+ var action = new cc.ActionInterval(this._duration);
131
+ this._cloneDecoration(action);
132
+ return action;
133
+ },
134
+
135
+ /**
136
+ * Implementation of ease motion.
137
+ *
138
+ * @example
139
+ * //example
140
+ * action.easeing(cc.easeIn(3.0));
141
+ * @param {Object} easeObj
142
+ * @returns {cc.ActionInterval}
143
+ */
144
+ easing: function (easeObj) {
145
+ if (this._easeList)
146
+ this._easeList.length = 0;
147
+ else
148
+ this._easeList = [];
149
+ for (var i = 0; i < arguments.length; i++)
150
+ this._easeList.push(arguments[i]);
151
+ return this;
152
+ },
153
+
154
+ _computeEaseTime: function (dt) {
155
+ var locList = this._easeList;
156
+ if ((!locList) || (locList.length === 0))
157
+ return dt;
158
+ for (var i = 0, n = locList.length; i < n; i++)
159
+ dt = locList[i].easing(dt);
160
+ return dt;
161
+ },
162
+
163
+ /**
164
+ * called every frame with it's delta time. <br />
165
+ * DON'T override unless you know what you are doing.
166
+ *
167
+ * @param {Number} dt
168
+ */
169
+ step:function (dt) {
170
+ if (this._firstTick) {
171
+ this._firstTick = false;
172
+ this._elapsed = 0;
173
+ } else
174
+ this._elapsed += dt;
175
+
176
+ //this.update((1 > (this._elapsed / this._duration)) ? this._elapsed / this._duration : 1);
177
+ //this.update(Math.max(0, Math.min(1, this._elapsed / Math.max(this._duration, cc.FLT_EPSILON))));
178
+ var t = this._elapsed / (this._duration > 0.0000001192092896 ? this._duration : 0.0000001192092896);
179
+ t = (1 > t ? t : 1);
180
+ this.update(t > 0 ? t : 0);
181
+
182
+ //Compatible with repeat class, Discard after can be deleted (this._repeatMethod)
183
+ if(this._repeatMethod && this._timesForRepeat > 1 && this.isDone()){
184
+ if(!this._repeatForever){
185
+ this._timesForRepeat--;
186
+ }
187
+ //var diff = locInnerAction.getElapsed() - locInnerAction._duration;
188
+ this.startWithTarget(this.target);
189
+ // to prevent jerk. issue #390 ,1247
190
+ //this._innerAction.step(0);
191
+ //this._innerAction.step(diff);
192
+ this.step(this._elapsed - this._duration);
193
+
194
+ }
195
+ },
196
+
197
+ /**
198
+ * Start this action with target.
199
+ * @param {cc.Node} target
200
+ */
201
+ startWithTarget:function (target) {
202
+ cc.Action.prototype.startWithTarget.call(this, target);
203
+ this._elapsed = 0;
204
+ this._firstTick = true;
205
+ },
206
+
207
+ /**
208
+ * returns a reversed action. <br />
209
+ * Will be overwrite.
210
+ *
211
+ * @return {null}
212
+ */
213
+ reverse:function () {
214
+ cc.log("cc.IntervalAction: reverse not implemented.");
215
+ return null;
216
+ },
217
+
218
+ /**
219
+ * Set amplitude rate.
220
+ * @warning It should be overridden in subclass.
221
+ * @param {Number} amp
222
+ */
223
+ setAmplitudeRate:function (amp) {
224
+ // Abstract class needs implementation
225
+ cc.log("cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.");
226
+ },
227
+
228
+ /**
229
+ * Get amplitude rate.
230
+ * @warning It should be overridden in subclass.
231
+ * @return {Number} 0
232
+ */
233
+ getAmplitudeRate:function () {
234
+ // Abstract class needs implementation
235
+ cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass.");
236
+ return 0;
237
+ },
238
+
239
+ /**
240
+ * Changes the speed of an action, making it take longer (speed>1)
241
+ * or less (speed<1) time. <br/>
242
+ * Useful to simulate 'slow motion' or 'fast forward' effect.
243
+ *
244
+ * @param speed
245
+ * @returns {cc.Action}
246
+ */
247
+ speed: function(speed){
248
+ if(speed <= 0){
249
+ cc.log("The speed parameter error");
250
+ return this;
251
+ }
252
+
253
+ this._speedMethod = true;//Compatible with repeat class, Discard after can be deleted
254
+ this._speed *= speed;
255
+ return this;
256
+ },
257
+
258
+ /**
259
+ * Get this action speed.
260
+ * @return {Number}
261
+ */
262
+ getSpeed: function(){
263
+ return this._speed;
264
+ },
265
+
266
+ /**
267
+ * Set this action speed.
268
+ * @param {Number} speed
269
+ * @returns {cc.ActionInterval}
270
+ */
271
+ setSpeed: function(speed){
272
+ this._speed = speed;
273
+ return this;
274
+ },
275
+
276
+ /**
277
+ * Repeats an action a number of times.
278
+ * To repeat an action forever use the CCRepeatForever action.
279
+ * @param times
280
+ * @returns {cc.ActionInterval}
281
+ */
282
+ repeat: function(times){
283
+ times = Math.round(times);
284
+ if(isNaN(times) || times < 1){
285
+ cc.log("The repeat parameter error");
286
+ return this;
287
+ }
288
+ this._repeatMethod = true;//Compatible with repeat class, Discard after can be deleted
289
+ this._timesForRepeat *= times;
290
+ return this;
291
+ },
292
+
293
+ /**
294
+ * Repeats an action for ever. <br/>
295
+ * To repeat the an action for a limited number of times use the Repeat action. <br/>
296
+ * @returns {cc.ActionInterval}
297
+ */
298
+ repeatForever: function(){
299
+ this._repeatMethod = true;//Compatible with repeat class, Discard after can be deleted
300
+ this._timesForRepeat = this.MAX_VALUE;
301
+ this._repeatForever = true;
302
+ return this;
303
+ }
304
+ });
305
+
306
+ /**
307
+ * An interval action is an action that takes place within a certain period of time.
308
+ * @function
309
+ * @param {Number} d duration in seconds
310
+ * @return {cc.ActionInterval}
311
+ * @example
312
+ * // example
313
+ * var actionInterval = cc.actionInterval(3);
314
+ */
315
+ cc.actionInterval = function (d) {
316
+ return new cc.ActionInterval(d);
317
+ };
318
+
319
+ /**
320
+ * Please use cc.actionInterval instead.
321
+ * An interval action is an action that takes place within a certain period of time.
322
+ * @static
323
+ * @deprecated since v3.0 <br /> Please use cc.actionInterval instead.
324
+ * @param {Number} d duration in seconds
325
+ * @return {cc.ActionInterval}
326
+ */
327
+ cc.ActionInterval.create = cc.actionInterval;
328
+
329
+ /**
330
+ * Runs actions sequentially, one after another.
331
+ * @class
332
+ * @extends cc.ActionInterval
333
+ * @param {Array|cc.FiniteTimeAction} tempArray
334
+ * @example
335
+ * // create sequence with actions
336
+ * var seq = new cc.Sequence(act1, act2);
337
+ *
338
+ * // create sequence with array
339
+ * var seq = new cc.Sequence(actArray);
340
+ */
341
+ cc.Sequence = cc.ActionInterval.extend(/** @lends cc.Sequence# */{
342
+ _actions:null,
343
+ _split:null,
344
+ _last:0,
345
+
346
+ /**
347
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
348
+ * Create an array of sequenceable actions.
349
+ * @param {Array|cc.FiniteTimeAction} tempArray
350
+ */
351
+ ctor:function (tempArray) {
352
+ cc.ActionInterval.prototype.ctor.call(this);
353
+ this._actions = [];
354
+
355
+ var paramArray = (tempArray instanceof Array) ? tempArray : arguments;
356
+ var last = paramArray.length - 1;
357
+ if ((last >= 0) && (paramArray[last] == null))
358
+ cc.log("parameters should not be ending with null in Javascript");
359
+
360
+ if (last >= 0) {
361
+ var prev = paramArray[0], action1;
362
+ for (var i = 1; i < last; i++) {
363
+ if (paramArray[i]) {
364
+ action1 = prev;
365
+ prev = cc.Sequence._actionOneTwo(action1, paramArray[i]);
366
+ }
367
+ }
368
+ this.initWithTwoActions(prev, paramArray[last]);
369
+ }
370
+ },
371
+
372
+ /**
373
+ * Initializes the action <br/>
374
+ * @param {cc.FiniteTimeAction} actionOne
375
+ * @param {cc.FiniteTimeAction} actionTwo
376
+ * @return {Boolean}
377
+ */
378
+ initWithTwoActions:function (actionOne, actionTwo) {
379
+ if(!actionOne || !actionTwo)
380
+ throw "cc.Sequence.initWithTwoActions(): arguments must all be non nil";
381
+
382
+ var d = actionOne._duration + actionTwo._duration;
383
+ this.initWithDuration(d);
384
+
385
+ this._actions[0] = actionOne;
386
+ this._actions[1] = actionTwo;
387
+ return true;
388
+ },
389
+
390
+ /**
391
+ * returns a new clone of the action
392
+ * @returns {cc.Sequence}
393
+ */
394
+ clone:function () {
395
+ var action = new cc.Sequence();
396
+ this._cloneDecoration(action);
397
+ action.initWithTwoActions(this._actions[0].clone(), this._actions[1].clone());
398
+ return action;
399
+ },
400
+
401
+ /**
402
+ * Start the action with target.
403
+ * @param {cc.Node} target
404
+ */
405
+ startWithTarget:function (target) {
406
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
407
+ this._split = this._actions[0]._duration / this._duration;
408
+ this._last = -1;
409
+ },
410
+
411
+ /**
412
+ * stop the action.
413
+ */
414
+ stop:function () {
415
+ // Issue #1305
416
+ if (this._last !== -1)
417
+ this._actions[this._last].stop();
418
+ cc.Action.prototype.stop.call(this);
419
+ },
420
+
421
+ /**
422
+ * Called once per frame. Time is the number of seconds of a frame interval.
423
+ * @param {Number} dt
424
+ */
425
+ update:function (dt) {
426
+ var new_t, found = 0;
427
+ var locSplit = this._split, locActions = this._actions, locLast = this._last, actionFound;
428
+
429
+ dt = this._computeEaseTime(dt);
430
+ if (dt < locSplit) {
431
+ // action[0]
432
+ new_t = (locSplit !== 0) ? dt / locSplit : 1;
433
+
434
+ if (found === 0 && locLast === 1) {
435
+ // Reverse mode ?
436
+ // XXX: Bug. this case doesn't contemplate when _last==-1, found=0 and in "reverse mode"
437
+ // since it will require a hack to know if an action is on reverse mode or not.
438
+ // "step" should be overriden, and the "reverseMode" value propagated to inner Sequences.
439
+ locActions[1].update(0);
440
+ locActions[1].stop();
441
+ }
442
+ } else {
443
+ // action[1]
444
+ found = 1;
445
+ new_t = (locSplit === 1) ? 1 : (dt - locSplit) / (1 - locSplit);
446
+
447
+ if (locLast === -1) {
448
+ // action[0] was skipped, execute it.
449
+ locActions[0].startWithTarget(this.target);
450
+ locActions[0].update(1);
451
+ locActions[0].stop();
452
+ }
453
+ if (!locLast) {
454
+ // switching to action 1. stop action 0.
455
+ locActions[0].update(1);
456
+ locActions[0].stop();
457
+ }
458
+ }
459
+
460
+ actionFound = locActions[found];
461
+ // Last action found and it is done.
462
+ if (locLast === found && actionFound.isDone())
463
+ return;
464
+
465
+ // Last action found and it is done
466
+ if (locLast !== found)
467
+ actionFound.startWithTarget(this.target);
468
+
469
+ new_t = new_t * actionFound._timesForRepeat;
470
+ actionFound.update(new_t > 1 ? new_t % 1 : new_t);
471
+ this._last = found;
472
+ },
473
+
474
+ /**
475
+ * Returns a reversed action.
476
+ * @return {cc.Sequence}
477
+ */
478
+ reverse:function () {
479
+ var action = cc.Sequence._actionOneTwo(this._actions[1].reverse(), this._actions[0].reverse());
480
+ this._cloneDecoration(action);
481
+ this._reverseEaseList(action);
482
+ return action;
483
+ }
484
+ });
485
+
486
+ /** helper constructor to create an array of sequenceable actions
487
+ * @function
488
+ * @param {Array|cc.FiniteTimeAction} tempArray
489
+ * @return {cc.Sequence}
490
+ * @example
491
+ * // example
492
+ * // create sequence with actions
493
+ * var seq = cc.sequence(act1, act2);
494
+ *
495
+ * // create sequence with array
496
+ * var seq = cc.sequence(actArray);
497
+ * todo: It should be use new
498
+ */
499
+ cc.sequence = function (/*Multiple Arguments*/tempArray) {
500
+ var paramArray = (tempArray instanceof Array) ? tempArray : arguments;
501
+ if ((paramArray.length > 0) && (paramArray[paramArray.length - 1] == null))
502
+ cc.log("parameters should not be ending with null in Javascript");
503
+
504
+ var result, current, i, repeat;
505
+ while(paramArray && paramArray.length > 0){
506
+ current = Array.prototype.shift.call(paramArray);
507
+ repeat = current._timesForRepeat || 1;
508
+ current._repeatMethod = false;
509
+ current._timesForRepeat = 1;
510
+
511
+ i = 0;
512
+ if(!result){
513
+ result = current;
514
+ i = 1;
515
+ }
516
+
517
+ for(i; i<repeat; i++){
518
+ result = cc.Sequence._actionOneTwo(result, current);
519
+ }
520
+ }
521
+
522
+ return result;
523
+ };
524
+
525
+ /**
526
+ * Please use cc.sequence instead.
527
+ * helper constructor to create an array of sequenceable actions
528
+ * @static
529
+ * @deprecated since v3.0 <br /> Please use cc.sequence instead.
530
+ * @param {Array|cc.FiniteTimeAction} tempArray
531
+ * @return {cc.Sequence}
532
+ */
533
+ cc.Sequence.create = cc.sequence;
534
+
535
+ /** creates the action
536
+ * @param {cc.FiniteTimeAction} actionOne
537
+ * @param {cc.FiniteTimeAction} actionTwo
538
+ * @return {cc.Sequence}
539
+ * @private
540
+ */
541
+ cc.Sequence._actionOneTwo = function (actionOne, actionTwo) {
542
+ var sequence = new cc.Sequence();
543
+ sequence.initWithTwoActions(actionOne, actionTwo);
544
+ return sequence;
545
+ };
546
+
547
+ /**
548
+ * Repeats an action a number of times.
549
+ * To repeat an action forever use the CCRepeatForever action.
550
+ * @class
551
+ * @extends cc.ActionInterval
552
+ * @param {cc.FiniteTimeAction} action
553
+ * @param {Number} times
554
+ * @example
555
+ * var rep = new cc.Repeat(cc.sequence(jump2, jump1), 5);
556
+ */
557
+ cc.Repeat = cc.ActionInterval.extend(/** @lends cc.Repeat# */{
558
+ _times:0,
559
+ _total:0,
560
+ _nextDt:0,
561
+ _actionInstant:false,
562
+ _innerAction:null, //CCFiniteTimeAction
563
+
564
+ /**
565
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
566
+ * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30).
567
+ * @param {cc.FiniteTimeAction} action
568
+ * @param {Number} times
569
+ */
570
+ ctor: function (action, times) {
571
+ cc.ActionInterval.prototype.ctor.call(this);
572
+
573
+ times !== undefined && this.initWithAction(action, times);
574
+ },
575
+
576
+ /**
577
+ * @param {cc.FiniteTimeAction} action
578
+ * @param {Number} times
579
+ * @return {Boolean}
580
+ */
581
+ initWithAction:function (action, times) {
582
+ var duration = action._duration * times;
583
+
584
+ if (this.initWithDuration(duration)) {
585
+ this._times = times;
586
+ this._innerAction = action;
587
+ if (action instanceof cc.ActionInstant){
588
+ this._actionInstant = true;
589
+ this._times -= 1;
590
+ }
591
+ this._total = 0;
592
+ return true;
593
+ }
594
+ return false;
595
+ },
596
+
597
+ /**
598
+ * returns a new clone of the action
599
+ * @returns {cc.Repeat}
600
+ */
601
+ clone:function () {
602
+ var action = new cc.Repeat();
603
+ this._cloneDecoration(action);
604
+ action.initWithAction(this._innerAction.clone(), this._times);
605
+ return action;
606
+ },
607
+
608
+ /**
609
+ * Start the action with target.
610
+ * @param {cc.Node} target
611
+ */
612
+ startWithTarget:function (target) {
613
+ this._total = 0;
614
+ this._nextDt = this._innerAction._duration / this._duration;
615
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
616
+ this._innerAction.startWithTarget(target);
617
+ },
618
+
619
+ /**
620
+ * stop the action
621
+ */
622
+ stop:function () {
623
+ this._innerAction.stop();
624
+ cc.Action.prototype.stop.call(this);
625
+ },
626
+
627
+ /**
628
+ * Called once per frame. Time is the number of seconds of a frame interval.
629
+ * @param {Number} dt
630
+ */
631
+ update:function (dt) {
632
+ dt = this._computeEaseTime(dt);
633
+ var locInnerAction = this._innerAction;
634
+ var locDuration = this._duration;
635
+ var locTimes = this._times;
636
+ var locNextDt = this._nextDt;
637
+
638
+ if (dt >= locNextDt) {
639
+ while (dt > locNextDt && this._total < locTimes) {
640
+ locInnerAction.update(1);
641
+ this._total++;
642
+ locInnerAction.stop();
643
+ locInnerAction.startWithTarget(this.target);
644
+ locNextDt += locInnerAction._duration / locDuration;
645
+ this._nextDt = locNextDt;
646
+ }
647
+
648
+ // fix for issue #1288, incorrect end value of repeat
649
+ if (dt >= 1.0 && this._total < locTimes)
650
+ this._total++;
651
+
652
+ // don't set a instant action back or update it, it has no use because it has no duration
653
+ if (!this._actionInstant) {
654
+ if (this._total === locTimes) {
655
+ locInnerAction.update(1);
656
+ locInnerAction.stop();
657
+ } else {
658
+ // issue #390 prevent jerk, use right update
659
+ locInnerAction.update(dt - (locNextDt - locInnerAction._duration / locDuration));
660
+ }
661
+ }
662
+ } else {
663
+ locInnerAction.update((dt * locTimes) % 1.0);
664
+ }
665
+ },
666
+
667
+ /**
668
+ * Return true if the action has finished.
669
+ * @return {Boolean}
670
+ */
671
+ isDone:function () {
672
+ return this._total == this._times;
673
+ },
674
+
675
+ /**
676
+ * returns a reversed action.
677
+ * @return {cc.Repeat}
678
+ */
679
+ reverse:function () {
680
+ var action = new cc.Repeat(this._innerAction.reverse(), this._times);
681
+ this._cloneDecoration(action);
682
+ this._reverseEaseList(action);
683
+ return action;
684
+ },
685
+
686
+ /**
687
+ * Set inner Action.
688
+ * @param {cc.FiniteTimeAction} action
689
+ */
690
+ setInnerAction:function (action) {
691
+ if (this._innerAction != action) {
692
+ this._innerAction = action;
693
+ }
694
+ },
695
+
696
+ /**
697
+ * Get inner Action.
698
+ * @return {cc.FiniteTimeAction}
699
+ */
700
+ getInnerAction:function () {
701
+ return this._innerAction;
702
+ }
703
+ });
704
+
705
+ /**
706
+ * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
707
+ * @function
708
+ * @param {cc.FiniteTimeAction} action
709
+ * @param {Number} times
710
+ * @return {cc.Repeat}
711
+ * @example
712
+ * // example
713
+ * var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
714
+ */
715
+ cc.repeat = function (action, times) {
716
+ return new cc.Repeat(action, times);
717
+ };
718
+
719
+ /**
720
+ * Please use cc.repeat instead
721
+ * Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)
722
+ * @static
723
+ * @deprecated since v3.0 <br /> Please use cc.repeat instead.
724
+ * @param {cc.FiniteTimeAction} action
725
+ * @param {Number} times
726
+ * @return {cc.Repeat}
727
+ */
728
+ cc.Repeat.create = cc.repeat;
729
+
730
+
731
+ /** Repeats an action for ever. <br/>
732
+ * To repeat the an action for a limited number of times use the Repeat action. <br/>
733
+ * @warning This action can't be Sequenceable because it is not an IntervalAction
734
+ * @class
735
+ * @extends cc.ActionInterval
736
+ * @param {cc.FiniteTimeAction} action
737
+ * @example
738
+ * var rep = new cc.RepeatForever(cc.sequence(jump2, jump1), 5);
739
+ */
740
+ cc.RepeatForever = cc.ActionInterval.extend(/** @lends cc.RepeatForever# */{
741
+ _innerAction:null, //CCActionInterval
742
+
743
+ /**
744
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
745
+ * Create a acton which repeat forever.
746
+ * @param {cc.FiniteTimeAction} action
747
+ */
748
+ ctor:function (action) {
749
+ cc.ActionInterval.prototype.ctor.call(this);
750
+ this._innerAction = null;
751
+
752
+ action && this.initWithAction(action);
753
+ },
754
+
755
+ /**
756
+ * @param {cc.ActionInterval} action
757
+ * @return {Boolean}
758
+ */
759
+ initWithAction:function (action) {
760
+ if(!action)
761
+ throw "cc.RepeatForever.initWithAction(): action must be non null";
762
+
763
+ this._innerAction = action;
764
+ return true;
765
+ },
766
+
767
+ /**
768
+ * returns a new clone of the action
769
+ * @returns {cc.RepeatForever}
770
+ */
771
+ clone:function () {
772
+ var action = new cc.RepeatForever();
773
+ this._cloneDecoration(action);
774
+ action.initWithAction(this._innerAction.clone());
775
+ return action;
776
+ },
777
+
778
+ /**
779
+ * Start the action with target.
780
+ * @param {cc.Node} target
781
+ */
782
+ startWithTarget:function (target) {
783
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
784
+ this._innerAction.startWithTarget(target);
785
+ },
786
+
787
+ /**
788
+ * called every frame with it's delta time. <br />
789
+ * DON'T override unless you know what you are doing.
790
+ * @param dt delta time in seconds
791
+ */
792
+ step:function (dt) {
793
+ var locInnerAction = this._innerAction;
794
+ locInnerAction.step(dt);
795
+ if (locInnerAction.isDone()) {
796
+ //var diff = locInnerAction.getElapsed() - locInnerAction._duration;
797
+ locInnerAction.startWithTarget(this.target);
798
+ // to prevent jerk. issue #390 ,1247
799
+ //this._innerAction.step(0);
800
+ //this._innerAction.step(diff);
801
+ locInnerAction.step(locInnerAction.getElapsed() - locInnerAction._duration);
802
+ }
803
+ },
804
+
805
+ /**
806
+ * Return true if the action has finished.
807
+ * @return {Boolean}
808
+ */
809
+ isDone:function () {
810
+ return false;
811
+ },
812
+
813
+ /**
814
+ * Returns a reversed action.
815
+ * @return {cc.RepeatForever}
816
+ */
817
+ reverse:function () {
818
+ var action = new cc.RepeatForever(this._innerAction.reverse());
819
+ this._cloneDecoration(action);
820
+ this._reverseEaseList(action);
821
+ return action;
822
+ },
823
+
824
+ /**
825
+ * Set inner action.
826
+ * @param {cc.ActionInterval} action
827
+ */
828
+ setInnerAction:function (action) {
829
+ if (this._innerAction != action) {
830
+ this._innerAction = action;
831
+ }
832
+ },
833
+
834
+ /**
835
+ * Get inner action.
836
+ * @return {cc.ActionInterval}
837
+ */
838
+ getInnerAction:function () {
839
+ return this._innerAction;
840
+ }
841
+ });
842
+
843
+ /**
844
+ * Create a acton which repeat forever
845
+ * @function
846
+ * @param {cc.FiniteTimeAction} action
847
+ * @return {cc.RepeatForever}
848
+ * @example
849
+ * // example
850
+ * var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
851
+ */
852
+ cc.repeatForever = function (action) {
853
+ return new cc.RepeatForever(action);
854
+ };
855
+
856
+ /**
857
+ * Please use cc.repeatForever instead
858
+ * Create a acton which repeat forever
859
+ * @static
860
+ * @deprecated since v3.0 <br /> Please use cc.repeatForever instead.
861
+ * @param {cc.FiniteTimeAction} action
862
+ * @return {cc.RepeatForever}
863
+ * @param {Array|cc.FiniteTimeAction} tempArray
864
+ * @example
865
+ * var action = new cc.Spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720));
866
+ */
867
+ cc.RepeatForever.create = cc.repeatForever;
868
+
869
+
870
+ /** Spawn a new action immediately
871
+ * @class
872
+ * @extends cc.ActionInterval
873
+ */
874
+ cc.Spawn = cc.ActionInterval.extend(/** @lends cc.Spawn# */{
875
+ _one:null,
876
+ _two:null,
877
+
878
+ /**
879
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
880
+ * @param {Array|cc.FiniteTimeAction} tempArray
881
+ */
882
+ ctor:function (tempArray) {
883
+ cc.ActionInterval.prototype.ctor.call(this);
884
+ this._one = null;
885
+ this._two = null;
886
+
887
+ var paramArray = (tempArray instanceof Array) ? tempArray : arguments;
888
+ var last = paramArray.length - 1;
889
+ if ((last >= 0) && (paramArray[last] == null))
890
+ cc.log("parameters should not be ending with null in Javascript");
891
+
892
+ if (last >= 0) {
893
+ var prev = paramArray[0], action1;
894
+ for (var i = 1; i < last; i++) {
895
+ if (paramArray[i]) {
896
+ action1 = prev;
897
+ prev = cc.Spawn._actionOneTwo(action1, paramArray[i]);
898
+ }
899
+ }
900
+ this.initWithTwoActions(prev, paramArray[last]);
901
+ }
902
+ },
903
+
904
+ /** initializes the Spawn action with the 2 actions to spawn
905
+ * @param {cc.FiniteTimeAction} action1
906
+ * @param {cc.FiniteTimeAction} action2
907
+ * @return {Boolean}
908
+ */
909
+ initWithTwoActions:function (action1, action2) {
910
+ if(!action1 || !action2)
911
+ throw "cc.Spawn.initWithTwoActions(): arguments must all be non null" ;
912
+
913
+ var ret = false;
914
+
915
+ var d1 = action1._duration;
916
+ var d2 = action2._duration;
917
+
918
+ if (this.initWithDuration(Math.max(d1, d2))) {
919
+ this._one = action1;
920
+ this._two = action2;
921
+
922
+ if (d1 > d2) {
923
+ this._two = cc.Sequence._actionOneTwo(action2, cc.delayTime(d1 - d2));
924
+ } else if (d1 < d2) {
925
+ this._one = cc.Sequence._actionOneTwo(action1, cc.delayTime(d2 - d1));
926
+ }
927
+
928
+ ret = true;
929
+ }
930
+ return ret;
931
+ },
932
+
933
+ /**
934
+ * returns a new clone of the action
935
+ * @returns {cc.Spawn}
936
+ */
937
+ clone:function () {
938
+ var action = new cc.Spawn();
939
+ this._cloneDecoration(action);
940
+ action.initWithTwoActions(this._one.clone(), this._two.clone());
941
+ return action;
942
+ },
943
+
944
+ /**
945
+ * Start the action with target.
946
+ * @param {cc.Node} target
947
+ */
948
+ startWithTarget:function (target) {
949
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
950
+ this._one.startWithTarget(target);
951
+ this._two.startWithTarget(target);
952
+ },
953
+
954
+ /**
955
+ * Stop the action
956
+ */
957
+ stop:function () {
958
+ this._one.stop();
959
+ this._two.stop();
960
+ cc.Action.prototype.stop.call(this);
961
+ },
962
+
963
+ /**
964
+ * Called once per frame. Time is the number of seconds of a frame interval.
965
+ * @param {Number} dt
966
+ */
967
+ update:function (dt) {
968
+ dt = this._computeEaseTime(dt);
969
+ if (this._one)
970
+ this._one.update(dt);
971
+ if (this._two)
972
+ this._two.update(dt);
973
+ },
974
+
975
+ /**
976
+ * Returns a reversed action.
977
+ * @return {cc.Spawn}
978
+ */
979
+ reverse:function () {
980
+ var action = cc.Spawn._actionOneTwo(this._one.reverse(), this._two.reverse());
981
+ this._cloneDecoration(action);
982
+ this._reverseEaseList(action);
983
+ return action;
984
+ }
985
+ });
986
+
987
+ /**
988
+ * Create a spawn action which runs several actions in parallel.
989
+ * @function
990
+ * @param {Array|cc.FiniteTimeAction}tempArray
991
+ * @return {cc.FiniteTimeAction}
992
+ * @example
993
+ * // example
994
+ * var action = cc.spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720));
995
+ * todo:It should be the direct use new
996
+ */
997
+ cc.spawn = function (/*Multiple Arguments*/tempArray) {
998
+ var paramArray = (tempArray instanceof Array) ? tempArray : arguments;
999
+ if ((paramArray.length > 0) && (paramArray[paramArray.length - 1] == null))
1000
+ cc.log("parameters should not be ending with null in Javascript");
1001
+
1002
+ var prev = paramArray[0];
1003
+ for (var i = 1; i < paramArray.length; i++) {
1004
+ if (paramArray[i] != null)
1005
+ prev = cc.Spawn._actionOneTwo(prev, paramArray[i]);
1006
+ }
1007
+ return prev;
1008
+ };
1009
+
1010
+ /**
1011
+ * Please use cc.spawn instead.
1012
+ * Create a spawn action which runs several actions in parallel.
1013
+ * @static
1014
+ * @deprecated since v3.0 <br /> Please use cc.spawn instead.
1015
+ * @param {Array|cc.FiniteTimeAction}tempArray
1016
+ * @return {cc.FiniteTimeAction}
1017
+ */
1018
+ cc.Spawn.create = cc.spawn;
1019
+
1020
+ /**
1021
+ * @param {cc.FiniteTimeAction} action1
1022
+ * @param {cc.FiniteTimeAction} action2
1023
+ * @return {cc.Spawn}
1024
+ * @private
1025
+ */
1026
+ cc.Spawn._actionOneTwo = function (action1, action2) {
1027
+ var pSpawn = new cc.Spawn();
1028
+ pSpawn.initWithTwoActions(action1, action2);
1029
+ return pSpawn;
1030
+ };
1031
+
1032
+
1033
+ /**
1034
+ * Rotates a cc.Node object to a certain angle by modifying it's.
1035
+ * rotation attribute. <br/>
1036
+ * The direction will be decided by the shortest angle.
1037
+ * @class
1038
+ * @extends cc.ActionInterval
1039
+ * @param {Number} duration duration in seconds
1040
+ * @param {Number} deltaAngleX deltaAngleX in degrees.
1041
+ * @param {Number} [deltaAngleY] deltaAngleY in degrees.
1042
+ * @example
1043
+ * var rotateTo = new cc.RotateTo(2, 61.0);
1044
+ */
1045
+ cc.RotateTo = cc.ActionInterval.extend(/** @lends cc.RotateTo# */{
1046
+ _dstAngleX:0,
1047
+ _startAngleX:0,
1048
+ _diffAngleX:0,
1049
+
1050
+ _dstAngleY:0,
1051
+ _startAngleY:0,
1052
+ _diffAngleY:0,
1053
+
1054
+ /**
1055
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
1056
+ * Creates a RotateTo action with x and y rotation angles.
1057
+ * @param {Number} duration duration in seconds
1058
+ * @param {Number} deltaAngleX deltaAngleX in degrees.
1059
+ * @param {Number} [deltaAngleY] deltaAngleY in degrees.
1060
+ */
1061
+ ctor:function (duration, deltaAngleX, deltaAngleY) {
1062
+ cc.ActionInterval.prototype.ctor.call(this);
1063
+
1064
+ deltaAngleX !== undefined && this.initWithDuration(duration, deltaAngleX, deltaAngleY);
1065
+ },
1066
+
1067
+ /**
1068
+ * Initializes the action.
1069
+ * @param {Number} duration
1070
+ * @param {Number} deltaAngleX
1071
+ * @param {Number} deltaAngleY
1072
+ * @return {Boolean}
1073
+ */
1074
+ initWithDuration:function (duration, deltaAngleX, deltaAngleY) {
1075
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
1076
+ this._dstAngleX = deltaAngleX || 0;
1077
+ this._dstAngleY = deltaAngleY || this._dstAngleX;
1078
+ return true;
1079
+ }
1080
+ return false;
1081
+ },
1082
+
1083
+ /**
1084
+ * returns a new clone of the action
1085
+ * @returns {cc.RotateTo}
1086
+ */
1087
+ clone:function () {
1088
+ var action = new cc.RotateTo();
1089
+ this._cloneDecoration(action);
1090
+ action.initWithDuration(this._duration, this._dstAngleX, this._dstAngleY);
1091
+ return action;
1092
+ },
1093
+
1094
+ /**
1095
+ * Start the action with target.
1096
+ * @param {cc.Node} target
1097
+ */
1098
+ startWithTarget:function (target) {
1099
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
1100
+
1101
+ // Calculate X
1102
+ var locStartAngleX = target.rotationX % 360.0;
1103
+ var locDiffAngleX = this._dstAngleX - locStartAngleX;
1104
+ if (locDiffAngleX > 180)
1105
+ locDiffAngleX -= 360;
1106
+ if (locDiffAngleX < -180)
1107
+ locDiffAngleX += 360;
1108
+ this._startAngleX = locStartAngleX;
1109
+ this._diffAngleX = locDiffAngleX;
1110
+
1111
+ // Calculate Y It's duplicated from calculating X since the rotation wrap should be the same
1112
+ this._startAngleY = target.rotationY % 360.0;
1113
+ var locDiffAngleY = this._dstAngleY - this._startAngleY;
1114
+ if (locDiffAngleY > 180)
1115
+ locDiffAngleY -= 360;
1116
+ if (locDiffAngleY < -180)
1117
+ locDiffAngleY += 360;
1118
+ this._diffAngleY = locDiffAngleY;
1119
+ },
1120
+
1121
+ /**
1122
+ * RotateTo reverse not implemented.
1123
+ * Will be overridden.
1124
+ */
1125
+ reverse:function () {
1126
+ cc.log("cc.RotateTo.reverse(): it should be overridden in subclass.");
1127
+ },
1128
+
1129
+ /**
1130
+ * Called once per frame. Time is the number of seconds of a frame interval.
1131
+ * @param {Number} dt
1132
+ */
1133
+ update:function (dt) {
1134
+ dt = this._computeEaseTime(dt);
1135
+ if (this.target) {
1136
+ this.target.rotationX = this._startAngleX + this._diffAngleX * dt;
1137
+ this.target.rotationY = this._startAngleY + this._diffAngleY * dt;
1138
+ }
1139
+ }
1140
+ });
1141
+
1142
+ /**
1143
+ * Creates a RotateTo action with separate rotation angles.
1144
+ * To specify the angle of rotation.
1145
+ * @function
1146
+ * @param {Number} duration duration in seconds
1147
+ * @param {Number} deltaAngleX deltaAngleX in degrees.
1148
+ * @param {Number} [deltaAngleY] deltaAngleY in degrees.
1149
+ * @return {cc.RotateTo}
1150
+ * @example
1151
+ * // example
1152
+ * var rotateTo = cc.rotateTo(2, 61.0);
1153
+ */
1154
+ cc.rotateTo = function (duration, deltaAngleX, deltaAngleY) {
1155
+ return new cc.RotateTo(duration, deltaAngleX, deltaAngleY);
1156
+ };
1157
+
1158
+ /**
1159
+ * Please use cc.rotateTo instead
1160
+ * Creates a RotateTo action with separate rotation angles.
1161
+ * To specify the angle of rotation.
1162
+ * @static
1163
+ * @deprecated since v3.0 <br /> Please use cc.rotateTo instead.
1164
+ * @param {Number} duration duration in seconds
1165
+ * @param {Number} deltaAngleX deltaAngleX in degrees.
1166
+ * @param {Number} [deltaAngleY] deltaAngleY in degrees.
1167
+ * @return {cc.RotateTo}
1168
+ */
1169
+ cc.RotateTo.create = cc.rotateTo;
1170
+
1171
+
1172
+ /**
1173
+ * Rotates a cc.Node object clockwise a number of degrees by modifying it's rotation attribute.
1174
+ * Relative to its properties to modify.
1175
+ * @class
1176
+ * @extends cc.ActionInterval
1177
+ * @param {Number} duration duration in seconds
1178
+ * @param {Number} deltaAngleX deltaAngleX in degrees
1179
+ * @param {Number} [deltaAngleY] deltaAngleY in degrees
1180
+ * @example
1181
+ * var actionBy = new cc.RotateBy(2, 360);
1182
+ */
1183
+ cc.RotateBy = cc.ActionInterval.extend(/** @lends cc.RotateBy# */{
1184
+ _angleX:0,
1185
+ _startAngleX:0,
1186
+ _angleY:0,
1187
+ _startAngleY:0,
1188
+
1189
+ /**
1190
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
1191
+ * @param {Number} duration duration in seconds
1192
+ * @param {Number} deltaAngleX deltaAngleX in degrees
1193
+ * @param {Number} [deltaAngleY] deltaAngleY in degrees
1194
+ */
1195
+ ctor: function (duration, deltaAngleX, deltaAngleY) {
1196
+ cc.ActionInterval.prototype.ctor.call(this);
1197
+
1198
+ deltaAngleX !== undefined && this.initWithDuration(duration, deltaAngleX, deltaAngleY);
1199
+ },
1200
+
1201
+ /**
1202
+ * Initializes the action.
1203
+ * @param {Number} duration duration in seconds
1204
+ * @param {Number} deltaAngleX deltaAngleX in degrees
1205
+ * @param {Number} [deltaAngleY=] deltaAngleY in degrees
1206
+ * @return {Boolean}
1207
+ */
1208
+ initWithDuration:function (duration, deltaAngleX, deltaAngleY) {
1209
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
1210
+ this._angleX = deltaAngleX || 0;
1211
+ this._angleY = deltaAngleY || this._angleX;
1212
+ return true;
1213
+ }
1214
+ return false;
1215
+ },
1216
+
1217
+ /**
1218
+ * returns a new clone of the action
1219
+ * @returns {cc.RotateBy}
1220
+ */
1221
+ clone:function () {
1222
+ var action = new cc.RotateBy();
1223
+ this._cloneDecoration(action);
1224
+ action.initWithDuration(this._duration, this._angleX, this._angleY);
1225
+ return action;
1226
+ },
1227
+
1228
+ /**
1229
+ * Start the action with target.
1230
+ * @param {cc.Node} target
1231
+ */
1232
+ startWithTarget:function (target) {
1233
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
1234
+ this._startAngleX = target.rotationX;
1235
+ this._startAngleY = target.rotationY;
1236
+ },
1237
+
1238
+ /**
1239
+ * Called once per frame. Time is the number of seconds of a frame interval.
1240
+ * @param {Number} dt
1241
+ */
1242
+ update:function (dt) {
1243
+ dt = this._computeEaseTime(dt);
1244
+ if (this.target) {
1245
+ this.target.rotationX = this._startAngleX + this._angleX * dt;
1246
+ this.target.rotationY = this._startAngleY + this._angleY * dt;
1247
+ }
1248
+ },
1249
+
1250
+ /**
1251
+ * Returns a reversed action.
1252
+ * @return {cc.RotateBy}
1253
+ */
1254
+ reverse:function () {
1255
+ var action = new cc.RotateBy(this._duration, -this._angleX, -this._angleY);
1256
+ this._cloneDecoration(action);
1257
+ this._reverseEaseList(action);
1258
+ return action;
1259
+ }
1260
+ });
1261
+
1262
+ /**
1263
+ * Rotates a cc.Node object clockwise a number of degrees by modifying it's rotation attribute.
1264
+ * Relative to its properties to modify.
1265
+ * @function
1266
+ * @param {Number} duration duration in seconds
1267
+ * @param {Number} deltaAngleX deltaAngleX in degrees
1268
+ * @param {Number} [deltaAngleY] deltaAngleY in degrees
1269
+ * @return {cc.RotateBy}
1270
+ * @example
1271
+ * // example
1272
+ * var actionBy = cc.rotateBy(2, 360);
1273
+ */
1274
+ cc.rotateBy = function (duration, deltaAngleX, deltaAngleY) {
1275
+ return new cc.RotateBy(duration, deltaAngleX, deltaAngleY);
1276
+ };
1277
+ /**
1278
+ * Please use cc.rotateBy instead.
1279
+ * Rotates a cc.Node object clockwise a number of degrees by modifying it's rotation attribute.
1280
+ * Relative to its properties to modify.
1281
+ * @static
1282
+ * @deprecated since v3.0 <br /> Please use cc.rotateBy instead.
1283
+ * @param {Number} duration duration in seconds
1284
+ * @param {Number} deltaAngleX deltaAngleX in degrees
1285
+ * @param {Number} [deltaAngleY] deltaAngleY in degrees
1286
+ * @return {cc.RotateBy}
1287
+ */
1288
+ cc.RotateBy.create = cc.rotateBy;
1289
+
1290
+
1291
+ /**
1292
+ * <p>
1293
+ * Moves a CCNode object x,y pixels by modifying it's position attribute. <br/>
1294
+ * x and y are relative to the position of the object. <br/>
1295
+ * Several CCMoveBy actions can be concurrently called, and the resulting <br/>
1296
+ * movement will be the sum of individual movements.
1297
+ * </p>
1298
+ * @class
1299
+ * @extends cc.ActionInterval
1300
+ * @param {Number} duration duration in seconds
1301
+ * @param {cc.Point|Number} deltaPos
1302
+ * @param {Number} [deltaY]
1303
+ * @example
1304
+ * var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40));
1305
+ */
1306
+ cc.MoveBy = cc.ActionInterval.extend(/** @lends cc.MoveBy# */{
1307
+ _positionDelta:null,
1308
+ _startPosition:null,
1309
+ _previousPosition:null,
1310
+
1311
+ /**
1312
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
1313
+ * @param {Number} duration duration in seconds
1314
+ * @param {cc.Point|Number} deltaPos
1315
+ * @param {Number} [deltaY]
1316
+ */
1317
+ ctor:function (duration, deltaPos, deltaY) {
1318
+ cc.ActionInterval.prototype.ctor.call(this);
1319
+
1320
+ this._positionDelta = cc.p(0, 0);
1321
+ this._startPosition = cc.p(0, 0);
1322
+ this._previousPosition = cc.p(0, 0);
1323
+
1324
+ deltaPos !== undefined && this.initWithDuration(duration, deltaPos, deltaY);
1325
+ },
1326
+
1327
+ /**
1328
+ * Initializes the action.
1329
+ * @param {Number} duration duration in seconds
1330
+ * @param {cc.Point} position
1331
+ * @param {Number} [y]
1332
+ * @return {Boolean}
1333
+ */
1334
+ initWithDuration:function (duration, position, y) {
1335
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
1336
+ if(position.x !== undefined) {
1337
+ y = position.y;
1338
+ position = position.x;
1339
+ }
1340
+
1341
+ this._positionDelta.x = position;
1342
+ this._positionDelta.y = y;
1343
+ return true;
1344
+ }
1345
+ return false;
1346
+ },
1347
+
1348
+ /**
1349
+ * returns a new clone of the action
1350
+ * @returns {cc.MoveBy}
1351
+ */
1352
+ clone:function () {
1353
+ var action = new cc.MoveBy();
1354
+ this._cloneDecoration(action);
1355
+ action.initWithDuration(this._duration, this._positionDelta);
1356
+ return action;
1357
+ },
1358
+
1359
+ /**
1360
+ * Start the action with target.
1361
+ * @param {cc.Node} target
1362
+ */
1363
+ startWithTarget:function (target) {
1364
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
1365
+ var locPosX = target.getPositionX();
1366
+ var locPosY = target.getPositionY();
1367
+ this._previousPosition.x = locPosX;
1368
+ this._previousPosition.y = locPosY;
1369
+ this._startPosition.x = locPosX;
1370
+ this._startPosition.y = locPosY;
1371
+ },
1372
+
1373
+ /**
1374
+ * Called once per frame. Time is the number of seconds of a frame interval.
1375
+ * @param {Number} dt
1376
+ */
1377
+ update:function (dt) {
1378
+ dt = this._computeEaseTime(dt);
1379
+ if (this.target) {
1380
+ var x = this._positionDelta.x * dt;
1381
+ var y = this._positionDelta.y * dt;
1382
+ var locStartPosition = this._startPosition;
1383
+ if (cc.ENABLE_STACKABLE_ACTIONS) {
1384
+ var targetX = this.target.getPositionX();
1385
+ var targetY = this.target.getPositionY();
1386
+ var locPreviousPosition = this._previousPosition;
1387
+
1388
+ locStartPosition.x = locStartPosition.x + targetX - locPreviousPosition.x;
1389
+ locStartPosition.y = locStartPosition.y + targetY - locPreviousPosition.y;
1390
+ x = x + locStartPosition.x;
1391
+ y = y + locStartPosition.y;
1392
+ locPreviousPosition.x = x;
1393
+ locPreviousPosition.y = y;
1394
+ this.target.setPosition(x, y);
1395
+ } else {
1396
+ this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y);
1397
+ }
1398
+ }
1399
+ },
1400
+
1401
+ /**
1402
+ * MoveTo reverse is not implemented
1403
+ * @return {cc.MoveBy}
1404
+ */
1405
+ reverse:function () {
1406
+ var action = new cc.MoveBy(this._duration, cc.p(-this._positionDelta.x, -this._positionDelta.y));
1407
+ this._cloneDecoration(action);
1408
+ this._reverseEaseList(action);
1409
+ return action;
1410
+ }
1411
+ });
1412
+
1413
+ /**
1414
+ * Create the action.
1415
+ * Relative to its coordinate moves a certain distance.
1416
+ * @function
1417
+ * @param {Number} duration duration in seconds
1418
+ * @param {cc.Point|Number} deltaPos
1419
+ * @param {Number} deltaY
1420
+ * @return {cc.MoveBy}
1421
+ * @example
1422
+ * // example
1423
+ * var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40));
1424
+ */
1425
+ cc.moveBy = function (duration, deltaPos, deltaY) {
1426
+ return new cc.MoveBy(duration, deltaPos, deltaY);
1427
+ };
1428
+ /**
1429
+ * Please use cc.moveBy instead.
1430
+ * Relative to its coordinate moves a certain distance.
1431
+ * @static
1432
+ * @deprecated since v3.0 please use cc.moveBy instead.
1433
+ * @param {Number} duration duration in seconds
1434
+ * @param {cc.Point|Number} deltaPos
1435
+ * @param {Number} deltaY
1436
+ * @return {cc.MoveBy}
1437
+ */
1438
+ cc.MoveBy.create = cc.moveBy;
1439
+
1440
+
1441
+ /**
1442
+ * Moves a CCNode object to the position x,y. x and y are absolute coordinates by modifying it's position attribute. <br/>
1443
+ * Several CCMoveTo actions can be concurrently called, and the resulting <br/>
1444
+ * movement will be the sum of individual movements.
1445
+ * @class
1446
+ * @extends cc.MoveBy
1447
+ * @param {Number} duration duration in seconds
1448
+ * @param {cc.Point|Number} position
1449
+ * @param {Number} y
1450
+ * @example
1451
+ * var actionBy = new cc.MoveTo(2, cc.p(80, 80));
1452
+ */
1453
+ cc.MoveTo = cc.MoveBy.extend(/** @lends cc.MoveTo# */{
1454
+ _endPosition:null,
1455
+
1456
+ /**
1457
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
1458
+ * @param {Number} duration duration in seconds
1459
+ * @param {cc.Point|Number} position
1460
+ * @param {Number} y
1461
+ */
1462
+ ctor:function (duration, position, y) {
1463
+ cc.MoveBy.prototype.ctor.call(this);
1464
+ this._endPosition = cc.p(0, 0);
1465
+
1466
+ position !== undefined && this.initWithDuration(duration, position, y);
1467
+ },
1468
+
1469
+ /**
1470
+ * Initializes the action.
1471
+ * @param {Number} duration duration in seconds
1472
+ * @param {cc.Point} position
1473
+ * @param {Number} y
1474
+ * @return {Boolean}
1475
+ */
1476
+ initWithDuration:function (duration, position, y) {
1477
+ if (cc.MoveBy.prototype.initWithDuration.call(this, duration, position, y)) {
1478
+ if(position.x !== undefined) {
1479
+ y = position.y;
1480
+ position = position.x;
1481
+ }
1482
+
1483
+ this._endPosition.x = position;
1484
+ this._endPosition.y = y;
1485
+ return true;
1486
+ }
1487
+ return false;
1488
+ },
1489
+
1490
+ /**
1491
+ * returns a new clone of the action
1492
+ * @returns {cc.MoveTo}
1493
+ */
1494
+ clone:function () {
1495
+ var action = new cc.MoveTo();
1496
+ this._cloneDecoration(action);
1497
+ action.initWithDuration(this._duration, this._endPosition);
1498
+ return action;
1499
+ },
1500
+
1501
+ /**
1502
+ * Start the action with target.
1503
+ * @param {cc.Node} target
1504
+ */
1505
+ startWithTarget:function (target) {
1506
+ cc.MoveBy.prototype.startWithTarget.call(this, target);
1507
+ this._positionDelta.x = this._endPosition.x - target.getPositionX();
1508
+ this._positionDelta.y = this._endPosition.y - target.getPositionY();
1509
+ }
1510
+ });
1511
+
1512
+ /**
1513
+ * Create new action.
1514
+ * Moving to the specified coordinates.
1515
+ * @function
1516
+ * @param {Number} duration duration in seconds
1517
+ * @param {cc.Point} position
1518
+ * @param {Number} y
1519
+ * @return {cc.MoveBy}
1520
+ * @example
1521
+ * // example
1522
+ * var actionBy = cc.moveTo(2, cc.p(80, 80));
1523
+ */
1524
+ cc.moveTo = function (duration, position, y) {
1525
+ return new cc.MoveTo(duration, position, y);
1526
+ };
1527
+ /**
1528
+ * Please use cc.moveTo instead.
1529
+ * Moving to the specified coordinates.
1530
+ * @static
1531
+ * @deprecated since v3.0 <br /> Please use cc.moveTo instead.
1532
+ * @param {Number} duration duration in seconds
1533
+ * @param {cc.Point} position
1534
+ * @param {Number} y
1535
+ * @return {cc.MoveBy}
1536
+ */
1537
+ cc.MoveTo.create = cc.moveTo;
1538
+
1539
+ /**
1540
+ * Skews a cc.Node object to given angles by modifying it's skewX and skewY attributes
1541
+ * @class
1542
+ * @extends cc.ActionInterval
1543
+ * @param {Number} t time in seconds
1544
+ * @param {Number} sx
1545
+ * @param {Number} sy
1546
+ * @example
1547
+ * var actionTo = new cc.SkewTo(2, 37.2, -37.2);
1548
+ */
1549
+ cc.SkewTo = cc.ActionInterval.extend(/** @lends cc.SkewTo# */{
1550
+ _skewX:0,
1551
+ _skewY:0,
1552
+ _startSkewX:0,
1553
+ _startSkewY:0,
1554
+ _endSkewX:0,
1555
+ _endSkewY:0,
1556
+ _deltaX:0,
1557
+ _deltaY:0,
1558
+
1559
+ /**
1560
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
1561
+ * @param {Number} t time in seconds
1562
+ * @param {Number} sx
1563
+ * @param {Number} sy
1564
+ */
1565
+ ctor: function (t, sx, sy) {
1566
+ cc.ActionInterval.prototype.ctor.call(this);
1567
+
1568
+ sy !== undefined && this.initWithDuration(t, sx, sy);
1569
+ },
1570
+
1571
+ /**
1572
+ * Initializes the action.
1573
+ * @param {Number} t time in seconds
1574
+ * @param {Number} sx
1575
+ * @param {Number} sy
1576
+ * @return {Boolean}
1577
+ */
1578
+ initWithDuration:function (t, sx, sy) {
1579
+ var ret = false;
1580
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
1581
+ this._endSkewX = sx;
1582
+ this._endSkewY = sy;
1583
+ ret = true;
1584
+ }
1585
+ return ret;
1586
+ },
1587
+
1588
+ /**
1589
+ * returns a new clone of the action
1590
+ * @returns {cc.SkewTo}
1591
+ */
1592
+ clone:function () {
1593
+ var action = new cc.SkewTo();
1594
+ this._cloneDecoration(action);
1595
+ action.initWithDuration(this._duration, this._endSkewX, this._endSkewY);
1596
+ return action;
1597
+ },
1598
+
1599
+ /**
1600
+ * Start the action with target.
1601
+ * @param {cc.Node} target
1602
+ */
1603
+ startWithTarget:function (target) {
1604
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
1605
+
1606
+ this._startSkewX = target.skewX % 180;
1607
+ this._deltaX = this._endSkewX - this._startSkewX;
1608
+ if (this._deltaX > 180)
1609
+ this._deltaX -= 360;
1610
+ if (this._deltaX < -180)
1611
+ this._deltaX += 360;
1612
+
1613
+ this._startSkewY = target.skewY % 360;
1614
+ this._deltaY = this._endSkewY - this._startSkewY;
1615
+ if (this._deltaY > 180)
1616
+ this._deltaY -= 360;
1617
+ if (this._deltaY < -180)
1618
+ this._deltaY += 360;
1619
+ },
1620
+
1621
+ /**
1622
+ * Called once per frame. Time is the number of seconds of a frame interval.
1623
+ * @param {Number} dt
1624
+ */
1625
+ update:function (dt) {
1626
+ dt = this._computeEaseTime(dt);
1627
+ this.target.skewX = this._startSkewX + this._deltaX * dt;
1628
+ this.target.skewY = this._startSkewY + this._deltaY * dt;
1629
+ }
1630
+ });
1631
+ /**
1632
+ * Create new action.
1633
+ * Skews a cc.Node object to given angles by modifying it's skewX and skewY attributes.
1634
+ * Changes to the specified value.
1635
+ * @function
1636
+ * @param {Number} t time in seconds
1637
+ * @param {Number} sx
1638
+ * @param {Number} sy
1639
+ * @return {cc.SkewTo}
1640
+ * @example
1641
+ * // example
1642
+ * var actionTo = cc.skewTo(2, 37.2, -37.2);
1643
+ */
1644
+ cc.skewTo = function (t, sx, sy) {
1645
+ return new cc.SkewTo(t, sx, sy);
1646
+ };
1647
+ /**
1648
+ * Please use cc.skewTo instead.
1649
+ * Skews a cc.Node object to given angles by modifying it's skewX and skewY attributes。
1650
+ * Changes to the specified value.
1651
+ * @static
1652
+ * @deprecated since v3.0 <br /> Please use cc.skewTo instead.
1653
+ * @param {Number} t time in seconds
1654
+ * @param {Number} sx
1655
+ * @param {Number} sy
1656
+ * @return {cc.SkewTo}
1657
+ */
1658
+ cc.SkewTo.create = cc.skewTo;
1659
+
1660
+ /**
1661
+ * Skews a cc.Node object by skewX and skewY degrees.
1662
+ * Relative to its attribute modification.
1663
+ * @class
1664
+ * @extends cc.SkewTo
1665
+ * @param {Number} t time in seconds
1666
+ * @param {Number} sx skew in degrees for X axis
1667
+ * @param {Number} sy skew in degrees for Y axis
1668
+ */
1669
+ cc.SkewBy = cc.SkewTo.extend(/** @lends cc.SkewBy# */{
1670
+
1671
+ /**
1672
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
1673
+ * @param {Number} t time in seconds
1674
+ * @param {Number} sx skew in degrees for X axis
1675
+ * @param {Number} sy skew in degrees for Y axis
1676
+ */
1677
+ ctor: function(t, sx, sy) {
1678
+ cc.SkewTo.prototype.ctor.call(this);
1679
+ sy !== undefined && this.initWithDuration(t, sx, sy);
1680
+ },
1681
+
1682
+ /**
1683
+ * Initializes the action.
1684
+ * @param {Number} t time in seconds
1685
+ * @param {Number} deltaSkewX skew in degrees for X axis
1686
+ * @param {Number} deltaSkewY skew in degrees for Y axis
1687
+ * @return {Boolean}
1688
+ */
1689
+ initWithDuration:function (t, deltaSkewX, deltaSkewY) {
1690
+ var ret = false;
1691
+ if (cc.SkewTo.prototype.initWithDuration.call(this, t, deltaSkewX, deltaSkewY)) {
1692
+ this._skewX = deltaSkewX;
1693
+ this._skewY = deltaSkewY;
1694
+ ret = true;
1695
+ }
1696
+ return ret;
1697
+ },
1698
+
1699
+ /**
1700
+ * returns a new clone of the action
1701
+ * @returns {cc.SkewBy}
1702
+ */
1703
+ clone:function () {
1704
+ var action = new cc.SkewBy();
1705
+ this._cloneDecoration(action);
1706
+ action.initWithDuration(this._duration, this._skewX, this._skewY);
1707
+ return action;
1708
+ },
1709
+
1710
+ /**
1711
+ * Start the action width target.
1712
+ * @param {cc.Node} target
1713
+ */
1714
+ startWithTarget:function (target) {
1715
+ cc.SkewTo.prototype.startWithTarget.call(this, target);
1716
+ this._deltaX = this._skewX;
1717
+ this._deltaY = this._skewY;
1718
+ this._endSkewX = this._startSkewX + this._deltaX;
1719
+ this._endSkewY = this._startSkewY + this._deltaY;
1720
+ },
1721
+
1722
+ /**
1723
+ * Returns a reversed action.
1724
+ * @return {cc.SkewBy}
1725
+ */
1726
+ reverse:function () {
1727
+ var action = new cc.SkewBy(this._duration, -this._skewX, -this._skewY);
1728
+ this._cloneDecoration(action);
1729
+ this._reverseEaseList(action);
1730
+ return action;
1731
+ }
1732
+ });
1733
+
1734
+ /**
1735
+ * Skews a cc.Node object by skewX and skewY degrees. <br />
1736
+ * Relative to its attribute modification.
1737
+ * @function
1738
+ * @param {Number} t time in seconds
1739
+ * @param {Number} sx sx skew in degrees for X axis
1740
+ * @param {Number} sy sy skew in degrees for Y axis
1741
+ * @return {cc.SkewBy}
1742
+ * @example
1743
+ * // example
1744
+ * var actionBy = cc.skewBy(2, 0, -90);
1745
+ */
1746
+ cc.skewBy = function (t, sx, sy) {
1747
+ return new cc.SkewBy(t, sx, sy);
1748
+ };
1749
+ /**
1750
+ * Please use cc.skewBy instead. <br />
1751
+ * Skews a cc.Node object by skewX and skewY degrees. <br />
1752
+ * Relative to its attribute modification.
1753
+ * @static
1754
+ * @deprecated since v3.0 please use cc.skewBy instead.
1755
+ * @param {Number} t time in seconds
1756
+ * @param {Number} sx sx skew in degrees for X axis
1757
+ * @param {Number} sy sy skew in degrees for Y axis
1758
+ * @return {cc.SkewBy}
1759
+ */
1760
+ cc.SkewBy.create = cc.skewBy;
1761
+
1762
+
1763
+ /**
1764
+ * Moves a cc.Node object simulating a parabolic jump movement by modifying it's position attribute.
1765
+ * Relative to its movement.
1766
+ * @class
1767
+ * @extends cc.ActionInterval
1768
+ * @param {Number} duration
1769
+ * @param {cc.Point|Number} position
1770
+ * @param {Number} [y]
1771
+ * @param {Number} height
1772
+ * @param {Number} jumps
1773
+ * @example
1774
+ * var actionBy = new cc.JumpBy(2, cc.p(300, 0), 50, 4);
1775
+ * var actionBy = new cc.JumpBy(2, 300, 0, 50, 4);
1776
+ */
1777
+ cc.JumpBy = cc.ActionInterval.extend(/** @lends cc.JumpBy# */{
1778
+ _startPosition:null,
1779
+ _delta:null,
1780
+ _height:0,
1781
+ _jumps:0,
1782
+ _previousPosition:null,
1783
+
1784
+ /**
1785
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
1786
+ * @param {Number} duration
1787
+ * @param {cc.Point|Number} position
1788
+ * @param {Number} [y]
1789
+ * @param {Number} height
1790
+ * @param {Number} jumps
1791
+ */
1792
+ ctor:function (duration, position, y, height, jumps) {
1793
+ cc.ActionInterval.prototype.ctor.call(this);
1794
+ this._startPosition = cc.p(0, 0);
1795
+ this._previousPosition = cc.p(0, 0);
1796
+ this._delta = cc.p(0, 0);
1797
+
1798
+ height !== undefined && this.initWithDuration(duration, position, y, height, jumps);
1799
+ },
1800
+ /**
1801
+ * Initializes the action.
1802
+ * @param {Number} duration
1803
+ * @param {cc.Point|Number} position
1804
+ * @param {Number} [y]
1805
+ * @param {Number} height
1806
+ * @param {Number} jumps
1807
+ * @return {Boolean}
1808
+ * @example
1809
+ * actionBy.initWithDuration(2, cc.p(300, 0), 50, 4);
1810
+ * actionBy.initWithDuration(2, 300, 0, 50, 4);
1811
+ */
1812
+ initWithDuration:function (duration, position, y, height, jumps) {
1813
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
1814
+ if (jumps === undefined) {
1815
+ jumps = height;
1816
+ height = y;
1817
+ y = position.y;
1818
+ position = position.x;
1819
+ }
1820
+ this._delta.x = position;
1821
+ this._delta.y = y;
1822
+ this._height = height;
1823
+ this._jumps = jumps;
1824
+ return true;
1825
+ }
1826
+ return false;
1827
+ },
1828
+
1829
+ /**
1830
+ * returns a new clone of the action
1831
+ * @returns {cc.JumpBy}
1832
+ */
1833
+ clone:function () {
1834
+ var action = new cc.JumpBy();
1835
+ this._cloneDecoration(action);
1836
+ action.initWithDuration(this._duration, this._delta, this._height, this._jumps);
1837
+ return action;
1838
+ },
1839
+
1840
+ /**
1841
+ * Start the action with target.
1842
+ * @param {cc.Node} target
1843
+ */
1844
+ startWithTarget:function (target) {
1845
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
1846
+ var locPosX = target.getPositionX();
1847
+ var locPosY = target.getPositionY();
1848
+ this._previousPosition.x = locPosX;
1849
+ this._previousPosition.y = locPosY;
1850
+ this._startPosition.x = locPosX;
1851
+ this._startPosition.y = locPosY;
1852
+ },
1853
+
1854
+ /**
1855
+ * Called once per frame. Time is the number of seconds of a frame interval.
1856
+ * @param {Number} dt
1857
+ */
1858
+ update:function (dt) {
1859
+ dt = this._computeEaseTime(dt);
1860
+ if (this.target) {
1861
+ var frac = dt * this._jumps % 1.0;
1862
+ var y = this._height * 4 * frac * (1 - frac);
1863
+ y += this._delta.y * dt;
1864
+
1865
+ var x = this._delta.x * dt;
1866
+ var locStartPosition = this._startPosition;
1867
+ if (cc.ENABLE_STACKABLE_ACTIONS) {
1868
+ var targetX = this.target.getPositionX();
1869
+ var targetY = this.target.getPositionY();
1870
+ var locPreviousPosition = this._previousPosition;
1871
+
1872
+ locStartPosition.x = locStartPosition.x + targetX - locPreviousPosition.x;
1873
+ locStartPosition.y = locStartPosition.y + targetY - locPreviousPosition.y;
1874
+ x = x + locStartPosition.x;
1875
+ y = y + locStartPosition.y;
1876
+ locPreviousPosition.x = x;
1877
+ locPreviousPosition.y = y;
1878
+ this.target.setPosition(x, y);
1879
+ } else {
1880
+ this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y);
1881
+ }
1882
+ }
1883
+ },
1884
+
1885
+ /**
1886
+ * Returns a reversed action.
1887
+ * @return {cc.JumpBy}
1888
+ */
1889
+ reverse:function () {
1890
+ var action = new cc.JumpBy(this._duration, cc.p(-this._delta.x, -this._delta.y), this._height, this._jumps);
1891
+ this._cloneDecoration(action);
1892
+ this._reverseEaseList(action);
1893
+ return action;
1894
+ }
1895
+ });
1896
+
1897
+ /**
1898
+ * Moves a cc.Node object simulating a parabolic jump movement by modifying it's position attribute.
1899
+ * Relative to its movement.
1900
+ * @function
1901
+ * @param {Number} duration
1902
+ * @param {cc.Point|Number} position
1903
+ * @param {Number} [y]
1904
+ * @param {Number} height
1905
+ * @param {Number} jumps
1906
+ * @return {cc.JumpBy}
1907
+ * @example
1908
+ * // example
1909
+ * var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4);
1910
+ * var actionBy = cc.jumpBy(2, 300, 0, 50, 4);
1911
+ */
1912
+ cc.jumpBy = function (duration, position, y, height, jumps) {
1913
+ return new cc.JumpBy(duration, position, y, height, jumps);
1914
+ };
1915
+ /**
1916
+ * Please use cc.jumpBy instead. <br />
1917
+ * Moves a cc.Node object simulating a parabolic jump movement by modifying it's position attribute. <br />
1918
+ * Relative to its movement.
1919
+ * @static
1920
+ * @deprecated since v3.0 please use cc.jumpBy instead.
1921
+ * @param {Number} duration
1922
+ * @param {cc.Point|Number} position
1923
+ * @param {Number} [y]
1924
+ * @param {Number} height
1925
+ * @param {Number} jumps
1926
+ * @return {cc.JumpBy}
1927
+ */
1928
+ cc.JumpBy.create = cc.jumpBy;
1929
+
1930
+ /**
1931
+ * Moves a cc.Node object to a parabolic position simulating a jump movement by modifying it's position attribute. <br />
1932
+ * Jump to the specified location.
1933
+ * @class
1934
+ * @extends cc.JumpBy
1935
+ * @param {Number} duration
1936
+ * @param {cc.Point|Number} position
1937
+ * @param {Number} [y]
1938
+ * @param {Number} height
1939
+ * @param {Number} jumps
1940
+ * @example
1941
+ * var actionTo = new cc.JumpTo(2, cc.p(300, 0), 50, 4);
1942
+ * var actionTo = new cc.JumpTo(2, 300, 0, 50, 4);
1943
+ */
1944
+ cc.JumpTo = cc.JumpBy.extend(/** @lends cc.JumpTo# */{
1945
+ _endPosition:null,
1946
+
1947
+ /**
1948
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
1949
+ * @param {Number} duration
1950
+ * @param {cc.Point|Number} position
1951
+ * @param {Number} [y]
1952
+ * @param {Number} height
1953
+ * @param {Number} jumps
1954
+ */
1955
+ ctor:function (duration, position, y, height, jumps) {
1956
+ cc.JumpBy.prototype.ctor.call(this);
1957
+ this._endPosition = cc.p(0, 0);
1958
+
1959
+ height !== undefined && this.initWithDuration(duration, position, y, height, jumps);
1960
+ },
1961
+ /**
1962
+ * Initializes the action.
1963
+ * @param {Number} duration
1964
+ * @param {cc.Point|Number} position
1965
+ * @param {Number} [y]
1966
+ * @param {Number} height
1967
+ * @param {Number} jumps
1968
+ * @return {Boolean}
1969
+ * @example
1970
+ * actionTo.initWithDuration(2, cc.p(300, 0), 50, 4);
1971
+ * actionTo.initWithDuration(2, 300, 0, 50, 4);
1972
+ */
1973
+ initWithDuration:function (duration, position, y, height, jumps) {
1974
+ if (cc.JumpBy.prototype.initWithDuration.call(this, duration, position, y, height, jumps)) {
1975
+ if (jumps === undefined) {
1976
+ y = position.y;
1977
+ position = position.x;
1978
+ }
1979
+ this._endPosition.x = position;
1980
+ this._endPosition.y = y;
1981
+ return true;
1982
+ }
1983
+ return false;
1984
+ },
1985
+ /**
1986
+ * Start the action with target.
1987
+ * @param {cc.Node} target
1988
+ */
1989
+ startWithTarget:function (target) {
1990
+ cc.JumpBy.prototype.startWithTarget.call(this, target);
1991
+ this._delta.x = this._endPosition.x - this._startPosition.x;
1992
+ this._delta.y = this._endPosition.y - this._startPosition.y;
1993
+ },
1994
+
1995
+ /**
1996
+ * returns a new clone of the action
1997
+ * @returns {cc.JumpTo}
1998
+ */
1999
+ clone:function () {
2000
+ var action = new cc.JumpTo();
2001
+ this._cloneDecoration(action);
2002
+ action.initWithDuration(this._duration, this._endPosition, this._height, this._jumps);
2003
+ return action;
2004
+ }
2005
+ });
2006
+
2007
+ /**
2008
+ * Moves a cc.Node object to a parabolic position simulating a jump movement by modifying it's position attribute. <br />
2009
+ * Jump to the specified location.
2010
+ * @function
2011
+ * @param {Number} duration
2012
+ * @param {cc.Point|Number} position
2013
+ * @param {Number} [y]
2014
+ * @param {Number} height
2015
+ * @param {Number} jumps
2016
+ * @return {cc.JumpTo}
2017
+ * @example
2018
+ * // example
2019
+ * var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4);
2020
+ * var actionTo = cc.jumpTo(2, 300, 300, 50, 4);
2021
+ */
2022
+ cc.jumpTo = function (duration, position, y, height, jumps) {
2023
+ return new cc.JumpTo(duration, position, y, height, jumps);
2024
+ };
2025
+ /**
2026
+ * Please use cc.jumpTo instead.
2027
+ * Moves a cc.Node object to a parabolic position simulating a jump movement by modifying it's position attribute. <br />
2028
+ * Jump to the specified location.
2029
+ * @static
2030
+ * @deprecated since v3.0 please use cc.jumpTo instead.
2031
+ * @param {Number} duration
2032
+ * @param {cc.Point|Number} position
2033
+ * @param {Number} [y]
2034
+ * @param {Number} height
2035
+ * @param {Number} jumps
2036
+ * @return {cc.JumpTo}
2037
+ */
2038
+ cc.JumpTo.create = cc.jumpTo;
2039
+
2040
+ /**
2041
+ * @function
2042
+ * @param {Number} a
2043
+ * @param {Number} b
2044
+ * @param {Number} c
2045
+ * @param {Number} d
2046
+ * @param {Number} t
2047
+ * @return {Number}
2048
+ */
2049
+ cc.bezierAt = function (a, b, c, d, t) {
2050
+ return (Math.pow(1 - t, 3) * a +
2051
+ 3 * t * (Math.pow(1 - t, 2)) * b +
2052
+ 3 * Math.pow(t, 2) * (1 - t) * c +
2053
+ Math.pow(t, 3) * d );
2054
+ };
2055
+
2056
+ /** An action that moves the target with a cubic Bezier curve by a certain distance.
2057
+ * Relative to its movement.
2058
+ * @class
2059
+ * @extends cc.ActionInterval
2060
+ * @param {Number} t time in seconds
2061
+ * @param {Array} c Array of points
2062
+ * @example
2063
+ * var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
2064
+ * var bezierForward = new cc.BezierBy(3, bezier);
2065
+ */
2066
+ cc.BezierBy = cc.ActionInterval.extend(/** @lends cc.BezierBy# */{
2067
+ _config:null,
2068
+ _startPosition:null,
2069
+ _previousPosition:null,
2070
+
2071
+ /**
2072
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
2073
+ * @param {Number} t time in seconds
2074
+ * @param {Array} c Array of points
2075
+ */
2076
+ ctor:function (t, c) {
2077
+ cc.ActionInterval.prototype.ctor.call(this);
2078
+ this._config = [];
2079
+ this._startPosition = cc.p(0, 0);
2080
+ this._previousPosition = cc.p(0, 0);
2081
+
2082
+ c && this.initWithDuration(t, c);
2083
+ },
2084
+
2085
+ /**
2086
+ * Initializes the action.
2087
+ * @param {Number} t time in seconds
2088
+ * @param {Array} c Array of points
2089
+ * @return {Boolean}
2090
+ */
2091
+ initWithDuration:function (t, c) {
2092
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
2093
+ this._config = c;
2094
+ return true;
2095
+ }
2096
+ return false;
2097
+ },
2098
+
2099
+ /**
2100
+ * returns a new clone of the action
2101
+ * @returns {cc.BezierBy}
2102
+ */
2103
+ clone:function () {
2104
+ var action = new cc.BezierBy();
2105
+ this._cloneDecoration(action);
2106
+ var newConfigs = [];
2107
+ for (var i = 0; i < this._config.length; i++) {
2108
+ var selConf = this._config[i];
2109
+ newConfigs.push(cc.p(selConf.x, selConf.y));
2110
+ }
2111
+ action.initWithDuration(this._duration, newConfigs);
2112
+ return action;
2113
+ },
2114
+
2115
+ /**
2116
+ * Start the action with target.
2117
+ * @param {cc.Node} target
2118
+ */
2119
+ startWithTarget:function (target) {
2120
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
2121
+ var locPosX = target.getPositionX();
2122
+ var locPosY = target.getPositionY();
2123
+ this._previousPosition.x = locPosX;
2124
+ this._previousPosition.y = locPosY;
2125
+ this._startPosition.x = locPosX;
2126
+ this._startPosition.y = locPosY;
2127
+ },
2128
+
2129
+ /**
2130
+ * Called once per frame. Time is the number of seconds of a frame interval.
2131
+ * @param {Number} dt
2132
+ */
2133
+ update:function (dt) {
2134
+ dt = this._computeEaseTime(dt);
2135
+ if (this.target) {
2136
+ var locConfig = this._config;
2137
+ var xa = 0;
2138
+ var xb = locConfig[0].x;
2139
+ var xc = locConfig[1].x;
2140
+ var xd = locConfig[2].x;
2141
+
2142
+ var ya = 0;
2143
+ var yb = locConfig[0].y;
2144
+ var yc = locConfig[1].y;
2145
+ var yd = locConfig[2].y;
2146
+
2147
+ var x = cc.bezierAt(xa, xb, xc, xd, dt);
2148
+ var y = cc.bezierAt(ya, yb, yc, yd, dt);
2149
+
2150
+ var locStartPosition = this._startPosition;
2151
+ if (cc.ENABLE_STACKABLE_ACTIONS) {
2152
+ var targetX = this.target.getPositionX();
2153
+ var targetY = this.target.getPositionY();
2154
+ var locPreviousPosition = this._previousPosition;
2155
+
2156
+ locStartPosition.x = locStartPosition.x + targetX - locPreviousPosition.x;
2157
+ locStartPosition.y = locStartPosition.y + targetY - locPreviousPosition.y;
2158
+ x = x + locStartPosition.x;
2159
+ y = y + locStartPosition.y;
2160
+ locPreviousPosition.x = x;
2161
+ locPreviousPosition.y = y;
2162
+ this.target.setPosition(x, y);
2163
+ } else {
2164
+ this.target.setPosition(locStartPosition.x + x, locStartPosition.y + y);
2165
+ }
2166
+ }
2167
+ },
2168
+
2169
+ /**
2170
+ * Returns a reversed action.
2171
+ * @return {cc.BezierBy}
2172
+ */
2173
+ reverse:function () {
2174
+ var locConfig = this._config;
2175
+ var r = [
2176
+ cc.pAdd(locConfig[1], cc.pNeg(locConfig[2])),
2177
+ cc.pAdd(locConfig[0], cc.pNeg(locConfig[2])),
2178
+ cc.pNeg(locConfig[2]) ];
2179
+ var action = new cc.BezierBy(this._duration, r);
2180
+ this._cloneDecoration(action);
2181
+ this._reverseEaseList(action);
2182
+ return action;
2183
+ }
2184
+ });
2185
+
2186
+ /**
2187
+ * An action that moves the target with a cubic Bezier curve by a certain distance.
2188
+ * Relative to its movement.
2189
+ * @function
2190
+ * @param {Number} t time in seconds
2191
+ * @param {Array} c Array of points
2192
+ * @return {cc.BezierBy}
2193
+ * @example
2194
+ * // example
2195
+ * var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
2196
+ * var bezierForward = cc.bezierBy(3, bezier);
2197
+ */
2198
+ cc.bezierBy = function (t, c) {
2199
+ return new cc.BezierBy(t, c);
2200
+ };
2201
+ /**
2202
+ * Please use cc.bezierBy instead.
2203
+ * An action that moves the target with a cubic Bezier curve by a certain distance.
2204
+ * Relative to its movement.
2205
+ * @static
2206
+ * @deprecated since v3.0 please use cc.bezierBy instead.
2207
+ * @param {Number} t time in seconds
2208
+ * @param {Array} c Array of points
2209
+ * @return {cc.BezierBy}
2210
+ */
2211
+ cc.BezierBy.create = cc.bezierBy;
2212
+
2213
+
2214
+ /** An action that moves the target with a cubic Bezier curve to a destination point.
2215
+ * @class
2216
+ * @extends cc.BezierBy
2217
+ * @param {Number} t
2218
+ * @param {Array} c array of points
2219
+ * @example
2220
+ * var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
2221
+ * var bezierTo = new cc.BezierTo(2, bezier);
2222
+ */
2223
+ cc.BezierTo = cc.BezierBy.extend(/** @lends cc.BezierTo# */{
2224
+ _toConfig:null,
2225
+
2226
+ /**
2227
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
2228
+ * @param {Number} t
2229
+ * @param {Array} c array of points
2230
+ * var bezierTo = new cc.BezierTo(2, bezier);
2231
+ */
2232
+ ctor:function (t, c) {
2233
+ cc.BezierBy.prototype.ctor.call(this);
2234
+ this._toConfig = [];
2235
+ c && this.initWithDuration(t, c);
2236
+ },
2237
+
2238
+ /**
2239
+ * Initializes the action.
2240
+ * @param {Number} t time in seconds
2241
+ * @param {Array} c Array of points
2242
+ * @return {Boolean}
2243
+ */
2244
+ initWithDuration:function (t, c) {
2245
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, t)) {
2246
+ this._toConfig = c;
2247
+ return true;
2248
+ }
2249
+ return false;
2250
+ },
2251
+
2252
+ /**
2253
+ * returns a new clone of the action
2254
+ * @returns {cc.BezierTo}
2255
+ */
2256
+ clone:function () {
2257
+ var action = new cc.BezierTo();
2258
+ this._cloneDecoration(action);
2259
+ action.initWithDuration(this._duration, this._toConfig);
2260
+ return action;
2261
+ },
2262
+
2263
+ /**
2264
+ * Start the action with target.
2265
+ * @param {cc.Node} target
2266
+ */
2267
+ startWithTarget:function (target) {
2268
+ cc.BezierBy.prototype.startWithTarget.call(this, target);
2269
+ var locStartPos = this._startPosition;
2270
+ var locToConfig = this._toConfig;
2271
+ var locConfig = this._config;
2272
+
2273
+ locConfig[0] = cc.pSub(locToConfig[0], locStartPos);
2274
+ locConfig[1] = cc.pSub(locToConfig[1], locStartPos);
2275
+ locConfig[2] = cc.pSub(locToConfig[2], locStartPos);
2276
+ }
2277
+ });
2278
+ /**
2279
+ * An action that moves the target with a cubic Bezier curve to a destination point.
2280
+ * @function
2281
+ * @param {Number} t
2282
+ * @param {Array} c array of points
2283
+ * @return {cc.BezierTo}
2284
+ * @example
2285
+ * // example
2286
+ * var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
2287
+ * var bezierTo = cc.bezierTo(2, bezier);
2288
+ */
2289
+ cc.bezierTo = function (t, c) {
2290
+ return new cc.BezierTo(t, c);
2291
+ };
2292
+ /**
2293
+ * Please use cc.bezierTo instead
2294
+ * @static
2295
+ * @deprecated since v3.0 please use cc.bezierTo instead.
2296
+ * @param {Number} t
2297
+ * @param {Array} c array of points
2298
+ * @return {cc.BezierTo}
2299
+ */
2300
+ cc.BezierTo.create = cc.bezierTo;
2301
+
2302
+
2303
+ /** Scales a cc.Node object to a zoom factor by modifying it's scale attribute.
2304
+ * @warning This action doesn't support "reverse"
2305
+ * @class
2306
+ * @extends cc.ActionInterval
2307
+ * @param {Number} duration
2308
+ * @param {Number} sx scale parameter in X
2309
+ * @param {Number} [sy] scale parameter in Y, if Null equal to sx
2310
+ * @example
2311
+ * // It scales to 0.5 in both X and Y.
2312
+ * var actionTo = new cc.ScaleTo(2, 0.5);
2313
+ *
2314
+ * // It scales to 0.5 in x and 2 in Y
2315
+ * var actionTo = new cc.ScaleTo(2, 0.5, 2);
2316
+ */
2317
+ cc.ScaleTo = cc.ActionInterval.extend(/** @lends cc.ScaleTo# */{
2318
+ _scaleX:1,
2319
+ _scaleY:1,
2320
+ _startScaleX:1,
2321
+ _startScaleY:1,
2322
+ _endScaleX:0,
2323
+ _endScaleY:0,
2324
+ _deltaX:0,
2325
+ _deltaY:0,
2326
+
2327
+ /**
2328
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
2329
+ * @param {Number} duration
2330
+ * @param {Number} sx scale parameter in X
2331
+ * @param {Number} [sy] scale parameter in Y, if Null equal to sx
2332
+ */
2333
+ ctor:function (duration, sx, sy) {
2334
+ cc.ActionInterval.prototype.ctor.call(this);
2335
+ sx !== undefined && this.initWithDuration(duration, sx, sy);
2336
+ },
2337
+
2338
+ /**
2339
+ * Initializes the action.
2340
+ * @param {Number} duration
2341
+ * @param {Number} sx
2342
+ * @param {Number} [sy=]
2343
+ * @return {Boolean}
2344
+ */
2345
+ initWithDuration:function (duration, sx, sy) { //function overload here
2346
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
2347
+ this._endScaleX = sx;
2348
+ this._endScaleY = (sy != null) ? sy : sx;
2349
+ return true;
2350
+ }
2351
+ return false;
2352
+ },
2353
+
2354
+ /**
2355
+ * returns a new clone of the action
2356
+ * @returns {cc.ScaleTo}
2357
+ */
2358
+ clone:function () {
2359
+ var action = new cc.ScaleTo();
2360
+ this._cloneDecoration(action);
2361
+ action.initWithDuration(this._duration, this._endScaleX, this._endScaleY);
2362
+ return action;
2363
+ },
2364
+
2365
+ /**
2366
+ * Start the action with target.
2367
+ * @param {cc.Node} target
2368
+ */
2369
+ startWithTarget:function (target) {
2370
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
2371
+ this._startScaleX = target.scaleX;
2372
+ this._startScaleY = target.scaleY;
2373
+ this._deltaX = this._endScaleX - this._startScaleX;
2374
+ this._deltaY = this._endScaleY - this._startScaleY;
2375
+ },
2376
+
2377
+ /**
2378
+ * Called once per frame. Time is the number of seconds of a frame interval.
2379
+ * @param {Number} dt
2380
+ */
2381
+ update:function (dt) {
2382
+ dt = this._computeEaseTime(dt);
2383
+ if (this.target) {
2384
+ this.target.scaleX = this._startScaleX + this._deltaX * dt;
2385
+ this.target.scaleY = this._startScaleY + this._deltaY * dt;
2386
+ }
2387
+ }
2388
+ });
2389
+ /**
2390
+ * Scales a cc.Node object to a zoom factor by modifying it's scale attribute.
2391
+ * @function
2392
+ * @param {Number} duration
2393
+ * @param {Number} sx scale parameter in X
2394
+ * @param {Number} [sy] scale parameter in Y, if Null equal to sx
2395
+ * @return {cc.ScaleTo}
2396
+ * @example
2397
+ * // example
2398
+ * // It scales to 0.5 in both X and Y.
2399
+ * var actionTo = cc.scaleTo(2, 0.5);
2400
+ *
2401
+ * // It scales to 0.5 in x and 2 in Y
2402
+ * var actionTo = cc.scaleTo(2, 0.5, 2);
2403
+ */
2404
+ cc.scaleTo = function (duration, sx, sy) { //function overload
2405
+ return new cc.ScaleTo(duration, sx, sy);
2406
+ };
2407
+ /**
2408
+ * Please use cc.scaleTo instead.
2409
+ * Scales a cc.Node object to a zoom factor by modifying it's scale attribute.
2410
+ * @static
2411
+ * @deprecated since v3.0 please use cc.scaleTo instead.
2412
+ * @param {Number} duration
2413
+ * @param {Number} sx scale parameter in X
2414
+ * @param {Number} [sy] scale parameter in Y, if Null equal to sx
2415
+ * @return {cc.ScaleTo}
2416
+ */
2417
+ cc.ScaleTo.create = cc.scaleTo;
2418
+
2419
+
2420
+ /** Scales a cc.Node object a zoom factor by modifying it's scale attribute.
2421
+ * Relative to its changes.
2422
+ * @class
2423
+ * @extends cc.ScaleTo
2424
+ */
2425
+ cc.ScaleBy = cc.ScaleTo.extend(/** @lends cc.ScaleBy# */{
2426
+ /**
2427
+ * Start the action with target.
2428
+ * @param {cc.Node} target
2429
+ */
2430
+ startWithTarget:function (target) {
2431
+ cc.ScaleTo.prototype.startWithTarget.call(this, target);
2432
+ this._deltaX = this._startScaleX * this._endScaleX - this._startScaleX;
2433
+ this._deltaY = this._startScaleY * this._endScaleY - this._startScaleY;
2434
+ },
2435
+
2436
+ /**
2437
+ * Returns a reversed action.
2438
+ * @return {cc.ScaleBy}
2439
+ */
2440
+ reverse:function () {
2441
+ var action = new cc.ScaleBy(this._duration, 1 / this._endScaleX, 1 / this._endScaleY);
2442
+ this._cloneDecoration(action);
2443
+ this._reverseEaseList(action);
2444
+ return action;
2445
+ },
2446
+
2447
+ /**
2448
+ * returns a new clone of the action
2449
+ * @returns {cc.ScaleBy}
2450
+ */
2451
+ clone:function () {
2452
+ var action = new cc.ScaleBy();
2453
+ this._cloneDecoration(action);
2454
+ action.initWithDuration(this._duration, this._endScaleX, this._endScaleY);
2455
+ return action;
2456
+ }
2457
+ });
2458
+ /**
2459
+ * Scales a cc.Node object a zoom factor by modifying it's scale attribute.
2460
+ * Relative to its changes.
2461
+ * @function
2462
+ * @param {Number} duration duration in seconds
2463
+ * @param {Number} sx sx scale parameter in X
2464
+ * @param {Number|Null} [sy=] sy scale parameter in Y, if Null equal to sx
2465
+ * @return {cc.ScaleBy}
2466
+ * @example
2467
+ * // example without sy, it scales by 2 both in X and Y
2468
+ * var actionBy = cc.scaleBy(2, 2);
2469
+ *
2470
+ * //example with sy, it scales by 0.25 in X and 4.5 in Y
2471
+ * var actionBy2 = cc.scaleBy(2, 0.25, 4.5);
2472
+ */
2473
+ cc.scaleBy = function (duration, sx, sy) {
2474
+ return new cc.ScaleBy(duration, sx, sy);
2475
+ };
2476
+ /**
2477
+ * Please use cc.scaleBy instead.
2478
+ * Scales a cc.Node object a zoom factor by modifying it's scale attribute.
2479
+ * Relative to its changes.
2480
+ * @static
2481
+ * @deprecated since v3.0 please use cc.scaleBy() instead.
2482
+ * @param {Number} duration duration in seconds
2483
+ * @param {Number} sx sx scale parameter in X
2484
+ * @param {Number|Null} [sy=] sy scale parameter in Y, if Null equal to sx
2485
+ * @return {cc.ScaleBy}
2486
+ */
2487
+ cc.ScaleBy.create = cc.scaleBy;
2488
+
2489
+ /** Blinks a cc.Node object by modifying it's visible attribute
2490
+ * @class
2491
+ * @extends cc.ActionInterval
2492
+ * @param {Number} duration duration in seconds
2493
+ * @param {Number} blinks blinks in times
2494
+ * @example
2495
+ * var action = new cc.Blink(2, 10);
2496
+ */
2497
+ cc.Blink = cc.ActionInterval.extend(/** @lends cc.Blink# */{
2498
+ _times:0,
2499
+ _originalState:false,
2500
+
2501
+ /**
2502
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
2503
+ * @param {Number} duration duration in seconds
2504
+ * @param {Number} blinks blinks in times
2505
+ */
2506
+ ctor:function (duration, blinks) {
2507
+ cc.ActionInterval.prototype.ctor.call(this);
2508
+ blinks !== undefined && this.initWithDuration(duration, blinks);
2509
+ },
2510
+
2511
+ /**
2512
+ * Initializes the action.
2513
+ * @param {Number} duration duration in seconds
2514
+ * @param {Number} blinks blinks in times
2515
+ * @return {Boolean}
2516
+ */
2517
+ initWithDuration:function (duration, blinks) {
2518
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
2519
+ this._times = blinks;
2520
+ return true;
2521
+ }
2522
+ return false;
2523
+ },
2524
+
2525
+ /**
2526
+ * returns a new clone of the action
2527
+ * @returns {cc.Blink}
2528
+ */
2529
+ clone:function () {
2530
+ var action = new cc.Blink();
2531
+ this._cloneDecoration(action);
2532
+ action.initWithDuration(this._duration, this._times);
2533
+ return action;
2534
+ },
2535
+
2536
+ /**
2537
+ * Called once per frame. Time is the number of seconds of a frame interval.
2538
+ * @param {Number} dt time in seconds
2539
+ */
2540
+ update:function (dt) {
2541
+ dt = this._computeEaseTime(dt);
2542
+ if (this.target && !this.isDone()) {
2543
+ var slice = 1.0 / this._times;
2544
+ var m = dt % slice;
2545
+ this.target.visible = (m > (slice / 2));
2546
+ }
2547
+ },
2548
+
2549
+ /**
2550
+ * Start the action with target.
2551
+ * @param {cc.Node} target
2552
+ */
2553
+ startWithTarget:function (target) {
2554
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
2555
+ this._originalState = target.visible;
2556
+ },
2557
+
2558
+ /**
2559
+ * stop the action
2560
+ */
2561
+ stop:function () {
2562
+ this.target.visible = this._originalState;
2563
+ cc.ActionInterval.prototype.stop.call(this);
2564
+ },
2565
+
2566
+ /**
2567
+ * Returns a reversed action.
2568
+ * @return {cc.Blink}
2569
+ */
2570
+ reverse:function () {
2571
+ var action = new cc.Blink(this._duration, this._times);
2572
+ this._cloneDecoration(action);
2573
+ this._reverseEaseList(action);
2574
+ return action;
2575
+ }
2576
+ });
2577
+ /**
2578
+ * Blinks a cc.Node object by modifying it's visible attribute.
2579
+ * @function
2580
+ * @param {Number} duration duration in seconds
2581
+ * @param blinks blinks in times
2582
+ * @return {cc.Blink}
2583
+ * @example
2584
+ * // example
2585
+ * var action = cc.blink(2, 10);
2586
+ */
2587
+ cc.blink = function (duration, blinks) {
2588
+ return new cc.Blink(duration, blinks);
2589
+ };
2590
+ /**
2591
+ * Please use cc.blink instead.
2592
+ * Blinks a cc.Node object by modifying it's visible attribute.
2593
+ * @static
2594
+ * @deprecated since v3.0 please use cc.blink instead.
2595
+ * @param {Number} duration duration in seconds
2596
+ * @param blinks blinks in times
2597
+ * @return {cc.Blink}
2598
+ */
2599
+ cc.Blink.create = cc.blink;
2600
+
2601
+ /** Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
2602
+ * @warning This action doesn't support "reverse"
2603
+ * @class
2604
+ * @extends cc.ActionInterval
2605
+ * @param {Number} duration
2606
+ * @param {Number} opacity 0-255, 0 is transparent
2607
+ * @example
2608
+ * var action = new cc.FadeTo(1.0, 0);
2609
+ */
2610
+ cc.FadeTo = cc.ActionInterval.extend(/** @lends cc.FadeTo# */{
2611
+ _toOpacity:0,
2612
+ _fromOpacity:0,
2613
+
2614
+ /**
2615
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
2616
+ * @param {Number} duration
2617
+ * @param {Number} opacity 0-255, 0 is transparent
2618
+ */
2619
+ ctor:function (duration, opacity) {
2620
+ cc.ActionInterval.prototype.ctor.call(this);
2621
+ opacity !== undefined && this.initWithDuration(duration, opacity);
2622
+ },
2623
+
2624
+ /**
2625
+ * Initializes the action.
2626
+ * @param {Number} duration duration in seconds
2627
+ * @param {Number} opacity
2628
+ * @return {Boolean}
2629
+ */
2630
+ initWithDuration:function (duration, opacity) {
2631
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
2632
+ this._toOpacity = opacity;
2633
+ return true;
2634
+ }
2635
+ return false;
2636
+ },
2637
+
2638
+ /**
2639
+ * returns a new clone of the action
2640
+ * @returns {cc.FadeTo}
2641
+ */
2642
+ clone:function () {
2643
+ var action = new cc.FadeTo();
2644
+ this._cloneDecoration(action);
2645
+ action.initWithDuration(this._duration, this._toOpacity);
2646
+ return action;
2647
+ },
2648
+
2649
+ /**
2650
+ * Called once per frame. Time is the number of seconds of a frame interval.
2651
+ * @param {Number} time time in seconds
2652
+ */
2653
+ update:function (time) {
2654
+ time = this._computeEaseTime(time);
2655
+ var fromOpacity = this._fromOpacity !== undefined ? this._fromOpacity : 255;
2656
+ this.target.opacity = fromOpacity + (this._toOpacity - fromOpacity) * time;
2657
+ },
2658
+
2659
+ /**
2660
+ * Start this action with target.
2661
+ * @param {cc.Node} target
2662
+ */
2663
+ startWithTarget:function (target) {
2664
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
2665
+ this._fromOpacity = target.opacity;
2666
+ }
2667
+ });
2668
+
2669
+ /**
2670
+ * Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
2671
+ * @function
2672
+ * @param {Number} duration
2673
+ * @param {Number} opacity 0-255, 0 is transparent
2674
+ * @return {cc.FadeTo}
2675
+ * @example
2676
+ * // example
2677
+ * var action = cc.fadeTo(1.0, 0);
2678
+ */
2679
+ cc.fadeTo = function (duration, opacity) {
2680
+ return new cc.FadeTo(duration, opacity);
2681
+ };
2682
+ /**
2683
+ * Please use cc.fadeTo instead.
2684
+ * Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one.
2685
+ * @static
2686
+ * @deprecated since v3.0 please use cc.fadeTo instead.
2687
+ * @param {Number} duration
2688
+ * @param {Number} opacity 0-255, 0 is transparent
2689
+ * @return {cc.FadeTo}
2690
+ */
2691
+ cc.FadeTo.create = cc.fadeTo;
2692
+
2693
+ /** Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.<br/>
2694
+ * The "reverse" of this action is FadeOut
2695
+ * @class
2696
+ * @extends cc.FadeTo
2697
+ * @param {Number} duration duration in seconds
2698
+ */
2699
+ cc.FadeIn = cc.FadeTo.extend(/** @lends cc.FadeIn# */{
2700
+ _reverseAction: null,
2701
+
2702
+ /**
2703
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
2704
+ * @param {Number} duration duration in seconds
2705
+ */
2706
+ ctor:function (duration) {
2707
+ cc.FadeTo.prototype.ctor.call(this);
2708
+ if (duration == null)
2709
+ duration = 0;
2710
+ this.initWithDuration(duration, 255);
2711
+ },
2712
+
2713
+ /**
2714
+ * Returns a reversed action.
2715
+ * @return {cc.FadeOut}
2716
+ */
2717
+ reverse:function () {
2718
+ var action = new cc.FadeOut();
2719
+ action.initWithDuration(this._duration, 0);
2720
+ this._cloneDecoration(action);
2721
+ this._reverseEaseList(action);
2722
+ return action;
2723
+ },
2724
+
2725
+ /**
2726
+ * returns a new clone of the action
2727
+ * @returns {cc.FadeIn}
2728
+ */
2729
+ clone:function () {
2730
+ var action = new cc.FadeIn();
2731
+ this._cloneDecoration(action);
2732
+ action.initWithDuration(this._duration, this._toOpacity);
2733
+ return action;
2734
+ },
2735
+
2736
+ /**
2737
+ * Start the action with target.
2738
+ * @param {cc.Node} target
2739
+ */
2740
+ startWithTarget:function (target) {
2741
+ if(this._reverseAction)
2742
+ this._toOpacity = this._reverseAction._fromOpacity;
2743
+ cc.FadeTo.prototype.startWithTarget.call(this, target);
2744
+ }
2745
+ });
2746
+
2747
+ /**
2748
+ * Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
2749
+ * @function
2750
+ * @param {Number} duration duration in seconds
2751
+ * @return {cc.FadeIn}
2752
+ * @example
2753
+ * //example
2754
+ * var action = cc.fadeIn(1.0);
2755
+ */
2756
+ cc.fadeIn = function (duration) {
2757
+ return new cc.FadeIn(duration);
2758
+ };
2759
+ /**
2760
+ * Please use cc.fadeIn instead.
2761
+ * Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.
2762
+ * @static
2763
+ * @deprecated since v3.0 please use cc.fadeIn() instead.
2764
+ * @param {Number} duration duration in seconds
2765
+ * @return {cc.FadeIn}
2766
+ */
2767
+ cc.FadeIn.create = cc.fadeIn;
2768
+
2769
+
2770
+ /** Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
2771
+ * The "reverse" of this action is FadeIn
2772
+ * @class
2773
+ * @extends cc.FadeTo
2774
+ * @param {Number} duration duration in seconds
2775
+ */
2776
+ cc.FadeOut = cc.FadeTo.extend(/** @lends cc.FadeOut# */{
2777
+
2778
+ /**
2779
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
2780
+ * @param {Number} duration duration in seconds
2781
+ */
2782
+ ctor:function (duration) {
2783
+ cc.FadeTo.prototype.ctor.call(this);
2784
+ if (duration == null)
2785
+ duration = 0;
2786
+ this.initWithDuration(duration, 0);
2787
+ },
2788
+
2789
+ /**
2790
+ * Returns a reversed action.
2791
+ * @return {cc.FadeIn}
2792
+ */
2793
+ reverse:function () {
2794
+ var action = new cc.FadeIn();
2795
+ action._reverseAction = this;
2796
+ action.initWithDuration(this._duration, 255);
2797
+ this._cloneDecoration(action);
2798
+ this._reverseEaseList(action);
2799
+ return action;
2800
+ },
2801
+
2802
+ /**
2803
+ * returns a new clone of the action
2804
+ * @returns {cc.FadeOut}
2805
+ */
2806
+ clone:function () {
2807
+ var action = new cc.FadeOut();
2808
+ this._cloneDecoration(action);
2809
+ action.initWithDuration(this._duration, this._toOpacity);
2810
+ return action;
2811
+ }
2812
+ });
2813
+
2814
+ /**
2815
+ * Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
2816
+ * @function
2817
+ * @param {Number} d duration in seconds
2818
+ * @return {cc.FadeOut}
2819
+ * @example
2820
+ * // example
2821
+ * var action = cc.fadeOut(1.0);
2822
+ */
2823
+ cc.fadeOut = function (d) {
2824
+ return new cc.FadeOut(d);
2825
+ };
2826
+ /**
2827
+ * Please use cc.fadeOut instead.
2828
+ * Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.
2829
+ * @static
2830
+ * @deprecated since v3.0 please use cc.fadeOut instead.
2831
+ * @param {Number} d duration in seconds
2832
+ * @return {cc.FadeOut}
2833
+ */
2834
+ cc.FadeOut.create = cc.fadeOut;
2835
+
2836
+ /** Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one.
2837
+ * @warning This action doesn't support "reverse"
2838
+ * @class
2839
+ * @extends cc.ActionInterval
2840
+ * @param {Number} duration
2841
+ * @param {Number} red 0-255
2842
+ * @param {Number} green 0-255
2843
+ * @param {Number} blue 0-255
2844
+ * @example
2845
+ * var action = new cc.TintTo(2, 255, 0, 255);
2846
+ */
2847
+ cc.TintTo = cc.ActionInterval.extend(/** @lends cc.TintTo# */{
2848
+ _to:null,
2849
+ _from:null,
2850
+
2851
+ /**
2852
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
2853
+ * @param {Number} duration
2854
+ * @param {Number} red 0-255
2855
+ * @param {Number} green 0-255
2856
+ * @param {Number} blue 0-255
2857
+ */
2858
+ ctor:function (duration, red, green, blue) {
2859
+ cc.ActionInterval.prototype.ctor.call(this);
2860
+ this._to = cc.color(0, 0, 0);
2861
+ this._from = cc.color(0, 0, 0);
2862
+
2863
+ blue !== undefined && this.initWithDuration(duration, red, green, blue);
2864
+ },
2865
+
2866
+ /**
2867
+ * Initializes the action.
2868
+ * @param {Number} duration
2869
+ * @param {Number} red 0-255
2870
+ * @param {Number} green 0-255
2871
+ * @param {Number} blue 0-255
2872
+ * @return {Boolean}
2873
+ */
2874
+ initWithDuration:function (duration, red, green, blue) {
2875
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
2876
+ this._to = cc.color(red, green, blue);
2877
+ return true;
2878
+ }
2879
+ return false;
2880
+ },
2881
+
2882
+ /**
2883
+ * returns a new clone of the action
2884
+ * @returns {cc.TintTo}
2885
+ */
2886
+ clone:function () {
2887
+ var action = new cc.TintTo();
2888
+ this._cloneDecoration(action);
2889
+ var locTo = this._to;
2890
+ action.initWithDuration(this._duration, locTo.r, locTo.g, locTo.b);
2891
+ return action;
2892
+ },
2893
+
2894
+ /**
2895
+ * Start the action with target.
2896
+ * @param {cc.Node} target
2897
+ */
2898
+ startWithTarget:function (target) {
2899
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
2900
+
2901
+ this._from = this.target.color;
2902
+ },
2903
+
2904
+ /**
2905
+ * Called once per frame. Time is the number of seconds of a frame interval.
2906
+ * @param {Number} dt time in seconds
2907
+ */
2908
+ update:function (dt) {
2909
+ dt = this._computeEaseTime(dt);
2910
+ var locFrom = this._from, locTo = this._to;
2911
+ if (locFrom) {
2912
+ this.target.color = cc.color(locFrom.r + (locTo.r - locFrom.r) * dt,
2913
+ locFrom.g + (locTo.g - locFrom.g) * dt,
2914
+ locFrom.b + (locTo.b - locFrom.b) * dt);
2915
+ }
2916
+ }
2917
+ });
2918
+
2919
+ /**
2920
+ * Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one.
2921
+ * @function
2922
+ * @param {Number} duration
2923
+ * @param {Number} red 0-255
2924
+ * @param {Number} green 0-255
2925
+ * @param {Number} blue 0-255
2926
+ * @return {cc.TintTo}
2927
+ * @example
2928
+ * // example
2929
+ * var action = cc.tintTo(2, 255, 0, 255);
2930
+ */
2931
+ cc.tintTo = function (duration, red, green, blue) {
2932
+ return new cc.TintTo(duration, red, green, blue);
2933
+ };
2934
+ /**
2935
+ * Please use cc.tintTo instead.
2936
+ * Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one.
2937
+ * @static
2938
+ * @deprecated since v3.0 please use cc.tintTo instead.
2939
+ * @param {Number} duration
2940
+ * @param {Number} red 0-255
2941
+ * @param {Number} green 0-255
2942
+ * @param {Number} blue 0-255
2943
+ * @return {cc.TintTo}
2944
+ */
2945
+ cc.TintTo.create = cc.tintTo;
2946
+
2947
+
2948
+ /** Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one.
2949
+ * Relative to their own color change.
2950
+ * @class
2951
+ * @extends cc.ActionInterval
2952
+ * @param {Number} duration duration in seconds
2953
+ * @param {Number} deltaRed
2954
+ * @param {Number} deltaGreen
2955
+ * @param {Number} deltaBlue
2956
+ * @example
2957
+ * var action = new cc.TintBy(2, -127, -255, -127);
2958
+ */
2959
+ cc.TintBy = cc.ActionInterval.extend(/** @lends cc.TintBy# */{
2960
+ _deltaR:0,
2961
+ _deltaG:0,
2962
+ _deltaB:0,
2963
+
2964
+ _fromR:0,
2965
+ _fromG:0,
2966
+ _fromB:0,
2967
+
2968
+ /**
2969
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
2970
+ * @param {Number} duration duration in seconds
2971
+ * @param {Number} deltaRed
2972
+ * @param {Number} deltaGreen
2973
+ * @param {Number} deltaBlue
2974
+ */
2975
+ ctor:function (duration, deltaRed, deltaGreen, deltaBlue) {
2976
+ cc.ActionInterval.prototype.ctor.call(this);
2977
+ deltaBlue !== undefined && this.initWithDuration(duration, deltaRed, deltaGreen, deltaBlue);
2978
+ },
2979
+
2980
+ /**
2981
+ * Initializes the action.
2982
+ * @param {Number} duration
2983
+ * @param {Number} deltaRed 0-255
2984
+ * @param {Number} deltaGreen 0-255
2985
+ * @param {Number} deltaBlue 0-255
2986
+ * @return {Boolean}
2987
+ */
2988
+ initWithDuration:function (duration, deltaRed, deltaGreen, deltaBlue) {
2989
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
2990
+ this._deltaR = deltaRed;
2991
+ this._deltaG = deltaGreen;
2992
+ this._deltaB = deltaBlue;
2993
+ return true;
2994
+ }
2995
+ return false;
2996
+ },
2997
+
2998
+ /**
2999
+ * returns a new clone of the action
3000
+ * @returns {cc.TintBy}
3001
+ */
3002
+ clone:function () {
3003
+ var action = new cc.TintBy();
3004
+ this._cloneDecoration(action);
3005
+ action.initWithDuration(this._duration, this._deltaR, this._deltaG, this._deltaB);
3006
+ return action;
3007
+ },
3008
+
3009
+ /**
3010
+ * Start the action with target.
3011
+ * @param {cc.Node} target
3012
+ */
3013
+ startWithTarget:function (target) {
3014
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
3015
+
3016
+ var color = target.color;
3017
+ this._fromR = color.r;
3018
+ this._fromG = color.g;
3019
+ this._fromB = color.b;
3020
+
3021
+ },
3022
+
3023
+ /**
3024
+ * Called once per frame. Time is the number of seconds of a frame interval.
3025
+ * @param {Number} dt time in seconds
3026
+ */
3027
+ update:function (dt) {
3028
+ dt = this._computeEaseTime(dt);
3029
+
3030
+ this.target.color = cc.color(this._fromR + this._deltaR * dt,
3031
+ this._fromG + this._deltaG * dt,
3032
+ this._fromB + this._deltaB * dt);
3033
+
3034
+ },
3035
+
3036
+ /**
3037
+ * Returns a reversed action.
3038
+ * @return {cc.TintBy}
3039
+ */
3040
+ reverse:function () {
3041
+ var action = new cc.TintBy(this._duration, -this._deltaR, -this._deltaG, -this._deltaB);
3042
+ this._cloneDecoration(action);
3043
+ this._reverseEaseList(action);
3044
+ return action;
3045
+ }
3046
+ });
3047
+
3048
+ /**
3049
+ * Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one.
3050
+ * Relative to their own color change.
3051
+ * @function
3052
+ * @param {Number} duration duration in seconds
3053
+ * @param {Number} deltaRed
3054
+ * @param {Number} deltaGreen
3055
+ * @param {Number} deltaBlue
3056
+ * @return {cc.TintBy}
3057
+ * @example
3058
+ * // example
3059
+ * var action = cc.tintBy(2, -127, -255, -127);
3060
+ */
3061
+ cc.tintBy = function (duration, deltaRed, deltaGreen, deltaBlue) {
3062
+ return new cc.TintBy(duration, deltaRed, deltaGreen, deltaBlue);
3063
+ };
3064
+ /**
3065
+ * Please use cc.tintBy instead.
3066
+ * Tints a cc.Node that implements the cc.NodeRGB protocol from current tint to a custom one.
3067
+ * Relative to their own color change.
3068
+ * @static
3069
+ * @deprecated since v3.0 please use cc.tintBy instead.
3070
+ * @param {Number} duration duration in seconds
3071
+ * @param {Number} deltaRed
3072
+ * @param {Number} deltaGreen
3073
+ * @param {Number} deltaBlue
3074
+ * @return {cc.TintBy}
3075
+ */
3076
+ cc.TintBy.create = cc.tintBy;
3077
+
3078
+ /** Delays the action a certain amount of seconds
3079
+ * @class
3080
+ * @extends cc.ActionInterval
3081
+ */
3082
+ cc.DelayTime = cc.ActionInterval.extend(/** @lends cc.DelayTime# */{
3083
+ /**
3084
+ * Called once per frame. Time is the number of seconds of a frame interval.
3085
+ * Will be overwrite.
3086
+ * @param {Number} dt time in seconds
3087
+ */
3088
+ update:function (dt) {},
3089
+
3090
+ /**
3091
+ * Returns a reversed action.
3092
+ * @return {cc.DelayTime}
3093
+ */
3094
+ reverse:function () {
3095
+ var action = new cc.DelayTime(this._duration);
3096
+ this._cloneDecoration(action);
3097
+ this._reverseEaseList(action);
3098
+ return action;
3099
+ },
3100
+
3101
+ /**
3102
+ * returns a new clone of the action
3103
+ * @returns {cc.DelayTime}
3104
+ */
3105
+ clone:function () {
3106
+ var action = new cc.DelayTime();
3107
+ this._cloneDecoration(action);
3108
+ action.initWithDuration(this._duration);
3109
+ return action;
3110
+ }
3111
+ });
3112
+
3113
+ /**
3114
+ * Delays the action a certain amount of seconds
3115
+ * @function
3116
+ * @param {Number} d duration in seconds
3117
+ * @return {cc.DelayTime}
3118
+ * @example
3119
+ * // example
3120
+ * var delay = cc.delayTime(1);
3121
+ */
3122
+ cc.delayTime = function (d) {
3123
+ return new cc.DelayTime(d);
3124
+ };
3125
+ /**
3126
+ * Please use cc.delayTime instead.
3127
+ * Delays the action a certain amount of seconds
3128
+ * @static
3129
+ * @deprecated since v3.0 please use cc.delaTime instead.
3130
+ * @param {Number} d duration in seconds
3131
+ * @return {cc.DelayTime}
3132
+ */
3133
+ cc.DelayTime.create = cc.delayTime;
3134
+
3135
+ /**
3136
+ * <p>
3137
+ * Executes an action in reverse order, from time=duration to time=0 <br/>
3138
+ * @warning Use this action carefully. This action is not sequenceable. <br/>
3139
+ * Use it as the default "reversed" method of your own actions, but using it outside the "reversed" <br/>
3140
+ * scope is not recommended.
3141
+ * </p>
3142
+ * @class
3143
+ * @extends cc.ActionInterval
3144
+ * @param {cc.FiniteTimeAction} action
3145
+ * @example
3146
+ * var reverse = new cc.ReverseTime(this);
3147
+ */
3148
+ cc.ReverseTime = cc.ActionInterval.extend(/** @lends cc.ReverseTime# */{
3149
+ _other:null,
3150
+
3151
+ /**
3152
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
3153
+ * @param {cc.FiniteTimeAction} action
3154
+ */
3155
+ ctor:function (action) {
3156
+ cc.ActionInterval.prototype.ctor.call(this);
3157
+ this._other = null;
3158
+
3159
+ action && this.initWithAction(action);
3160
+ },
3161
+
3162
+ /**
3163
+ * @param {cc.FiniteTimeAction} action
3164
+ * @return {Boolean}
3165
+ */
3166
+ initWithAction:function (action) {
3167
+ if(!action)
3168
+ throw "cc.ReverseTime.initWithAction(): action must be non null";
3169
+ if(action == this._other)
3170
+ throw "cc.ReverseTime.initWithAction(): the action was already passed in.";
3171
+
3172
+ if (cc.ActionInterval.prototype.initWithDuration.call(this, action._duration)) {
3173
+ // Don't leak if action is reused
3174
+ this._other = action;
3175
+ return true;
3176
+ }
3177
+ return false;
3178
+ },
3179
+
3180
+ /**
3181
+ * returns a new clone of the action
3182
+ * @returns {cc.ReverseTime}
3183
+ */
3184
+ clone:function () {
3185
+ var action = new cc.ReverseTime();
3186
+ this._cloneDecoration(action);
3187
+ action.initWithAction(this._other.clone());
3188
+ return action;
3189
+ },
3190
+
3191
+ /**
3192
+ * Start the action with target.
3193
+ * @param {cc.Node} target
3194
+ */
3195
+ startWithTarget:function (target) {
3196
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
3197
+ this._other.startWithTarget(target);
3198
+ },
3199
+
3200
+ /**
3201
+ * Called once per frame. Time is the number of seconds of a frame interval.
3202
+ * @param {Number} dt time in seconds
3203
+ */
3204
+ update:function (dt) {
3205
+ dt = this._computeEaseTime(dt);
3206
+ if (this._other)
3207
+ this._other.update(1 - dt);
3208
+ },
3209
+
3210
+ /**
3211
+ * Returns a reversed action.
3212
+ * @return {cc.ActionInterval}
3213
+ */
3214
+ reverse:function () {
3215
+ return this._other.clone();
3216
+ },
3217
+
3218
+ /**
3219
+ * Stop the action
3220
+ */
3221
+ stop:function () {
3222
+ this._other.stop();
3223
+ cc.Action.prototype.stop.call(this);
3224
+ }
3225
+ });
3226
+
3227
+ /**
3228
+ * Executes an action in reverse order, from time=duration to time=0.
3229
+ * @function
3230
+ * @param {cc.FiniteTimeAction} action
3231
+ * @return {cc.ReverseTime}
3232
+ * @example
3233
+ * // example
3234
+ * var reverse = cc.reverseTime(this);
3235
+ */
3236
+ cc.reverseTime = function (action) {
3237
+ return new cc.ReverseTime(action);
3238
+ };
3239
+ /**
3240
+ * Please use cc.reverseTime instead.
3241
+ * Executes an action in reverse order, from time=duration to time=0.
3242
+ * @static
3243
+ * @deprecated since v3.0 please use cc.reverseTime instead.
3244
+ * @param {cc.FiniteTimeAction} action
3245
+ * @return {cc.ReverseTime}
3246
+ */
3247
+ cc.ReverseTime.create = cc.reverseTime;
3248
+
3249
+
3250
+ /** Animates a sprite given the name of an Animation
3251
+ * @class
3252
+ * @extends cc.ActionInterval
3253
+ * @param {cc.Animation} animation
3254
+ * @example
3255
+ * // create the animation with animation
3256
+ * var anim = new cc.Animate(dance_grey);
3257
+ */
3258
+ cc.Animate = cc.ActionInterval.extend(/** @lends cc.Animate# */{
3259
+ _animation:null,
3260
+ _nextFrame:0,
3261
+ _origFrame:null,
3262
+ _executedLoops:0,
3263
+ _splitTimes:null,
3264
+
3265
+ /**
3266
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
3267
+ * create the animate with animation.
3268
+ * @param {cc.Animation} animation
3269
+ */
3270
+ ctor:function (animation) {
3271
+ cc.ActionInterval.prototype.ctor.call(this);
3272
+ this._splitTimes = [];
3273
+
3274
+ animation && this.initWithAnimation(animation);
3275
+ },
3276
+
3277
+ /**
3278
+ * @return {cc.Animation}
3279
+ */
3280
+ getAnimation:function () {
3281
+ return this._animation;
3282
+ },
3283
+
3284
+ /**
3285
+ * @param {cc.Animation} animation
3286
+ */
3287
+ setAnimation:function (animation) {
3288
+ this._animation = animation;
3289
+ },
3290
+
3291
+ /**
3292
+ * @param {cc.Animation} animation
3293
+ * @return {Boolean}
3294
+ */
3295
+ initWithAnimation:function (animation) {
3296
+ if(!animation)
3297
+ throw "cc.Animate.initWithAnimation(): animation must be non-NULL";
3298
+ var singleDuration = animation.getDuration();
3299
+ if (this.initWithDuration(singleDuration * animation.getLoops())) {
3300
+ this._nextFrame = 0;
3301
+ this.setAnimation(animation);
3302
+
3303
+ this._origFrame = null;
3304
+ this._executedLoops = 0;
3305
+ var locTimes = this._splitTimes;
3306
+ locTimes.length = 0;
3307
+
3308
+ var accumUnitsOfTime = 0;
3309
+ var newUnitOfTimeValue = singleDuration / animation.getTotalDelayUnits();
3310
+
3311
+ var frames = animation.getFrames();
3312
+ cc.arrayVerifyType(frames, cc.AnimationFrame);
3313
+
3314
+ for (var i = 0; i < frames.length; i++) {
3315
+ var frame = frames[i];
3316
+ var value = (accumUnitsOfTime * newUnitOfTimeValue) / singleDuration;
3317
+ accumUnitsOfTime += frame.getDelayUnits();
3318
+ locTimes.push(value);
3319
+ }
3320
+ return true;
3321
+ }
3322
+ return false;
3323
+ },
3324
+
3325
+ /**
3326
+ * returns a new clone of the action
3327
+ * @returns {cc.Animate}
3328
+ */
3329
+ clone:function () {
3330
+ var action = new cc.Animate();
3331
+ this._cloneDecoration(action);
3332
+ action.initWithAnimation(this._animation.clone());
3333
+ return action;
3334
+ },
3335
+
3336
+ /**
3337
+ * Start the action with target.
3338
+ * @param {cc.Sprite} target
3339
+ */
3340
+ startWithTarget:function (target) {
3341
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
3342
+ if (this._animation.getRestoreOriginalFrame())
3343
+ this._origFrame = target.displayFrame();
3344
+ this._nextFrame = 0;
3345
+ this._executedLoops = 0;
3346
+ },
3347
+
3348
+ /**
3349
+ * Called once per frame. Time is the number of seconds of a frame interval.
3350
+ * @param {Number} dt
3351
+ */
3352
+ update:function (dt) {
3353
+ dt = this._computeEaseTime(dt);
3354
+ // if t==1, ignore. Animation should finish with t==1
3355
+ if (dt < 1.0) {
3356
+ dt *= this._animation.getLoops();
3357
+
3358
+ // new loop? If so, reset frame counter
3359
+ var loopNumber = 0 | dt;
3360
+ if (loopNumber > this._executedLoops) {
3361
+ this._nextFrame = 0;
3362
+ this._executedLoops++;
3363
+ }
3364
+
3365
+ // new t for animations
3366
+ dt = dt % 1.0;
3367
+ }
3368
+
3369
+ var frames = this._animation.getFrames();
3370
+ var numberOfFrames = frames.length, locSplitTimes = this._splitTimes;
3371
+ for (var i = this._nextFrame; i < numberOfFrames; i++) {
3372
+ if (locSplitTimes[i] <= dt) {
3373
+ this.target.setSpriteFrame(frames[i].getSpriteFrame());
3374
+ this._nextFrame = i + 1;
3375
+ } else {
3376
+ // Issue 1438. Could be more than one frame per tick, due to low frame rate or frame delta < 1/FPS
3377
+ break;
3378
+ }
3379
+ }
3380
+ },
3381
+
3382
+ /**
3383
+ * Returns a reversed action.
3384
+ * @return {cc.Animate}
3385
+ */
3386
+ reverse:function () {
3387
+ var locAnimation = this._animation;
3388
+ var oldArray = locAnimation.getFrames();
3389
+ var newArray = [];
3390
+ cc.arrayVerifyType(oldArray, cc.AnimationFrame);
3391
+ if (oldArray.length > 0) {
3392
+ for (var i = oldArray.length - 1; i >= 0; i--) {
3393
+ var element = oldArray[i];
3394
+ if (!element)
3395
+ break;
3396
+ newArray.push(element.clone());
3397
+ }
3398
+ }
3399
+ var newAnim = new cc.Animation(newArray, locAnimation.getDelayPerUnit(), locAnimation.getLoops());
3400
+ newAnim.setRestoreOriginalFrame(locAnimation.getRestoreOriginalFrame());
3401
+ var action = new cc.Animate(newAnim);
3402
+ this._cloneDecoration(action);
3403
+ this._reverseEaseList(action);
3404
+
3405
+ return action;
3406
+ },
3407
+
3408
+ /**
3409
+ * stop the action
3410
+ */
3411
+ stop:function () {
3412
+ if (this._animation.getRestoreOriginalFrame() && this.target)
3413
+ this.target.setSpriteFrame(this._origFrame);
3414
+ cc.Action.prototype.stop.call(this);
3415
+ }
3416
+ });
3417
+
3418
+ /**
3419
+ * create the animate with animation
3420
+ * @function
3421
+ * @param {cc.Animation} animation
3422
+ * @return {cc.Animate}
3423
+ * @example
3424
+ * // example
3425
+ * // create the animation with animation
3426
+ * var anim = cc.animate(dance_grey);
3427
+ */
3428
+ cc.animate = function (animation) {
3429
+ return new cc.Animate(animation);
3430
+ };
3431
+ /**
3432
+ * Please use cc.animate instead
3433
+ * create the animate with animation
3434
+ * @static
3435
+ * @deprecated since v3.0 please use cc.animate instead.
3436
+ * @param {cc.Animation} animation
3437
+ * @return {cc.Animate}
3438
+ */
3439
+ cc.Animate.create = cc.animate;
3440
+
3441
+ /**
3442
+ * <p>
3443
+ * Overrides the target of an action so that it always runs on the target<br/>
3444
+ * specified at action creation rather than the one specified by runAction.
3445
+ * </p>
3446
+ * @class
3447
+ * @extends cc.ActionInterval
3448
+ * @param {cc.Node} target
3449
+ * @param {cc.FiniteTimeAction} action
3450
+ */
3451
+ cc.TargetedAction = cc.ActionInterval.extend(/** @lends cc.TargetedAction# */{
3452
+ _action:null,
3453
+ _forcedTarget:null,
3454
+
3455
+ /**
3456
+ * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br />
3457
+ * Create an action with the specified action and forced target.
3458
+ * @param {cc.Node} target
3459
+ * @param {cc.FiniteTimeAction} action
3460
+ */
3461
+ ctor: function (target, action) {
3462
+ cc.ActionInterval.prototype.ctor.call(this);
3463
+ action && this.initWithTarget(target, action);
3464
+ },
3465
+
3466
+ /**
3467
+ * Init an action with the specified action and forced target
3468
+ * @param {cc.Node} target
3469
+ * @param {cc.FiniteTimeAction} action
3470
+ * @return {Boolean}
3471
+ */
3472
+ initWithTarget:function (target, action) {
3473
+ if (this.initWithDuration(action._duration)) {
3474
+ this._forcedTarget = target;
3475
+ this._action = action;
3476
+ return true;
3477
+ }
3478
+ return false;
3479
+ },
3480
+
3481
+ /**
3482
+ * returns a new clone of the action
3483
+ * @returns {cc.TargetedAction}
3484
+ */
3485
+ clone:function () {
3486
+ var action = new cc.TargetedAction();
3487
+ this._cloneDecoration(action);
3488
+ action.initWithTarget(this._forcedTarget, this._action.clone());
3489
+ return action;
3490
+ },
3491
+
3492
+ /**
3493
+ * Start the action with target.
3494
+ * @param {cc.Node} target
3495
+ */
3496
+ startWithTarget:function (target) {
3497
+ cc.ActionInterval.prototype.startWithTarget.call(this, target);
3498
+ this._action.startWithTarget(this._forcedTarget);
3499
+ },
3500
+
3501
+ /**
3502
+ * stop the action
3503
+ */
3504
+ stop:function () {
3505
+ this._action.stop();
3506
+ },
3507
+
3508
+ /**
3509
+ * Called once per frame. Time is the number of seconds of a frame interval.
3510
+ * @param {Number} dt
3511
+ */
3512
+ update:function (dt) {
3513
+ dt = this._computeEaseTime(dt);
3514
+ this._action.update(dt);
3515
+ },
3516
+
3517
+ /**
3518
+ * return the target that the action will be forced to run with
3519
+ * @return {cc.Node}
3520
+ */
3521
+ getForcedTarget:function () {
3522
+ return this._forcedTarget;
3523
+ },
3524
+
3525
+ /**
3526
+ * set the target that the action will be forced to run with
3527
+ * @param {cc.Node} forcedTarget
3528
+ */
3529
+ setForcedTarget:function (forcedTarget) {
3530
+ if (this._forcedTarget != forcedTarget)
3531
+ this._forcedTarget = forcedTarget;
3532
+ }
3533
+ });
3534
+
3535
+ /**
3536
+ * Create an action with the specified action and forced target
3537
+ * @function
3538
+ * @param {cc.Node} target
3539
+ * @param {cc.FiniteTimeAction} action
3540
+ * @return {cc.TargetedAction}
3541
+ */
3542
+ cc.targetedAction = function (target, action) {
3543
+ return new cc.TargetedAction(target, action);
3544
+ };
3545
+ /**
3546
+ * Please use cc.targetedAction instead
3547
+ * Create an action with the specified action and forced target
3548
+ * @static
3549
+ * @deprecated since v3.0 please use cc.targetedAction instead.
3550
+ * @param {cc.Node} target
3551
+ * @param {cc.FiniteTimeAction} action
3552
+ * @return {cc.TargetedAction}
3553
+ */
3554
+ cc.TargetedAction.create = cc.targetedAction;