ccb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,2239 @@
1
+ /******************************************************************************
2
+ * Spine Runtimes Software License
3
+ * Version 2
4
+ *
5
+ * Copyright (c) 2013, Esoteric Software
6
+ * All rights reserved.
7
+ *
8
+ * You are granted a perpetual, non-exclusive, non-sublicensable and
9
+ * non-transferable license to install, execute and perform the Spine Runtimes
10
+ * Software (the "Software") solely for internal use. Without the written
11
+ * permission of Esoteric Software, you may not (a) modify, translate, adapt or
12
+ * otherwise create derivative works, improvements of the Software or develop
13
+ * new applications using the Software or (b) remove, delete, alter or obscure
14
+ * any trademarks or any copyright, trademark, patent or other intellectual
15
+ * property or proprietary rights notices on or in the Software, including
16
+ * any copy thereof. Redistributions in binary or source form must include
17
+ * this license and terms. THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE
18
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY
21
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ *****************************************************************************/
28
+
29
+ var spine = spine || {
30
+ radDeg: 180 / Math.PI,
31
+ degRad: Math.PI / 180,
32
+ temp: [],
33
+ Float32Array: (typeof(Float32Array) === 'undefined') ? Array : Float32Array,
34
+ Uint16Array: (typeof(Uint16Array) === 'undefined') ? Array : Uint16Array
35
+ };
36
+
37
+ spine.BoneData = function (name, parent) {
38
+ this.name = name;
39
+ this.parent = parent;
40
+ };
41
+ spine.BoneData.prototype = {
42
+ length: 0,
43
+ x: 0, y: 0,
44
+ rotation: 0,
45
+ scaleX: 1, scaleY: 1,
46
+ inheritScale: true,
47
+ inheritRotation: true
48
+ };
49
+
50
+ spine.SlotData = function (name, boneData) {
51
+ this.name = name;
52
+ this.boneData = boneData;
53
+ this.r = this.g = this.b = this.a = 1; //FOR google compiler Advance mode
54
+ };
55
+ spine.SlotData.prototype = {
56
+ r: 1, g: 1, b: 1, a: 1,
57
+ attachmentName: null,
58
+ additiveBlending: false
59
+ };
60
+
61
+ spine.Bone = function (boneData, parent) {
62
+ this.data = boneData;
63
+ this.parent = parent;
64
+ this.setToSetupPose();
65
+ };
66
+ spine.Bone.yDown = false;
67
+ spine.Bone.prototype = {
68
+ x: 0, y: 0,
69
+ rotation: 0,
70
+ scaleX: 1, scaleY: 1,
71
+ m00: 0, m01: 0, worldX: 0, // a b x
72
+ m10: 0, m11: 0, worldY: 0, // c d y
73
+ worldRotation: 0,
74
+ worldScaleX: 1, worldScaleY: 1,
75
+ updateWorldTransform: function (flipX, flipY) {
76
+ var parent = this.parent;
77
+ if (parent != null) {
78
+ this.worldX = this.x * parent.m00 + this.y * parent.m01 + parent.worldX;
79
+ this.worldY = this.x * parent.m10 + this.y * parent.m11 + parent.worldY;
80
+ if (this.data.inheritScale) {
81
+ this.worldScaleX = parent.worldScaleX * this.scaleX;
82
+ this.worldScaleY = parent.worldScaleY * this.scaleY;
83
+ } else {
84
+ this.worldScaleX = this.scaleX;
85
+ this.worldScaleY = this.scaleY;
86
+ }
87
+ this.worldRotation = this.data.inheritRotation ? parent.worldRotation + this.rotation : this.rotation;
88
+ } else {
89
+ this.worldX = flipX ? -this.x : this.x;
90
+ this.worldY = flipY != spine.Bone.yDown ? -this.y : this.y;
91
+ this.worldScaleX = this.scaleX;
92
+ this.worldScaleY = this.scaleY;
93
+ this.worldRotation = this.rotation;
94
+ }
95
+ var radians = this.worldRotation * Math.PI / 180;
96
+ var cos = Math.cos(radians);
97
+ var sin = Math.sin(radians);
98
+ this.m00 = cos * this.worldScaleX;
99
+ this.m10 = sin * this.worldScaleX;
100
+ this.m01 = -sin * this.worldScaleY;
101
+ this.m11 = cos * this.worldScaleY;
102
+ if (flipX) {
103
+ this.m00 = -this.m00;
104
+ this.m01 = -this.m01;
105
+ }
106
+ if (flipY != spine.Bone.yDown) {
107
+ this.m10 = -this.m10;
108
+ this.m11 = -this.m11;
109
+ }
110
+ },
111
+ setToSetupPose: function () {
112
+ var data = this.data;
113
+ this.x = data.x;
114
+ this.y = data.y;
115
+ this.rotation = data.rotation;
116
+ this.scaleX = data.scaleX;
117
+ this.scaleY = data.scaleY;
118
+ }
119
+ };
120
+
121
+ spine.Slot = function (slotData, skeleton, bone) {
122
+ this.data = slotData;
123
+ this.skeleton = skeleton;
124
+ this.bone = bone;
125
+ this.setToSetupPose();
126
+ };
127
+ spine.Slot.prototype = {
128
+ r: 1, g: 1, b: 1, a: 1,
129
+ _attachmentTime: 0,
130
+ attachment: null,
131
+ setAttachment: function (attachment) {
132
+ this.attachment = attachment;
133
+ this._attachmentTime = this.skeleton.time;
134
+ },
135
+ setAttachmentTime: function (time) {
136
+ this._attachmentTime = this.skeleton.time - time;
137
+ },
138
+ getAttachmentTime: function () {
139
+ return this.skeleton.time - this._attachmentTime;
140
+ },
141
+ setToSetupPose: function () {
142
+ var data = this.data;
143
+ this.r = data.r;
144
+ this.g = data.g;
145
+ this.b = data.b;
146
+ this.a = data.a;
147
+
148
+ var slotDatas = this.skeleton.data.slots;
149
+ for (var i = 0, n = slotDatas.length; i < n; i++) {
150
+ if (slotDatas[i] == data) {
151
+ this.setAttachment(!data.attachmentName ? null : this.skeleton.getAttachmentBySlotIndex(i, data.attachmentName));
152
+ break;
153
+ }
154
+ }
155
+ }
156
+ };
157
+
158
+ spine.Skin = function (name) {
159
+ this.name = name;
160
+ this.attachments = {};
161
+ };
162
+ spine.Skin.prototype = {
163
+ addAttachment: function (slotIndex, name, attachment) {
164
+ this.attachments[slotIndex + ":" + name] = attachment;
165
+ },
166
+ getAttachment: function (slotIndex, name) {
167
+ return this.attachments[slotIndex + ":" + name];
168
+ },
169
+ _attachAll: function (skeleton, oldSkin) {
170
+ for (var key in oldSkin.attachments) {
171
+ var colon = key.indexOf(":");
172
+ var slotIndex = parseInt(key.substring(0, colon));
173
+ var name = key.substring(colon + 1);
174
+ var slot = skeleton.slots[slotIndex];
175
+ if (slot.attachment && slot.attachment.name == name) {
176
+ var attachment = this.getAttachment(slotIndex, name);
177
+ if (attachment) slot.setAttachment(attachment);
178
+ }
179
+ }
180
+ }
181
+ };
182
+
183
+ spine.Animation = function (name, timelines, duration) {
184
+ this.name = name;
185
+ this.timelines = timelines;
186
+ this.duration = duration;
187
+ };
188
+ spine.Animation.prototype = {
189
+ apply: function (skeleton, lastTime, time, loop, events) {
190
+ if (loop && this.duration != 0) {
191
+ time %= this.duration;
192
+ lastTime %= this.duration;
193
+ }
194
+ var timelines = this.timelines;
195
+ for (var i = 0, n = timelines.length; i < n; i++)
196
+ timelines[i].apply(skeleton, lastTime, time, events, 1);
197
+ },
198
+ mix: function (skeleton, lastTime, time, loop, events, alpha) {
199
+ if (loop && this.duration != 0) {
200
+ time %= this.duration;
201
+ lastTime %= this.duration;
202
+ }
203
+ var timelines = this.timelines;
204
+ for (var i = 0, n = timelines.length; i < n; i++)
205
+ timelines[i].apply(skeleton, lastTime, time, events, alpha);
206
+ }
207
+ };
208
+
209
+ spine.binarySearch = function (values, target, step) {
210
+ var low = 0;
211
+ var high = Math.floor(values.length / step) - 2;
212
+ if (high == 0) return step;
213
+ var current = high >>> 1;
214
+ while (true) {
215
+ if (values[(current + 1) * step] <= target)
216
+ low = current + 1;
217
+ else
218
+ high = current;
219
+ if (low == high) return (low + 1) * step;
220
+ current = (low + high) >>> 1;
221
+ }
222
+ };
223
+ spine.linearSearch = function (values, target, step) {
224
+ for (var i = 0, last = values.length - step; i <= last; i += step)
225
+ if (values[i] > target) return i;
226
+ return -1;
227
+ };
228
+
229
+ spine.Curves = function (frameCount) {
230
+ this.curves = []; // dfx, dfy, ddfx, ddfy, dddfx, dddfy, ...
231
+ this.curves.length = (frameCount - 1) * 6;
232
+ };
233
+ spine.Curves.prototype = {
234
+ setLinear: function (frameIndex) {
235
+ this.curves[frameIndex * 6] = 0/*LINEAR*/;
236
+ },
237
+ setStepped: function (frameIndex) {
238
+ this.curves[frameIndex * 6] = -1/*STEPPED*/;
239
+ },
240
+ /** Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next.
241
+ * cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of
242
+ * the difference between the keyframe's values. */
243
+ setCurve: function (frameIndex, cx1, cy1, cx2, cy2) {
244
+ var subdiv_step = 1 / 10/*BEZIER_SEGMENTS*/;
245
+ var subdiv_step2 = subdiv_step * subdiv_step;
246
+ var subdiv_step3 = subdiv_step2 * subdiv_step;
247
+ var pre1 = 3 * subdiv_step;
248
+ var pre2 = 3 * subdiv_step2;
249
+ var pre4 = 6 * subdiv_step2;
250
+ var pre5 = 6 * subdiv_step3;
251
+ var tmp1x = -cx1 * 2 + cx2;
252
+ var tmp1y = -cy1 * 2 + cy2;
253
+ var tmp2x = (cx1 - cx2) * 3 + 1;
254
+ var tmp2y = (cy1 - cy2) * 3 + 1;
255
+ var i = frameIndex * 6;
256
+ var curves = this.curves;
257
+ curves[i] = cx1 * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3;
258
+ curves[i + 1] = cy1 * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3;
259
+ curves[i + 2] = tmp1x * pre4 + tmp2x * pre5;
260
+ curves[i + 3] = tmp1y * pre4 + tmp2y * pre5;
261
+ curves[i + 4] = tmp2x * pre5;
262
+ curves[i + 5] = tmp2y * pre5;
263
+ },
264
+ getCurvePercent: function (frameIndex, percent) {
265
+ percent = percent < 0 ? 0 : (percent > 1 ? 1 : percent);
266
+ var curveIndex = frameIndex * 6;
267
+ var curves = this.curves;
268
+ var dfx = curves[curveIndex];
269
+ if (!dfx/*LINEAR*/) return percent;
270
+ if (dfx == -1/*STEPPED*/) return 0;
271
+ var dfy = curves[curveIndex + 1];
272
+ var ddfx = curves[curveIndex + 2];
273
+ var ddfy = curves[curveIndex + 3];
274
+ var dddfx = curves[curveIndex + 4];
275
+ var dddfy = curves[curveIndex + 5];
276
+ var x = dfx, y = dfy;
277
+ var i = 10/*BEZIER_SEGMENTS*/ - 2;
278
+ while (true) {
279
+ if (x >= percent) {
280
+ var lastX = x - dfx;
281
+ var lastY = y - dfy;
282
+ return lastY + (y - lastY) * (percent - lastX) / (x - lastX);
283
+ }
284
+ if (i == 0) break;
285
+ i--;
286
+ dfx += ddfx;
287
+ dfy += ddfy;
288
+ ddfx += dddfx;
289
+ ddfy += dddfy;
290
+ x += dfx;
291
+ y += dfy;
292
+ }
293
+ return y + (1 - y) * (percent - x) / (1 - x); // Last point is 1,1.
294
+ }
295
+ };
296
+
297
+ spine.RotateTimeline = function (frameCount) {
298
+ this.curves = new spine.Curves(frameCount);
299
+ this.frames = []; // time, angle, ...
300
+ this.frames.length = frameCount * 2;
301
+ };
302
+ spine.RotateTimeline.prototype = {
303
+ boneIndex: 0,
304
+ getFrameCount: function () {
305
+ return this.frames.length / 2;
306
+ },
307
+ setFrame: function (frameIndex, time, angle) {
308
+ frameIndex *= 2;
309
+ this.frames[frameIndex] = time;
310
+ this.frames[frameIndex + 1] = angle;
311
+ },
312
+ apply: function (skeleton, lastTime, time, firedEvents, alpha) {
313
+ var frames = this.frames;
314
+ if (time < frames[0]) return; // Time is before first frame.
315
+
316
+ var bone = skeleton.bones[this.boneIndex];
317
+
318
+ if (time >= frames[frames.length - 2]) { // Time is after last frame.
319
+ var amount = bone.data.rotation + frames[frames.length - 1] - bone.rotation;
320
+ while (amount > 180)
321
+ amount -= 360;
322
+ while (amount < -180)
323
+ amount += 360;
324
+ bone.rotation += amount * alpha;
325
+ return;
326
+ }
327
+
328
+ // Interpolate between the last frame and the current frame.
329
+ var frameIndex = spine.binarySearch(frames, time, 2);
330
+ var lastFrameValue = frames[frameIndex - 1];
331
+ var frameTime = frames[frameIndex];
332
+ var percent = 1 - (time - frameTime) / (frames[frameIndex - 2/*LAST_FRAME_TIME*/] - frameTime);
333
+ percent = this.curves.getCurvePercent(frameIndex / 2 - 1, percent);
334
+
335
+ var amount = frames[frameIndex + 1/*FRAME_VALUE*/] - lastFrameValue;
336
+ while (amount > 180)
337
+ amount -= 360;
338
+ while (amount < -180)
339
+ amount += 360;
340
+ amount = bone.data.rotation + (lastFrameValue + amount * percent) - bone.rotation;
341
+ while (amount > 180)
342
+ amount -= 360;
343
+ while (amount < -180)
344
+ amount += 360;
345
+ bone.rotation += amount * alpha;
346
+ }
347
+ };
348
+
349
+ spine.TranslateTimeline = function (frameCount) {
350
+ this.curves = new spine.Curves(frameCount);
351
+ this.frames = []; // time, x, y, ...
352
+ this.frames.length = frameCount * 3;
353
+ };
354
+ spine.TranslateTimeline.prototype = {
355
+ boneIndex: 0,
356
+ getFrameCount: function () {
357
+ return this.frames.length / 3;
358
+ },
359
+ setFrame: function (frameIndex, time, x, y) {
360
+ frameIndex *= 3;
361
+ this.frames[frameIndex] = time;
362
+ this.frames[frameIndex + 1] = x;
363
+ this.frames[frameIndex + 2] = y;
364
+ },
365
+ apply: function (skeleton, lastTime, time, firedEvents, alpha) {
366
+ var frames = this.frames;
367
+ if (time < frames[0]) return; // Time is before first frame.
368
+
369
+ var bone = skeleton.bones[this.boneIndex];
370
+
371
+ if (time >= frames[frames.length - 3]) { // Time is after last frame.
372
+ bone.x += (bone.data.x + frames[frames.length - 2] - bone.x) * alpha;
373
+ bone.y += (bone.data.y + frames[frames.length - 1] - bone.y) * alpha;
374
+ return;
375
+ }
376
+
377
+ // Interpolate between the last frame and the current frame.
378
+ var frameIndex = spine.binarySearch(frames, time, 3);
379
+ var lastFrameX = frames[frameIndex - 2];
380
+ var lastFrameY = frames[frameIndex - 1];
381
+ var frameTime = frames[frameIndex];
382
+ var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*LAST_FRAME_TIME*/] - frameTime);
383
+ percent = this.curves.getCurvePercent(frameIndex / 3 - 1, percent);
384
+
385
+ bone.x += (bone.data.x + lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent - bone.x) * alpha;
386
+ bone.y += (bone.data.y + lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent - bone.y) * alpha;
387
+ }
388
+ };
389
+
390
+ spine.ScaleTimeline = function (frameCount) {
391
+ this.curves = new spine.Curves(frameCount);
392
+ this.frames = []; // time, x, y, ...
393
+ this.frames.length = frameCount * 3;
394
+ };
395
+ spine.ScaleTimeline.prototype = {
396
+ boneIndex: 0,
397
+ getFrameCount: function () {
398
+ return this.frames.length / 3;
399
+ },
400
+ setFrame: function (frameIndex, time, x, y) {
401
+ frameIndex *= 3;
402
+ this.frames[frameIndex] = time;
403
+ this.frames[frameIndex + 1] = x;
404
+ this.frames[frameIndex + 2] = y;
405
+ },
406
+ apply: function (skeleton, lastTime, time, firedEvents, alpha) {
407
+ var frames = this.frames;
408
+ if (time < frames[0]) return; // Time is before first frame.
409
+
410
+ var bone = skeleton.bones[this.boneIndex];
411
+
412
+ if (time >= frames[frames.length - 3]) { // Time is after last frame.
413
+ bone.scaleX += (bone.data.scaleX - 1 + frames[frames.length - 2] - bone.scaleX) * alpha;
414
+ bone.scaleY += (bone.data.scaleY - 1 + frames[frames.length - 1] - bone.scaleY) * alpha;
415
+ return;
416
+ }
417
+
418
+ // Interpolate between the last frame and the current frame.
419
+ var frameIndex = spine.binarySearch(frames, time, 3);
420
+ var lastFrameX = frames[frameIndex - 2];
421
+ var lastFrameY = frames[frameIndex - 1];
422
+ var frameTime = frames[frameIndex];
423
+ var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*LAST_FRAME_TIME*/] - frameTime);
424
+ percent = this.curves.getCurvePercent(frameIndex / 3 - 1, percent);
425
+
426
+ bone.scaleX += (bone.data.scaleX - 1 + lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent - bone.scaleX) * alpha;
427
+ bone.scaleY += (bone.data.scaleY - 1 + lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent - bone.scaleY) * alpha;
428
+ }
429
+ };
430
+
431
+ spine.ColorTimeline = function (frameCount) {
432
+ this.curves = new spine.Curves(frameCount);
433
+ this.frames = []; // time, r, g, b, a, ...
434
+ this.frames.length = frameCount * 5;
435
+ };
436
+ spine.ColorTimeline.prototype = {
437
+ slotIndex: 0,
438
+ getFrameCount: function () {
439
+ return this.frames.length / 5;
440
+ },
441
+ setFrame: function (frameIndex, time, r, g, b, a) {
442
+ frameIndex *= 5;
443
+ this.frames[frameIndex] = time;
444
+ this.frames[frameIndex + 1] = r;
445
+ this.frames[frameIndex + 2] = g;
446
+ this.frames[frameIndex + 3] = b;
447
+ this.frames[frameIndex + 4] = a;
448
+ },
449
+ apply: function (skeleton, lastTime, time, firedEvents, alpha) {
450
+ var frames = this.frames;
451
+ if (time < frames[0]) return; // Time is before first frame.
452
+
453
+ var slot = skeleton.slots[this.slotIndex];
454
+
455
+ if (time >= frames[frames.length - 5]) { // Time is after last frame.
456
+ var i = frames.length - 1;
457
+ slot.r = frames[i - 3];
458
+ slot.g = frames[i - 2];
459
+ slot.b = frames[i - 1];
460
+ slot.a = frames[i];
461
+ return;
462
+ }
463
+
464
+ // Interpolate between the last frame and the current frame.
465
+ var frameIndex = spine.binarySearch(frames, time, 5);
466
+ var lastFrameR = frames[frameIndex - 4];
467
+ var lastFrameG = frames[frameIndex - 3];
468
+ var lastFrameB = frames[frameIndex - 2];
469
+ var lastFrameA = frames[frameIndex - 1];
470
+ var frameTime = frames[frameIndex];
471
+ var percent = 1 - (time - frameTime) / (frames[frameIndex - 5/*LAST_FRAME_TIME*/] - frameTime);
472
+ percent = this.curves.getCurvePercent(frameIndex / 5 - 1, percent);
473
+
474
+ var r = lastFrameR + (frames[frameIndex + 1/*FRAME_R*/] - lastFrameR) * percent;
475
+ var g = lastFrameG + (frames[frameIndex + 2/*FRAME_G*/] - lastFrameG) * percent;
476
+ var b = lastFrameB + (frames[frameIndex + 3/*FRAME_B*/] - lastFrameB) * percent;
477
+ var a = lastFrameA + (frames[frameIndex + 4/*FRAME_A*/] - lastFrameA) * percent;
478
+ if (alpha < 1) {
479
+ slot.r += (r - slot.r) * alpha;
480
+ slot.g += (g - slot.g) * alpha;
481
+ slot.b += (b - slot.b) * alpha;
482
+ slot.a += (a - slot.a) * alpha;
483
+ } else {
484
+ slot.r = r;
485
+ slot.g = g;
486
+ slot.b = b;
487
+ slot.a = a;
488
+ }
489
+ }
490
+ };
491
+
492
+ spine.AttachmentTimeline = function (frameCount) {
493
+ this.curves = new spine.Curves(frameCount);
494
+ this.frames = []; // time, ...
495
+ this.frames.length = frameCount;
496
+ this.attachmentNames = [];
497
+ this.attachmentNames.length = frameCount;
498
+ };
499
+ spine.AttachmentTimeline.prototype = {
500
+ slotIndex: 0,
501
+ getFrameCount: function () {
502
+ return this.frames.length;
503
+ },
504
+ setFrame: function (frameIndex, time, attachmentName) {
505
+ this.frames[frameIndex] = time;
506
+ this.attachmentNames[frameIndex] = attachmentName;
507
+ },
508
+ apply: function (skeleton, lastTime, time, firedEvents, alpha) {
509
+ var frames = this.frames;
510
+ if (time < frames[0]) return; // Time is before first frame.
511
+
512
+ var frameIndex;
513
+ if (time >= frames[frames.length - 1]) // Time is after last frame.
514
+ frameIndex = frames.length - 1;
515
+ else
516
+ frameIndex = spine.binarySearch(frames, time, 1) - 1;
517
+
518
+ var attachmentName = this.attachmentNames[frameIndex];
519
+ skeleton.slots[this.slotIndex].setAttachment(!attachmentName ? null : skeleton.getAttachmentBySlotIndex(this.slotIndex, attachmentName));
520
+ }
521
+ };
522
+
523
+ spine.EventTimeline = function (frameCount) {
524
+ this.frames = []; // time, ...
525
+ this.frames.length = frameCount;
526
+ this.events = [];
527
+ this.events.length = frameCount;
528
+ };
529
+ spine.EventTimeline.prototype = {
530
+ getFrameCount: function () {
531
+ return this.frames.length;
532
+ },
533
+ setFrame: function (frameIndex, time, event) {
534
+ this.frames[frameIndex] = time;
535
+ this.events[frameIndex] = event;
536
+ },
537
+ /** Fires events for frames > lastTime and <= time. */
538
+ apply: function (skeleton, lastTime, time, firedEvents, alpha) {
539
+ if (!firedEvents) return;
540
+
541
+ var frames = this.frames;
542
+ var frameCount = frames.length;
543
+
544
+ if (lastTime > time) { // Fire events after last time for looped animations.
545
+ this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha);
546
+ lastTime = -1;
547
+ } else if (lastTime >= frames[frameCount - 1]) // Last time is after last frame.
548
+ return;
549
+ if (time < frames[0]) return; // Time is before first frame.
550
+
551
+ var frameIndex;
552
+ if (lastTime < frames[0])
553
+ frameIndex = 0;
554
+ else {
555
+ frameIndex = spine.binarySearch(frames, lastTime, 1);
556
+ var frame = frames[frameIndex];
557
+ while (frameIndex > 0) { // Fire multiple events with the same frame.
558
+ if (frames[frameIndex - 1] != frame) break;
559
+ frameIndex--;
560
+ }
561
+ }
562
+ var events = this.events;
563
+ for (; frameIndex < frameCount && time >= frames[frameIndex]; frameIndex++)
564
+ firedEvents.push(events[frameIndex]);
565
+ }
566
+ };
567
+
568
+ spine.DrawOrderTimeline = function (frameCount) {
569
+ this.frames = []; // time, ...
570
+ this.frames.length = frameCount;
571
+ this.drawOrders = [];
572
+ this.drawOrders.length = frameCount;
573
+ };
574
+ spine.DrawOrderTimeline.prototype = {
575
+ getFrameCount: function () {
576
+ return this.frames.length;
577
+ },
578
+ setFrame: function (frameIndex, time, drawOrder) {
579
+ this.frames[frameIndex] = time;
580
+ this.drawOrders[frameIndex] = drawOrder;
581
+ },
582
+ apply: function (skeleton, lastTime, time, firedEvents, alpha) {
583
+ var frames = this.frames;
584
+ if (time < frames[0]) return; // Time is before first frame.
585
+
586
+ var frameIndex;
587
+ if (time >= frames[frames.length - 1]) // Time is after last frame.
588
+ frameIndex = frames.length - 1;
589
+ else
590
+ frameIndex = spine.binarySearch(frames, time, 1) - 1;
591
+
592
+ var drawOrder = skeleton.drawOrder;
593
+ var slots = skeleton.slots;
594
+ var drawOrderToSetupIndex = this.drawOrders[frameIndex];
595
+ if (!drawOrderToSetupIndex) {
596
+ for (var i = 0, n = slots.length; i < n; i++)
597
+ drawOrder[i] = slots[i];
598
+ } else {
599
+ for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
600
+ drawOrder[i] = skeleton.slots[drawOrderToSetupIndex[i]];
601
+ }
602
+
603
+ }
604
+ };
605
+
606
+ spine.SkeletonData = function () {
607
+ this.bones = [];
608
+ this.slots = [];
609
+ this.skins = [];
610
+ this.events = [];
611
+ this.animations = [];
612
+ };
613
+ spine.SkeletonData.prototype = {
614
+ defaultSkin: null,
615
+ /** @return May be null. */
616
+ findBone: function (boneName) {
617
+ var bones = this.bones;
618
+ for (var i = 0, n = bones.length; i < n; i++)
619
+ if (bones[i].name == boneName) return bones[i];
620
+ return null;
621
+ },
622
+ /** @return -1 if the bone was not found. */
623
+ findBoneIndex: function (boneName) {
624
+ var bones = this.bones;
625
+ for (var i = 0, n = bones.length; i < n; i++)
626
+ if (bones[i].name == boneName) return i;
627
+ return -1;
628
+ },
629
+ /** @return May be null. */
630
+ findSlot: function (slotName) {
631
+ var slots = this.slots;
632
+ for (var i = 0, n = slots.length; i < n; i++) {
633
+ if (slots[i].name == slotName) return slots[i];
634
+ }
635
+ return null;
636
+ },
637
+ /** @return -1 if the bone was not found. */
638
+ findSlotIndex: function (slotName) {
639
+ var slots = this.slots;
640
+ for (var i = 0, n = slots.length; i < n; i++)
641
+ if (slots[i].name == slotName) return i;
642
+ return -1;
643
+ },
644
+ /** @return May be null. */
645
+ findSkin: function (skinName) {
646
+ var skins = this.skins;
647
+ for (var i = 0, n = skins.length; i < n; i++)
648
+ if (skins[i].name == skinName) return skins[i];
649
+ return null;
650
+ },
651
+ /** @return May be null. */
652
+ findEvent: function (eventName) {
653
+ var events = this.events;
654
+ for (var i = 0, n = events.length; i < n; i++)
655
+ if (events[i].name == eventName) return events[i];
656
+ return null;
657
+ },
658
+ /** @return May be null. */
659
+ findAnimation: function (animationName) {
660
+ var animations = this.animations;
661
+ for (var i = 0, n = animations.length; i < n; i++)
662
+ if (animations[i].name == animationName) return animations[i];
663
+ return null;
664
+ }
665
+ };
666
+
667
+ spine.Skeleton = function (skeletonData) {
668
+ this.data = skeletonData;
669
+
670
+ this.bones = [];
671
+ for (var i = 0, n = skeletonData.bones.length; i < n; i++) {
672
+ var boneData = skeletonData.bones[i];
673
+ var parent = !boneData.parent ? null : this.bones[skeletonData.bones.indexOf(boneData.parent)];
674
+ this.bones.push(new spine.Bone(boneData, parent));
675
+ }
676
+
677
+ this.slots = [];
678
+ this.drawOrder = [];
679
+ for (var i = 0, n = skeletonData.slots.length; i < n; i++) {
680
+ var slotData = skeletonData.slots[i];
681
+ var bone = this.bones[skeletonData.bones.indexOf(slotData.boneData)];
682
+ var slot = new spine.Slot(slotData, this, bone);
683
+ this.slots.push(slot);
684
+ this.drawOrder.push(slot);
685
+ }
686
+ };
687
+ spine.Skeleton.prototype = {
688
+ x: 0, y: 0,
689
+ skin: null,
690
+ r: 1, g: 1, b: 1, a: 1,
691
+ time: 0,
692
+ flipX: false, flipY: false,
693
+ /** Updates the world transform for each bone. */
694
+ updateWorldTransform: function () {
695
+ var flipX = this.flipX;
696
+ var flipY = this.flipY;
697
+ var bones = this.bones;
698
+ for (var i = 0, n = bones.length; i < n; i++)
699
+ bones[i].updateWorldTransform(flipX, flipY);
700
+ },
701
+ /** Sets the bones and slots to their setup pose values. */
702
+ setToSetupPose: function () {
703
+ this.setBonesToSetupPose();
704
+ this.setSlotsToSetupPose();
705
+ },
706
+ setBonesToSetupPose: function () {
707
+ var bones = this.bones;
708
+ for (var i = 0, n = bones.length; i < n; i++)
709
+ bones[i].setToSetupPose();
710
+ },
711
+ setSlotsToSetupPose: function () {
712
+ var slots = this.slots;
713
+ for (var i = 0, n = slots.length; i < n; i++)
714
+ slots[i].setToSetupPose(i);
715
+ },
716
+ /** @return May return null. */
717
+ getRootBone: function () {
718
+ return this.bones.length == 0 ? null : this.bones[0];
719
+ },
720
+ /** @return May be null. */
721
+ findBone: function (boneName) {
722
+ var bones = this.bones;
723
+ for (var i = 0, n = bones.length; i < n; i++)
724
+ if (bones[i].data.name == boneName) return bones[i];
725
+ return null;
726
+ },
727
+ /** @return -1 if the bone was not found. */
728
+ findBoneIndex: function (boneName) {
729
+ var bones = this.bones;
730
+ for (var i = 0, n = bones.length; i < n; i++)
731
+ if (bones[i].data.name == boneName) return i;
732
+ return -1;
733
+ },
734
+ /** @return May be null. */
735
+ findSlot: function (slotName) {
736
+ var slots = this.slots;
737
+ for (var i = 0, n = slots.length; i < n; i++)
738
+ if (slots[i].data.name == slotName) return slots[i];
739
+ return null;
740
+ },
741
+ /** @return -1 if the bone was not found. */
742
+ findSlotIndex: function (slotName) {
743
+ var slots = this.slots;
744
+ for (var i = 0, n = slots.length; i < n; i++)
745
+ if (slots[i].data.name == slotName) return i;
746
+ return -1;
747
+ },
748
+ setSkinByName: function (skinName) {
749
+ var skin = this.data.findSkin(skinName);
750
+ if (!skin) throw "Skin not found: " + skinName;
751
+ this.setSkin(skin);
752
+ },
753
+ /** Sets the skin used to look up attachments not found in the {@link SkeletonData#getDefaultSkin() default skin}. Attachments
754
+ * from the new skin are attached if the corresponding attachment from the old skin was attached.
755
+ * @param newSkin May be null. */
756
+ setSkin: function (newSkin) {
757
+ if (this.skin && newSkin) {
758
+ newSkin._attachAll(this, this.skin);
759
+ }
760
+ this.skin = newSkin;
761
+ },
762
+ /** @return May be null. */
763
+ getAttachmentBySlotName: function (slotName, attachmentName) {
764
+ return this.getAttachmentBySlotIndex(this.data.findSlotIndex(slotName), attachmentName);
765
+ },
766
+ /** @return May be null. */
767
+ getAttachmentBySlotIndex: function (slotIndex, attachmentName) {
768
+ if (this.skin) {
769
+ var attachment = this.skin.getAttachment(slotIndex, attachmentName);
770
+ if (attachment) return attachment;
771
+ }
772
+ if (this.data.defaultSkin) return this.data.defaultSkin.getAttachment(slotIndex, attachmentName);
773
+ return null;
774
+ },
775
+ /** @param attachmentName May be null. */
776
+ setAttachment: function (slotName, attachmentName) {
777
+ var slots = this.slots;
778
+ for (var i = 0, n = slots.length; i < n; i++) {
779
+ var slot = slots[i];
780
+ if (slot.data.name == slotName) {
781
+ var attachment = null;
782
+ if (attachmentName) {
783
+ attachment = this.getAttachment(i, attachmentName);
784
+ if (!attachment) throw "Attachment not found: " + attachmentName + ", for slot: " + slotName;
785
+ }
786
+ slot.setAttachment(attachment);
787
+ return;
788
+ }
789
+ }
790
+ throw "Slot not found: " + slotName;
791
+ },
792
+ update: function (delta) {
793
+ this.time += delta;
794
+ }
795
+ };
796
+
797
+ spine.EventData = function (name) {
798
+ this.name = name;
799
+ };
800
+
801
+ spine.EventData.prototype = {
802
+ intValue: 0,
803
+ floatValue: 0,
804
+ stringValue: null
805
+ };
806
+
807
+ spine.Event = function (data) {
808
+ this.data = data;
809
+ };
810
+
811
+ spine.Event.prototype = {
812
+ intValue: 0,
813
+ floatValue: 0,
814
+ stringValue: null
815
+ };
816
+
817
+ spine.AttachmentType = {
818
+ region: 0,
819
+ boundingbox: 1,
820
+ mesh: 2,
821
+ skinnedmesh: 3
822
+ };
823
+
824
+ spine.RegionAttachment = function (name) {
825
+ this.name = name;
826
+ this.offset = [];
827
+ this.offset.length = 8;
828
+ this.uvs = [];
829
+ this.uvs.length = 8;
830
+ this["type"] = spine.AttachmentType.region; //FOR advance mode
831
+ };
832
+
833
+ spine.RegionAttachment.prototype = {
834
+ type: spine.AttachmentType.region,
835
+ x: 0, y: 0,
836
+ rotation: 0,
837
+ scaleX: 1, scaleY: 1,
838
+ width: 0, height: 0,
839
+ rendererObject: null,
840
+ regionOffsetX: 0, regionOffsetY: 0,
841
+ regionWidth: 0, regionHeight: 0,
842
+ regionOriginalWidth: 0, regionOriginalHeight: 0,
843
+ setUVs: function (u, v, u2, v2, rotate) {
844
+ var uvs = this.uvs;
845
+ if (rotate) {
846
+ uvs[2/*X2*/] = u;
847
+ uvs[3/*Y2*/] = v2;
848
+ uvs[4/*X3*/] = u;
849
+ uvs[5/*Y3*/] = v;
850
+ uvs[6/*X4*/] = u2;
851
+ uvs[7/*Y4*/] = v;
852
+ uvs[0/*X1*/] = u2;
853
+ uvs[1/*Y1*/] = v2;
854
+ } else {
855
+ uvs[0/*X1*/] = u;
856
+ uvs[1/*Y1*/] = v2;
857
+ uvs[2/*X2*/] = u;
858
+ uvs[3/*Y2*/] = v;
859
+ uvs[4/*X3*/] = u2;
860
+ uvs[5/*Y3*/] = v;
861
+ uvs[6/*X4*/] = u2;
862
+ uvs[7/*Y4*/] = v2;
863
+ }
864
+ },
865
+ updateOffset: function () {
866
+ var regionScaleX = this.width / this.regionOriginalWidth * this.scaleX;
867
+ var regionScaleY = this.height / this.regionOriginalHeight * this.scaleY;
868
+ var localX = -this.width / 2 * this.scaleX + this.regionOffsetX * regionScaleX;
869
+ var localY = -this.height / 2 * this.scaleY + this.regionOffsetY * regionScaleY;
870
+ var localX2 = localX + this.regionWidth * regionScaleX;
871
+ var localY2 = localY + this.regionHeight * regionScaleY;
872
+ var radians = this.rotation * Math.PI / 180;
873
+ var cos = Math.cos(radians);
874
+ var sin = Math.sin(radians);
875
+ var localXCos = localX * cos + this.x;
876
+ var localXSin = localX * sin;
877
+ var localYCos = localY * cos + this.y;
878
+ var localYSin = localY * sin;
879
+ var localX2Cos = localX2 * cos + this.x;
880
+ var localX2Sin = localX2 * sin;
881
+ var localY2Cos = localY2 * cos + this.y;
882
+ var localY2Sin = localY2 * sin;
883
+ var offset = this.offset;
884
+ offset[0/*X1*/] = localXCos - localYSin;
885
+ offset[1/*Y1*/] = localYCos + localXSin;
886
+ offset[2/*X2*/] = localXCos - localY2Sin;
887
+ offset[3/*Y2*/] = localY2Cos + localXSin;
888
+ offset[4/*X3*/] = localX2Cos - localY2Sin;
889
+ offset[5/*Y3*/] = localY2Cos + localX2Sin;
890
+ offset[6/*X4*/] = localX2Cos - localYSin;
891
+ offset[7/*Y4*/] = localYCos + localX2Sin;
892
+ },
893
+ computeVertices: function (x, y, slot, vertices) {
894
+ var bone = slot.bone;
895
+ x += bone.worldX;
896
+ y += bone.worldY;
897
+ var m00 = bone.m00;
898
+ var m01 = bone.m01;
899
+ var m10 = bone.m10;
900
+ var m11 = bone.m11;
901
+ var offset = this.offset;
902
+ vertices[0/*X1*/] = offset[0/*X1*/] * m00 + offset[1/*Y1*/] * m01 + x;
903
+ vertices[1/*Y1*/] = offset[0/*X1*/] * m10 + offset[1/*Y1*/] * m11 + y;
904
+ vertices[2/*X2*/] = offset[2/*X2*/] * m00 + offset[3/*Y2*/] * m01 + x;
905
+ vertices[3/*Y2*/] = offset[2/*X2*/] * m10 + offset[3/*Y2*/] * m11 + y;
906
+ vertices[4/*X3*/] = offset[4/*X3*/] * m00 + offset[5/*X3*/] * m01 + x;
907
+ vertices[5/*X3*/] = offset[4/*X3*/] * m10 + offset[5/*X3*/] * m11 + y;
908
+ vertices[6/*X4*/] = offset[6/*X4*/] * m00 + offset[7/*Y4*/] * m01 + x;
909
+ vertices[7/*Y4*/] = offset[6/*X4*/] * m10 + offset[7/*Y4*/] * m11 + y;
910
+ }
911
+ };
912
+
913
+ spine.MeshAttachment = function (name) {
914
+ this.name = name;
915
+ };
916
+ spine.MeshAttachment.prototype = {
917
+ type: spine.AttachmentType.mesh,
918
+ vertices: null,
919
+ uvs: null,
920
+ regionUVs: null,
921
+ triangles: null,
922
+ hullLength: 0,
923
+ r: 1, g: 1, b: 1, a: 1,
924
+ path: null,
925
+ rendererObject: null,
926
+ regionU: 0, regionV: 0, regionU2: 0, regionV2: 0, regionRotate: false,
927
+ regionOffsetX: 0, regionOffsetY: 0,
928
+ regionWidth: 0, regionHeight: 0,
929
+ regionOriginalWidth: 0, regionOriginalHeight: 0,
930
+ edges: null,
931
+ width: 0, height: 0,
932
+ updateUVs: function () {
933
+ var width = this.regionU2 - this.regionU, height = this.regionV2 - this.regionV;
934
+ var n = this.regionUVs.length;
935
+ if (!this.uvs || this.uvs.length != n) {
936
+ this.uvs = new spine.Float32Array(n);
937
+ }
938
+ if (this.regionRotate) {
939
+ for (var i = 0; i < n; i += 2) {
940
+ this.uvs[i] = this.regionU + this.regionUVs[i + 1] * width;
941
+ this.uvs[i + 1] = this.regionV + height - this.regionUVs[i] * height;
942
+ }
943
+ } else {
944
+ for (var i = 0; i < n; i += 2) {
945
+ this.uvs[i] = this.regionU + this.regionUVs[i] * width;
946
+ this.uvs[i + 1] = this.regionV + this.regionUVs[i + 1] * height;
947
+ }
948
+ }
949
+ },
950
+ computeVertices: function (x, y, slot, vertices) {
951
+ var bone = slot.bone;
952
+ x += bone.worldX;
953
+ y += bone.worldY;
954
+ var m00 = bone.m00, m01 = bone.m01, m10 = bone.m10, m11 = bone.m11;
955
+ var verticesCount = this.vertices.length;
956
+ if (slot.attachment.length == verticesCount) this.vertices = slot.attachment;
957
+ for (var i = 0; i < verticesCount; i += 2) {
958
+ var vx = this.vertices[i];
959
+ var vy = this.vertices[i + 1];
960
+ vertices[i] = vx * m00 + vy * m01 + x;
961
+ vertices[i + 1] = vx * m10 + vy * m11 + y;
962
+ }
963
+ }
964
+ };
965
+
966
+ spine.SkinnedMeshAttachment = function (name) {
967
+ this.name = name;
968
+ };
969
+ spine.SkinnedMeshAttachment.prototype = {
970
+ type: spine.AttachmentType.skinnedmesh,
971
+ bones: null,
972
+ weights: null,
973
+ uvs: null,
974
+ regionUVs: null,
975
+ triangles: null,
976
+ hullLength: 0,
977
+ r: 1, g: 1, b: 1, a: 1,
978
+ path: null,
979
+ rendererObject: null,
980
+ regionU: 0, regionV: 0, regionU2: 0, regionV2: 0, regionRotate: false,
981
+ regionOffsetX: 0, regionOffsetY: 0,
982
+ regionWidth: 0, regionHeight: 0,
983
+ regionOriginalWidth: 0, regionOriginalHeight: 0,
984
+ edges: null,
985
+ width: 0, height: 0,
986
+ updateUVs: function (u, v, u2, v2, rotate) {
987
+ var width = this.regionU2 - this.regionU, height = this.regionV2 - this.regionV;
988
+ var n = this.regionUVs.length;
989
+ if (!this.uvs || this.uvs.length != n) {
990
+ this.uvs = new spine.Float32Array(n);
991
+ }
992
+ if (this.regionRotate) {
993
+ for (var i = 0; i < n; i += 2) {
994
+ this.uvs[i] = this.regionU + this.regionUVs[i + 1] * width;
995
+ this.uvs[i + 1] = this.regionV + height - this.regionUVs[i] * height;
996
+ }
997
+ } else {
998
+ for (var i = 0; i < n; i += 2) {
999
+ this.uvs[i] = this.regionU + this.regionUVs[i] * width;
1000
+ this.uvs[i + 1] = this.regionV + this.regionUVs[i + 1] * height;
1001
+ }
1002
+ }
1003
+ },
1004
+ computeWorldVertices: function (x, y, slot, worldVertices) {
1005
+ var skeletonBones = slot.bone.skeleton.bones;
1006
+ var weights = this.weights;
1007
+ var bones = this.bones;
1008
+
1009
+ var w = 0, v = 0, b = 0, f = 0, n = bones.length, nn;
1010
+ var wx, wy, bone, vx, vy, weight;
1011
+ if (!slot.attachmentVertices.length) {
1012
+ for (; v < n; w += 2) {
1013
+ wx = 0;
1014
+ wy = 0;
1015
+ nn = bones[v++] + v;
1016
+ for (; v < nn; v++, b += 3) {
1017
+ bone = skeletonBones[bones[v]];
1018
+ vx = weights[b];
1019
+ vy = weights[b + 1];
1020
+ weight = weights[b + 2];
1021
+ wx += (vx * bone.m00 + vy * bone.m01 + bone.worldX) * weight;
1022
+ wy += (vx * bone.m10 + vy * bone.m11 + bone.worldY) * weight;
1023
+ }
1024
+ worldVertices[w] = wx + x;
1025
+ worldVertices[w + 1] = wy + y;
1026
+ }
1027
+ } else {
1028
+ var ffd = slot.attachmentVertices;
1029
+ for (; v < n; w += 2) {
1030
+ wx = 0;
1031
+ wy = 0;
1032
+ nn = bones[v++] + v;
1033
+ for (; v < nn; v++, b += 3, f += 2) {
1034
+ bone = skeletonBones[bones[v]];
1035
+ vx = weights[b] + ffd[f];
1036
+ vy = weights[b + 1] + ffd[f + 1];
1037
+ weight = weights[b + 2];
1038
+ wx += (vx * bone.m00 + vy * bone.m01 + bone.worldX) * weight;
1039
+ wy += (vx * bone.m10 + vy * bone.m11 + bone.worldY) * weight;
1040
+ }
1041
+ worldVertices[w] = wx + x;
1042
+ worldVertices[w + 1] = wy + y;
1043
+ }
1044
+ }
1045
+ }
1046
+ };
1047
+
1048
+ spine.BoundingBoxAttachment = function (name) {
1049
+ this.name = name;
1050
+ this.vertices = [];
1051
+ this["type"] = spine.AttachmentType.boundingBox; //FOR advance mode
1052
+ };
1053
+
1054
+ spine.BoundingBoxAttachment.prototype = {
1055
+ type: spine.AttachmentType.boundingBox,
1056
+ computeWorldVertices: function (x, y, bone, worldVertices) {
1057
+ x += bone.worldX;
1058
+ y += bone.worldY;
1059
+ var m00 = bone.m00;
1060
+ var m01 = bone.m01;
1061
+ var m10 = bone.m10;
1062
+ var m11 = bone.m11;
1063
+ var vertices = this.vertices;
1064
+ for (var i = 0, n = vertices.length; i < n; i += 2) {
1065
+ var px = vertices[i];
1066
+ var py = vertices[i + 1];
1067
+ worldVertices[i] = px * m00 + py * m01 + x;
1068
+ worldVertices[i + 1] = px * m10 + py * m11 + y;
1069
+ }
1070
+ }
1071
+ };
1072
+
1073
+ spine.AnimationStateData = function (skeletonData) {
1074
+ this.skeletonData = skeletonData;
1075
+ this.animationToMixTime = {};
1076
+ };
1077
+ spine.AnimationStateData.prototype = {
1078
+ defaultMix: 0,
1079
+ setMixByName: function (fromName, toName, duration) {
1080
+ var from = this.skeletonData.findAnimation(fromName);
1081
+ if (!from) throw "Animation not found: " + fromName;
1082
+ var to = this.skeletonData.findAnimation(toName);
1083
+ if (!to) throw "Animation not found: " + toName;
1084
+ this.setMix(from, to, duration);
1085
+ },
1086
+ setMix: function (from, to, duration) {
1087
+ this.animationToMixTime[from.name + ":" + to.name] = duration;
1088
+ },
1089
+ getMix: function (from, to) {
1090
+ var time = this.animationToMixTime[from.name + ":" + to.name];
1091
+ return time ? time : this.defaultMix;
1092
+ }
1093
+ };
1094
+
1095
+ spine.TrackEntry = function () {
1096
+ };
1097
+ spine.TrackEntry.prototype = {
1098
+ next: null, previous: null,
1099
+ animation: null,
1100
+ loop: false,
1101
+ delay: 0, time: 0, lastTime: -1, endTime: 0,
1102
+ timeScale: 1,
1103
+ mixTime: 0, mixDuration: 0,
1104
+ onStart: null, onEnd: null, onComplete: null, onEvent: null
1105
+ };
1106
+
1107
+ spine.AnimationState = function (stateData) {
1108
+ this.data = stateData;
1109
+ this.tracks = [];
1110
+ this.events = [];
1111
+ };
1112
+
1113
+ spine.AnimationState.prototype = {
1114
+ onStart: null,
1115
+ onEnd: null,
1116
+ onComplete: null,
1117
+ onEvent: null,
1118
+ timeScale: 1,
1119
+ update: function (delta) {
1120
+ delta *= this.timeScale;
1121
+ for (var i = 0; i < this.tracks.length; i++) {
1122
+ var current = this.tracks[i];
1123
+ if (!current) continue;
1124
+
1125
+ var trackDelta = delta * current.timeScale;
1126
+ current.time += trackDelta;
1127
+ if (current.previous) {
1128
+ current.previous.time += trackDelta;
1129
+ current.mixTime += trackDelta;
1130
+ }
1131
+
1132
+ var next = current.next;
1133
+ if (next) {
1134
+ if (current.lastTime >= next.delay) this.setCurrent(i, next);
1135
+ } else {
1136
+ // End non-looping animation when it reaches its end time and there is no next entry.
1137
+ if (!current.loop && current.lastTime >= current.endTime) this.clearTrack(i);
1138
+ }
1139
+ }
1140
+ },
1141
+ apply: function (skeleton) {
1142
+ for (var i = 0; i < this.tracks.length; i++) {
1143
+ var current = this.tracks[i];
1144
+ if (!current) continue;
1145
+
1146
+ this.events.length = 0;
1147
+
1148
+ var time = current.time;
1149
+ var lastTime = current.lastTime;
1150
+ var endTime = current.endTime;
1151
+ var loop = current.loop;
1152
+ if (!loop && time > endTime) time = endTime;
1153
+
1154
+ var previous = current.previous;
1155
+ if (!previous)
1156
+ current.animation.apply(skeleton, current.lastTime, time, loop, this.events);
1157
+ else {
1158
+ var previousTime = previous.time;
1159
+ if (!previous.loop && previousTime > previous.endTime) previousTime = previous.endTime;
1160
+ previous.animation.apply(skeleton, previousTime, previousTime, previous.loop, null);
1161
+
1162
+ var alpha = current.mixTime / current.mixDuration;
1163
+ if (alpha >= 1) {
1164
+ alpha = 1;
1165
+ current.previous = null;
1166
+ }
1167
+ current.animation.mix(skeleton, current.lastTime, time, loop, this.events, alpha);
1168
+ }
1169
+
1170
+ for (var ii = 0, nn = this.events.length; ii < nn; ii++) {
1171
+ var event = this.events[ii];
1172
+ if (current.onEvent != null) current.onEvent(i, event);
1173
+ if (this.onEvent != null) this.onEvent(i, event);
1174
+ }
1175
+
1176
+ // Check if completed the animation or a loop iteration.
1177
+ if (loop ? (lastTime % endTime > time % endTime) : (lastTime < endTime && time >= endTime)) {
1178
+ var count = Math.floor(time / endTime);
1179
+ if (current.onComplete) current.onComplete(i, count);
1180
+ if (this.onComplete) this.onComplete(i, count);
1181
+ }
1182
+
1183
+ current.lastTime = current.time;
1184
+ }
1185
+ },
1186
+ clearTracks: function () {
1187
+ for (var i = 0, n = this.tracks.length; i < n; i++)
1188
+ this.clearTrack(i);
1189
+ this.tracks.length = 0;
1190
+ },
1191
+ clearTrack: function (trackIndex) {
1192
+ if (trackIndex >= this.tracks.length) return;
1193
+ var current = this.tracks[trackIndex];
1194
+ if (!current) return;
1195
+
1196
+ if (current.onEnd != null) current.onEnd(trackIndex);
1197
+ if (this.onEnd != null) this.onEnd(trackIndex);
1198
+
1199
+ this.tracks[trackIndex] = null;
1200
+ },
1201
+ _expandToIndex: function (index) {
1202
+ if (index < this.tracks.length) return this.tracks[index];
1203
+ while (index >= this.tracks.length)
1204
+ this.tracks.push(null);
1205
+ return null;
1206
+ },
1207
+ setCurrent: function (index, entry) {
1208
+ var current = this._expandToIndex(index);
1209
+ if (current) {
1210
+ var previous = current.previous;
1211
+ current.previous = null;
1212
+
1213
+ if (current.onEnd != null) current.onEnd(index);
1214
+ if (this.onEnd != null) this.onEnd(index);
1215
+
1216
+ entry.mixDuration = this.data.getMix(current.animation, entry.animation);
1217
+ if (entry.mixDuration > 0) {
1218
+ entry.mixTime = 0;
1219
+ // If a mix is in progress, mix from the closest animation.
1220
+ if (previous && current.mixTime / current.mixDuration < 0.5)
1221
+ entry.previous = previous;
1222
+ else
1223
+ entry.previous = current;
1224
+ }
1225
+ }
1226
+
1227
+ this.tracks[index] = entry;
1228
+
1229
+ if (entry.onStart != null) entry.onStart(index);
1230
+ if (this.onStart != null) this.onStart(index);
1231
+ },
1232
+ setAnimationByName: function (trackIndex, animationName, loop) {
1233
+ var animation = this.data.skeletonData.findAnimation(animationName);
1234
+ if (!animation) throw "Animation not found: " + animationName;
1235
+ return this.setAnimation(trackIndex, animation, loop);
1236
+ },
1237
+ /** Set the current animation. Any queued animations are cleared. */
1238
+ setAnimation: function (trackIndex, animation, loop) {
1239
+ var entry = new spine.TrackEntry();
1240
+ entry.animation = animation;
1241
+ entry.loop = loop;
1242
+ entry.endTime = animation.duration;
1243
+ this.setCurrent(trackIndex, entry);
1244
+ return entry;
1245
+ },
1246
+ addAnimationByName: function (trackIndex, animationName, loop, delay) {
1247
+ var animation = this.data.skeletonData.findAnimation(animationName);
1248
+ if (!animation) throw "Animation not found: " + animationName;
1249
+ return this.addAnimation(trackIndex, animation, loop, delay);
1250
+ },
1251
+ /** Adds an animation to be played delay seconds after the current or last queued animation.
1252
+ * @param delay May be <= 0 to use duration of previous animation minus any mix duration plus the negative delay. */
1253
+ addAnimation: function (trackIndex, animation, loop, delay) {
1254
+ var entry = new spine.TrackEntry();
1255
+ entry.animation = animation;
1256
+ entry.loop = loop;
1257
+ entry.endTime = animation.duration;
1258
+
1259
+ var last = this._expandToIndex(trackIndex);
1260
+ if (last) {
1261
+ while (last.next)
1262
+ last = last.next;
1263
+ last.next = entry;
1264
+ } else
1265
+ this.tracks[trackIndex] = entry;
1266
+
1267
+ if (delay <= 0) {
1268
+ if (last)
1269
+ delay += last.endTime - this.data.getMix(last.animation, animation);
1270
+ else
1271
+ delay = 0;
1272
+ }
1273
+ entry.delay = delay;
1274
+
1275
+ return entry;
1276
+ },
1277
+ /** May be null. */
1278
+ getCurrent: function (trackIndex) {
1279
+ if (trackIndex >= this.tracks.length) return null;
1280
+ return this.tracks[trackIndex];
1281
+ }
1282
+ };
1283
+
1284
+ spine.SkeletonJson = function (attachmentLoader) {
1285
+ this.attachmentLoader = attachmentLoader;
1286
+ };
1287
+ spine.SkeletonJson.prototype = {
1288
+ scale: 1,
1289
+ readSkeletonData: function (root, name) {
1290
+ var skeletonData = new spine.SkeletonData();
1291
+ skeletonData.name = name;
1292
+
1293
+ // Skeleton.
1294
+ var skeletonMap = root["skeleton"];
1295
+ if (skeletonMap) {
1296
+ skeletonData.hash = skeletonMap["hash"];
1297
+ skeletonData.version = skeletonMap["spine"];
1298
+ skeletonData.width = skeletonMap["width"] || 0;
1299
+ skeletonData.height = skeletonMap["height"] || 0;
1300
+ }
1301
+
1302
+ // Bones.
1303
+ var bones = root["bones"];
1304
+ for (var i = 0, n = bones.length; i < n; i++) {
1305
+ var boneMap = bones[i];
1306
+ var parent = null;
1307
+ if (boneMap["parent"]) {
1308
+ parent = skeletonData.findBone(boneMap["parent"]);
1309
+ if (!parent) throw "Parent bone not found: " + boneMap["parent"];
1310
+ }
1311
+ var boneData = new spine.BoneData(boneMap["name"], parent);
1312
+ boneData.length = (boneMap["length"] || 0) * this.scale;
1313
+ boneData.x = (boneMap["x"] || 0) * this.scale;
1314
+ boneData.y = (boneMap["y"] || 0) * this.scale;
1315
+ boneData.rotation = (boneMap["rotation"] || 0);
1316
+ boneData.scaleX = boneMap.hasOwnProperty("scaleX") ? boneMap["scaleX"] : 1;
1317
+ boneData.scaleY = boneMap.hasOwnProperty("scaleY") ? boneMap["scaleY"] : 1;
1318
+ boneData.inheritScale = boneMap.hasOwnProperty("inheritScale") ? boneMap["inheritScale"] : true;
1319
+ boneData.inheritRotation = boneMap.hasOwnProperty("inheritRotation") ? boneMap["inheritRotation"] : true;
1320
+ skeletonData.bones.push(boneData);
1321
+ }
1322
+
1323
+ // IK constraints.
1324
+ var ik = root["ik"];
1325
+ if (ik) {
1326
+ for (var i = 0, n = ik.length; i < n; i++) {
1327
+ var ikMap = ik[i];
1328
+ var ikConstraintData = new spine.IkConstraintData(ikMap["name"]);
1329
+
1330
+ var bones = ikMap["bones"];
1331
+ for (var ii = 0, nn = bones.length; ii < nn; ii++) {
1332
+ var bone = skeletonData.findBone(bones[ii]);
1333
+ if (!bone) throw "IK bone not found: " + bones[ii];
1334
+ ikConstraintData.bones.push(bone);
1335
+ }
1336
+
1337
+ ikConstraintData.target = skeletonData.findBone(ikMap["target"]);
1338
+ if (!ikConstraintData.target) throw "Target bone not found: " + ikMap["target"];
1339
+
1340
+ ikConstraintData.bendDirection = (!ikMap.hasOwnProperty("bendPositive") || ikMap["bendPositive"]) ? 1 : -1;
1341
+ ikConstraintData.mix = ikMap.hasOwnProperty("mix") ? ikMap["mix"] : 1;
1342
+
1343
+ skeletonData.ikConstraints.push(ikConstraintData);
1344
+ }
1345
+ }
1346
+
1347
+ // Slots.
1348
+ var slots = root["slots"];
1349
+ for (var i = 0, n = slots.length; i < n; i++) {
1350
+ var slotMap = slots[i];
1351
+ var boneData = skeletonData.findBone(slotMap["bone"]);
1352
+ if (!boneData) throw "Slot bone not found: " + slotMap["bone"];
1353
+ var slotData = new spine.SlotData(slotMap["name"], boneData);
1354
+
1355
+ var color = slotMap["color"];
1356
+ if (color) {
1357
+ slotData.r = this.toColor(color, 0);
1358
+ slotData.g = this.toColor(color, 1);
1359
+ slotData.b = this.toColor(color, 2);
1360
+ slotData.a = this.toColor(color, 3);
1361
+ }
1362
+
1363
+ slotData.attachmentName = slotMap["attachment"];
1364
+ slotData.additiveBlending = slotMap["additive"] && slotMap["additive"] == "true";
1365
+
1366
+ skeletonData.slots.push(slotData);
1367
+ }
1368
+
1369
+ // Skins.
1370
+ var skins = root["skins"];
1371
+ for (var skinName in skins) {
1372
+ if (!skins.hasOwnProperty(skinName)) continue;
1373
+ var skinMap = skins[skinName];
1374
+ var skin = new spine.Skin(skinName);
1375
+ for (var slotName in skinMap) {
1376
+ if (!skinMap.hasOwnProperty(slotName)) continue;
1377
+ var slotIndex = skeletonData.findSlotIndex(slotName);
1378
+ var slotEntry = skinMap[slotName];
1379
+ for (var attachmentName in slotEntry) {
1380
+ if (!slotEntry.hasOwnProperty(attachmentName)) continue;
1381
+ var attachment = this.readAttachment(skin, attachmentName, slotEntry[attachmentName]);
1382
+ if (attachment) skin.addAttachment(slotIndex, attachmentName, attachment);
1383
+ }
1384
+ }
1385
+ skeletonData.skins.push(skin);
1386
+ if (skin.name == "default") skeletonData.defaultSkin = skin;
1387
+ }
1388
+
1389
+ // Events.
1390
+ var events = root["events"];
1391
+ for (var eventName in events) {
1392
+ if (!events.hasOwnProperty(eventName)) continue;
1393
+ var eventMap = events[eventName];
1394
+ var eventData = new spine.EventData(eventName);
1395
+ eventData.intValue = eventMap["int"] || 0;
1396
+ eventData.floatValue = eventMap["float"] || 0;
1397
+ eventData.stringValue = eventMap["string"] || null;
1398
+ skeletonData.events.push(eventData);
1399
+ }
1400
+
1401
+ // Animations.
1402
+ var animations = root["animations"];
1403
+ for (var animationName in animations) {
1404
+ if (!animations.hasOwnProperty(animationName)) continue;
1405
+ this.readAnimation(animationName, animations[animationName], skeletonData);
1406
+ }
1407
+
1408
+ return skeletonData;
1409
+ },
1410
+ readAttachment: function (skin, name, map) {
1411
+ name = map["name"] || name;
1412
+
1413
+ var type = spine.AttachmentType[map["type"] || "region"];
1414
+ var path = map["path"] || name;
1415
+
1416
+ var scale = this.scale;
1417
+ if (type == spine.AttachmentType.region) {
1418
+ var region = this.attachmentLoader.newRegionAttachment(skin, name, path);
1419
+ if (!region) return null;
1420
+ region.path = path;
1421
+ region.x = (map["x"] || 0) * scale;
1422
+ region.y = (map["y"] || 0) * scale;
1423
+ region.scaleX = map.hasOwnProperty("scaleX") ? map["scaleX"] : 1;
1424
+ region.scaleY = map.hasOwnProperty("scaleY") ? map["scaleY"] : 1;
1425
+ region.rotation = map["rotation"] || 0;
1426
+ region.width = (map["width"] || 0) * scale;
1427
+ region.height = (map["height"] || 0) * scale;
1428
+
1429
+ var color = map["color"];
1430
+ if (color) {
1431
+ region.r = this.toColor(color, 0);
1432
+ region.g = this.toColor(color, 1);
1433
+ region.b = this.toColor(color, 2);
1434
+ region.a = this.toColor(color, 3);
1435
+ }
1436
+
1437
+ region.updateOffset();
1438
+ return region;
1439
+ } else if (type == spine.AttachmentType.mesh) {
1440
+ var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);
1441
+ if (!mesh) return null;
1442
+ mesh.path = path;
1443
+ mesh.vertices = this.getFloatArray(map, "vertices", scale);
1444
+ mesh.triangles = this.getIntArray(map, "triangles");
1445
+ mesh.regionUVs = this.getFloatArray(map, "uvs", 1);
1446
+ mesh.updateUVs();
1447
+
1448
+ color = map["color"];
1449
+ if (color) {
1450
+ mesh.r = this.toColor(color, 0);
1451
+ mesh.g = this.toColor(color, 1);
1452
+ mesh.b = this.toColor(color, 2);
1453
+ mesh.a = this.toColor(color, 3);
1454
+ }
1455
+
1456
+ mesh.hullLength = (map["hull"] || 0) * 2;
1457
+ if (map["edges"]) mesh.edges = this.getIntArray(map, "edges");
1458
+ mesh.width = (map["width"] || 0) * scale;
1459
+ mesh.height = (map["height"] || 0) * scale;
1460
+ return mesh;
1461
+ } else if (type == spine.AttachmentType.skinnedmesh) {
1462
+ var mesh = this.attachmentLoader.newSkinnedMeshAttachment(skin, name, path);
1463
+ if (!mesh) return null;
1464
+ mesh.path = path;
1465
+
1466
+ var uvs = this.getFloatArray(map, "uvs", 1);
1467
+ var vertices = this.getFloatArray(map, "vertices", 1);
1468
+ var weights = [];
1469
+ var bones = [];
1470
+ for (var i = 0, n = vertices.length; i < n; ) {
1471
+ var boneCount = vertices[i++] | 0;
1472
+ bones[bones.length] = boneCount;
1473
+ for (var nn = i + boneCount * 4; i < nn; ) {
1474
+ bones[bones.length] = vertices[i];
1475
+ weights[weights.length] = vertices[i + 1] * scale;
1476
+ weights[weights.length] = vertices[i + 2] * scale;
1477
+ weights[weights.length] = vertices[i + 3];
1478
+ i += 4;
1479
+ }
1480
+ }
1481
+ mesh.bones = bones;
1482
+ mesh.weights = weights;
1483
+ mesh.triangles = this.getIntArray(map, "triangles");
1484
+ mesh.regionUVs = uvs;
1485
+ mesh.updateUVs();
1486
+
1487
+ color = map["color"];
1488
+ if (color) {
1489
+ mesh.r = this.toColor(color, 0);
1490
+ mesh.g = this.toColor(color, 1);
1491
+ mesh.b = this.toColor(color, 2);
1492
+ mesh.a = this.toColor(color, 3);
1493
+ }
1494
+
1495
+ mesh.hullLength = (map["hull"] || 0) * 2;
1496
+ if (map["edges"]) mesh.edges = this.getIntArray(map, "edges");
1497
+ mesh.width = (map["width"] || 0) * scale;
1498
+ mesh.height = (map["height"] || 0) * scale;
1499
+ return mesh;
1500
+ } else if (type == spine.AttachmentType.boundingbox) {
1501
+ var attachment = this.attachmentLoader.newBoundingBoxAttachment(skin, name);
1502
+ var vertices = map["vertices"];
1503
+ for (var i = 0, n = vertices.length; i < n; i++)
1504
+ attachment.vertices.push(vertices[i] * scale);
1505
+ return attachment;
1506
+ }
1507
+ throw "Unknown attachment type: " + type;
1508
+ },
1509
+ readAnimation: function (name, map, skeletonData) {
1510
+ var timelines = [];
1511
+ var duration = 0;
1512
+
1513
+ var slots = map["slots"];
1514
+ for (var slotName in slots) {
1515
+ if (!slots.hasOwnProperty(slotName)) continue;
1516
+ var slotMap = slots[slotName];
1517
+ var slotIndex = skeletonData.findSlotIndex(slotName);
1518
+
1519
+ for (var timelineName in slotMap) {
1520
+ if (!slotMap.hasOwnProperty(timelineName)) continue;
1521
+ var values = slotMap[timelineName];
1522
+ if (timelineName == "color") {
1523
+ var timeline = new spine.ColorTimeline(values.length);
1524
+ timeline.slotIndex = slotIndex;
1525
+
1526
+ var frameIndex = 0;
1527
+ for (var i = 0, n = values.length; i < n; i++) {
1528
+ var valueMap = values[i];
1529
+ var color = valueMap["color"];
1530
+ var r = this.toColor(color, 0);
1531
+ var g = this.toColor(color, 1);
1532
+ var b = this.toColor(color, 2);
1533
+ var a = this.toColor(color, 3);
1534
+ timeline.setFrame(frameIndex, valueMap["time"], r, g, b, a);
1535
+ this.readCurve(timeline, frameIndex, valueMap);
1536
+ frameIndex++;
1537
+ }
1538
+ timelines.push(timeline);
1539
+ duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 5 - 5]);
1540
+
1541
+ } else if (timelineName == "attachment") {
1542
+ var timeline = new spine.AttachmentTimeline(values.length);
1543
+ timeline.slotIndex = slotIndex;
1544
+
1545
+ var frameIndex = 0;
1546
+ for (var i = 0, n = values.length; i < n; i++) {
1547
+ var valueMap = values[i];
1548
+ timeline.setFrame(frameIndex++, valueMap["time"], valueMap["name"]);
1549
+ }
1550
+ timelines.push(timeline);
1551
+ duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
1552
+
1553
+ } else
1554
+ throw "Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")";
1555
+ }
1556
+ }
1557
+
1558
+ var bones = map["bones"];
1559
+ for (var boneName in bones) {
1560
+ if (!bones.hasOwnProperty(boneName)) continue;
1561
+ var boneIndex = skeletonData.findBoneIndex(boneName);
1562
+ if (boneIndex == -1) throw "Bone not found: " + boneName;
1563
+ var boneMap = bones[boneName];
1564
+
1565
+ for (var timelineName in boneMap) {
1566
+ if (!boneMap.hasOwnProperty(timelineName)) continue;
1567
+ var values = boneMap[timelineName];
1568
+ if (timelineName == "rotate") {
1569
+ var timeline = new spine.RotateTimeline(values.length);
1570
+ timeline.boneIndex = boneIndex;
1571
+
1572
+ var frameIndex = 0;
1573
+ for (var i = 0, n = values.length; i < n; i++) {
1574
+ var valueMap = values[i];
1575
+ timeline.setFrame(frameIndex, valueMap["time"], valueMap["angle"]);
1576
+ this.readCurve(timeline, frameIndex, valueMap);
1577
+ frameIndex++;
1578
+ }
1579
+ timelines.push(timeline);
1580
+ duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 2 - 2]);
1581
+
1582
+ } else if (timelineName == "translate" || timelineName == "scale") {
1583
+ var timeline;
1584
+ var timelineScale = 1;
1585
+ if (timelineName == "scale")
1586
+ timeline = new spine.ScaleTimeline(values.length);
1587
+ else {
1588
+ timeline = new spine.TranslateTimeline(values.length);
1589
+ timelineScale = this.scale;
1590
+ }
1591
+ timeline.boneIndex = boneIndex;
1592
+
1593
+ var frameIndex = 0;
1594
+ for (var i = 0, n = values.length; i < n; i++) {
1595
+ var valueMap = values[i];
1596
+ var x = (valueMap["x"] || 0) * timelineScale;
1597
+ var y = (valueMap["y"] || 0) * timelineScale;
1598
+ timeline.setFrame(frameIndex, valueMap["time"], x, y);
1599
+ this.readCurve(timeline, frameIndex, valueMap);
1600
+ frameIndex++;
1601
+ }
1602
+ timelines.push(timeline);
1603
+ duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 3 - 3]);
1604
+
1605
+ } else if (timelineName == "flipX" || timelineName == "flipY") {
1606
+ var x = timelineName == "flipX";
1607
+ var timeline = x ? new spine.FlipXTimeline(values.length) : new spine.FlipYTimeline(values.length);
1608
+ timeline.boneIndex = boneIndex;
1609
+
1610
+ var field = x ? "x" : "y";
1611
+ var frameIndex = 0;
1612
+ for (var i = 0, n = values.length; i < n; i++) {
1613
+ var valueMap = values[i];
1614
+ timeline.setFrame(frameIndex, valueMap["time"], valueMap[field] || false);
1615
+ frameIndex++;
1616
+ }
1617
+ timelines.push(timeline);
1618
+ duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 2 - 2]);
1619
+ } else
1620
+ throw "Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")";
1621
+ }
1622
+ }
1623
+
1624
+ var ikMap = map["ik"];
1625
+ for (var ikConstraintName in ikMap) {
1626
+ if (!ikMap.hasOwnProperty(ikConstraintName)) continue;
1627
+ var ikConstraint = skeletonData.findIkConstraint(ikConstraintName);
1628
+ var values = ikMap[ikConstraintName];
1629
+ var timeline = new spine.IkConstraintTimeline(values.length);
1630
+ timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(ikConstraint);
1631
+ var frameIndex = 0;
1632
+ for (var i = 0, n = values.length; i < n; i++) {
1633
+ var valueMap = values[i];
1634
+ var mix = valueMap.hasOwnProperty("mix") ? valueMap["mix"] : 1;
1635
+ var bendDirection = (!valueMap.hasOwnProperty("bendPositive") || valueMap["bendPositive"]) ? 1 : -1;
1636
+ timeline.setFrame(frameIndex, valueMap["time"], mix, bendDirection);
1637
+ this.readCurve(timeline, frameIndex, valueMap);
1638
+ frameIndex++;
1639
+ }
1640
+ timelines.push(timeline);
1641
+ duration = Math.max(duration, timeline.frames[timeline.frameCount * 3 - 3]);
1642
+ }
1643
+
1644
+ var ffd = map["ffd"];
1645
+ for (var skinName in ffd) {
1646
+ var skin = skeletonData.findSkin(skinName);
1647
+ var slotMap = ffd[skinName];
1648
+ for (slotName in slotMap) {
1649
+ var slotIndex = skeletonData.findSlotIndex(slotName);
1650
+ var meshMap = slotMap[slotName];
1651
+ for (var meshName in meshMap) {
1652
+ var values = meshMap[meshName];
1653
+ var timeline = new spine.FfdTimeline(values.length);
1654
+ var attachment = skin.getAttachment(slotIndex, meshName);
1655
+ if (!attachment) throw "FFD attachment not found: " + meshName;
1656
+ timeline.slotIndex = slotIndex;
1657
+ timeline.attachment = attachment;
1658
+
1659
+ var isMesh = attachment.type == spine.AttachmentType.mesh;
1660
+ var vertexCount;
1661
+ if (isMesh)
1662
+ vertexCount = attachment.vertices.length;
1663
+ else
1664
+ vertexCount = attachment.weights.length / 3 * 2;
1665
+
1666
+ var frameIndex = 0;
1667
+ for (var i = 0, n = values.length; i < n; i++) {
1668
+ var valueMap = values[i];
1669
+ var vertices;
1670
+ if (!valueMap["vertices"]) {
1671
+ if (isMesh)
1672
+ vertices = attachment.vertices;
1673
+ else {
1674
+ vertices = [];
1675
+ vertices.length = vertexCount;
1676
+ }
1677
+ } else {
1678
+ var verticesValue = valueMap["vertices"];
1679
+ var vertices = [];
1680
+ vertices.length = vertexCount;
1681
+ var start = valueMap["offset"] || 0;
1682
+ var nn = verticesValue.length;
1683
+ if (this.scale == 1) {
1684
+ for (var ii = 0; ii < nn; ii++)
1685
+ vertices[ii + start] = verticesValue[ii];
1686
+ } else {
1687
+ for (var ii = 0; ii < nn; ii++)
1688
+ vertices[ii + start] = verticesValue[ii] * this.scale;
1689
+ }
1690
+ if (isMesh) {
1691
+ var meshVertices = attachment.vertices;
1692
+ for (var ii = 0, nn = vertices.length; ii < nn; ii++)
1693
+ vertices[ii] += meshVertices[ii];
1694
+ }
1695
+ }
1696
+
1697
+ timeline.setFrame(frameIndex, valueMap["time"], vertices);
1698
+ this.readCurve(timeline, frameIndex, valueMap);
1699
+ frameIndex++;
1700
+ }
1701
+ timelines[timelines.length] = timeline;
1702
+ duration = Math.max(duration, timeline.frames[timeline.frameCount - 1]);
1703
+ }
1704
+ }
1705
+ }
1706
+
1707
+ var drawOrderValues = map["drawOrder"];
1708
+ if (!drawOrderValues) drawOrderValues = map["draworder"];
1709
+ if (drawOrderValues) {
1710
+ var timeline = new spine.DrawOrderTimeline(drawOrderValues.length);
1711
+ var slotCount = skeletonData.slots.length;
1712
+ var frameIndex = 0;
1713
+ for (var i = 0, n = drawOrderValues.length; i < n; i++) {
1714
+ var drawOrderMap = drawOrderValues[i];
1715
+ var drawOrder = null;
1716
+ if (drawOrderMap["offsets"]) {
1717
+ drawOrder = [];
1718
+ drawOrder.length = slotCount;
1719
+ for (var ii = slotCount - 1; ii >= 0; ii--)
1720
+ drawOrder[ii] = -1;
1721
+ var offsets = drawOrderMap["offsets"];
1722
+ var unchanged = [];
1723
+ unchanged.length = slotCount - offsets.length;
1724
+ var originalIndex = 0, unchangedIndex = 0;
1725
+ for (var ii = 0, nn = offsets.length; ii < nn; ii++) {
1726
+ var offsetMap = offsets[ii];
1727
+ var slotIndex = skeletonData.findSlotIndex(offsetMap["slot"]);
1728
+ if (slotIndex == -1) throw "Slot not found: " + offsetMap["slot"];
1729
+ // Collect unchanged items.
1730
+ while (originalIndex != slotIndex)
1731
+ unchanged[unchangedIndex++] = originalIndex++;
1732
+ // Set changed items.
1733
+ drawOrder[originalIndex + offsetMap["offset"]] = originalIndex++;
1734
+ }
1735
+ // Collect remaining unchanged items.
1736
+ while (originalIndex < slotCount)
1737
+ unchanged[unchangedIndex++] = originalIndex++;
1738
+ // Fill in unchanged items.
1739
+ for (var ii = slotCount - 1; ii >= 0; ii--)
1740
+ if (drawOrder[ii] == -1) drawOrder[ii] = unchanged[--unchangedIndex];
1741
+ }
1742
+ timeline.setFrame(frameIndex++, drawOrderMap["time"], drawOrder);
1743
+ }
1744
+ timelines.push(timeline);
1745
+ duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
1746
+ }
1747
+
1748
+ var events = map["events"];
1749
+ if (events) {
1750
+ var timeline = new spine.EventTimeline(events.length);
1751
+ var frameIndex = 0;
1752
+ for (var i = 0, n = events.length; i < n; i++) {
1753
+ var eventMap = events[i];
1754
+ var eventData = skeletonData.findEvent(eventMap["name"]);
1755
+ if (!eventData) throw "Event not found: " + eventMap["name"];
1756
+ var event = new spine.Event(eventData);
1757
+ event.intValue = eventMap.hasOwnProperty("int") ? eventMap["int"] : eventData.intValue;
1758
+ event.floatValue = eventMap.hasOwnProperty("float") ? eventMap["float"] : eventData.floatValue;
1759
+ event.stringValue = eventMap.hasOwnProperty("string") ? eventMap["string"] : eventData.stringValue;
1760
+ timeline.setFrame(frameIndex++, eventMap["time"], event);
1761
+ }
1762
+ timelines.push(timeline);
1763
+ duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);
1764
+ }
1765
+
1766
+ skeletonData.animations.push(new spine.Animation(name, timelines, duration));
1767
+ },
1768
+ readCurve: function (timeline, frameIndex, valueMap) {
1769
+ var curve = valueMap["curve"];
1770
+ if (!curve)
1771
+ timeline.curves.setLinear(frameIndex);
1772
+ else if (curve == "stepped")
1773
+ timeline.curves.setStepped(frameIndex);
1774
+ else if (curve instanceof Array)
1775
+ timeline.curves.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]);
1776
+ },
1777
+ toColor: function (hexString, colorIndex) {
1778
+ if (hexString.length != 8) throw "Color hexidecimal length must be 8, recieved: " + hexString;
1779
+ return parseInt(hexString.substring(colorIndex * 2, (colorIndex * 2) + 2), 16) / 255;
1780
+ },
1781
+ getFloatArray: function (map, name, scale) {
1782
+ var list = map[name];
1783
+ var values = new spine.Float32Array(list.length);
1784
+ var i = 0, n = list.length;
1785
+ if (scale == 1) {
1786
+ for (; i < n; i++)
1787
+ values[i] = list[i];
1788
+ } else {
1789
+ for (; i < n; i++)
1790
+ values[i] = list[i] * scale;
1791
+ }
1792
+ return values;
1793
+ },
1794
+ getIntArray: function (map, name) {
1795
+ var list = map[name];
1796
+ var values = new spine.Uint16Array(list.length);
1797
+ for (var i = 0, n = list.length; i < n; i++)
1798
+ values[i] = list[i] | 0;
1799
+ return values;
1800
+ }
1801
+ };
1802
+
1803
+ spine.SkeletonJson.readCurve = function (timeline, frameIndex, valueMap) {
1804
+ var curve = valueMap["curve"];
1805
+ if (!curve) return;
1806
+ if (curve == "stepped")
1807
+ timeline.curves.setStepped(frameIndex);
1808
+ else if (curve instanceof Array)
1809
+ timeline.curves.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]);
1810
+ };
1811
+
1812
+ spine.SkeletonJson.toColor = function (hexString, colorIndex) {
1813
+ if (hexString.length != 8) throw "Color hexidecimal length must be 8, recieved: " + hexString;
1814
+ return parseInt(hexString.substring(colorIndex * 2, (colorIndex * 2) + 2), 16) / 255;
1815
+ };
1816
+
1817
+ spine.Atlas = function (atlasText, textureLoader) {
1818
+ this.textureLoader = textureLoader;
1819
+ this.pages = [];
1820
+ this.regions = [];
1821
+
1822
+ var reader = new spine.AtlasReader(atlasText);
1823
+ var tuple = [];
1824
+ tuple.length = 4;
1825
+ var page = null;
1826
+ while (true) {
1827
+ var line = reader.readLine();
1828
+ if (line === null) break;
1829
+ line = reader.trim(line);
1830
+ if (!line.length)
1831
+ page = null;
1832
+ else if (!page) {
1833
+ page = new spine.AtlasPage();
1834
+ page.name = line;
1835
+
1836
+ if (reader.readTuple(tuple) == 2) { // size is only optional for an atlas packed with an old TexturePacker.
1837
+ page.width = parseInt(tuple[0]);
1838
+ page.height = parseInt(tuple[1]);
1839
+ reader.readTuple(tuple);
1840
+ }
1841
+ page.format = spine.Atlas.Format[tuple[0]];
1842
+
1843
+ reader.readTuple(tuple);
1844
+ page.minFilter = spine.Atlas.TextureFilter[tuple[0]];
1845
+ page.magFilter = spine.Atlas.TextureFilter[tuple[1]];
1846
+
1847
+ var direction = reader.readValue();
1848
+ page.uWrap = spine.Atlas.TextureWrap.clampToEdge;
1849
+ page.vWrap = spine.Atlas.TextureWrap.clampToEdge;
1850
+ if (direction == "x")
1851
+ page.uWrap = spine.Atlas.TextureWrap.repeat;
1852
+ else if (direction == "y")
1853
+ page.vWrap = spine.Atlas.TextureWrap.repeat;
1854
+ else if (direction == "xy")
1855
+ page.uWrap = page.vWrap = spine.Atlas.TextureWrap.repeat;
1856
+
1857
+ textureLoader.load(page, line, this);
1858
+
1859
+ this.pages.push(page);
1860
+
1861
+ } else {
1862
+ var region = new spine.AtlasRegion();
1863
+ region.name = line;
1864
+ region.page = page;
1865
+
1866
+ region.rotate = reader.readValue() == "true";
1867
+
1868
+ reader.readTuple(tuple);
1869
+ var x = parseInt(tuple[0]);
1870
+ var y = parseInt(tuple[1]);
1871
+
1872
+ reader.readTuple(tuple);
1873
+ var width = parseInt(tuple[0]);
1874
+ var height = parseInt(tuple[1]);
1875
+
1876
+ region.u = x / page.width;
1877
+ region.v = y / page.height;
1878
+ if (region.rotate) {
1879
+ region.u2 = (x + height) / page.width;
1880
+ region.v2 = (y + width) / page.height;
1881
+ } else {
1882
+ region.u2 = (x + width) / page.width;
1883
+ region.v2 = (y + height) / page.height;
1884
+ }
1885
+ region.x = x;
1886
+ region.y = y;
1887
+ region.width = Math.abs(width);
1888
+ region.height = Math.abs(height);
1889
+
1890
+ if (reader.readTuple(tuple) == 4) { // split is optional
1891
+ region.splits = [parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])];
1892
+
1893
+ if (reader.readTuple(tuple) == 4) { // pad is optional, but only present with splits
1894
+ region.pads = [parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])];
1895
+
1896
+ reader.readTuple(tuple);
1897
+ }
1898
+ }
1899
+
1900
+ region.originalWidth = parseInt(tuple[0]);
1901
+ region.originalHeight = parseInt(tuple[1]);
1902
+
1903
+ reader.readTuple(tuple);
1904
+ region.offsetX = parseInt(tuple[0]);
1905
+ region.offsetY = parseInt(tuple[1]);
1906
+
1907
+ region.index = parseInt(reader.readValue());
1908
+
1909
+ this.regions.push(region);
1910
+ }
1911
+ }
1912
+ };
1913
+ spine.Atlas.prototype = {
1914
+ findRegion: function (name) {
1915
+ var regions = this.regions;
1916
+ for (var i = 0, n = regions.length; i < n; i++)
1917
+ if (regions[i].name == name) return regions[i];
1918
+ return null;
1919
+ },
1920
+ dispose: function () {
1921
+ var pages = this.pages;
1922
+ for (var i = 0, n = pages.length; i < n; i++)
1923
+ this.textureLoader.unload(pages[i].rendererObject);
1924
+ },
1925
+ updateUVs: function (page) {
1926
+ var regions = this.regions;
1927
+ for (var i = 0, n = regions.length; i < n; i++) {
1928
+ var region = regions[i];
1929
+ if (region.page != page) continue;
1930
+ region.u = region.x / page.width;
1931
+ region.v = region.y / page.height;
1932
+ if (region.rotate) {
1933
+ region.u2 = (region.x + region.height) / page.width;
1934
+ region.v2 = (region.y + region.width) / page.height;
1935
+ } else {
1936
+ region.u2 = (region.x + region.width) / page.width;
1937
+ region.v2 = (region.y + region.height) / page.height;
1938
+ }
1939
+ }
1940
+ }
1941
+ };
1942
+
1943
+ spine.Atlas.Format = {
1944
+ Alpha: 0,
1945
+ Intensity: 1,
1946
+ LuminanceAlpha: 2,
1947
+ RGB565: 3,
1948
+ RGBA4444: 4,
1949
+ RGB888: 5,
1950
+ RGBA8888: 6
1951
+ };
1952
+
1953
+ spine.Atlas.TextureFilter = {
1954
+ Nearest: 0,
1955
+ Linear: 1,
1956
+ MipMap: 2,
1957
+ MipMapNearestNearest: 3,
1958
+ MipMapLinearNearest: 4,
1959
+ MipMapNearestLinear: 5,
1960
+ MipMapLinearLinear: 6
1961
+ };
1962
+
1963
+ spine.Atlas.TextureWrap = {
1964
+ mirroredRepeat: 0,
1965
+ clampToEdge: 1,
1966
+ repeat: 2
1967
+ };
1968
+
1969
+ spine.AtlasPage = function () {
1970
+ };
1971
+ spine.AtlasPage.prototype = {
1972
+ name: null,
1973
+ format: null,
1974
+ minFilter: null,
1975
+ magFilter: null,
1976
+ uWrap: null,
1977
+ vWrap: null,
1978
+ rendererObject: null,
1979
+ width: 0,
1980
+ height: 0
1981
+ };
1982
+
1983
+ spine.AtlasRegion = function () {
1984
+ };
1985
+ spine.AtlasRegion.prototype = {
1986
+ page: null,
1987
+ name: null,
1988
+ x: 0, y: 0,
1989
+ width: 0, height: 0,
1990
+ u: 0, v: 0, u2: 0, v2: 0,
1991
+ offsetX: 0, offsetY: 0,
1992
+ originalWidth: 0, originalHeight: 0,
1993
+ index: 0,
1994
+ rotate: false,
1995
+ splits: null,
1996
+ pads: null
1997
+ };
1998
+
1999
+ spine.AtlasReader = function (text) {
2000
+ this.lines = text.split(/\r\n|\r|\n/);
2001
+ };
2002
+ spine.AtlasReader.prototype = {
2003
+ index: 0,
2004
+ trim: function (value) {
2005
+ return value.replace(/^\s+|\s+$/g, "");
2006
+ },
2007
+ readLine: function () {
2008
+ if (this.index >= this.lines.length) return null;
2009
+ return this.lines[this.index++];
2010
+ },
2011
+ readValue: function () {
2012
+ var line = this.readLine();
2013
+ var colon = line.indexOf(":");
2014
+ if (colon == -1) throw "Invalid line: " + line;
2015
+ return this.trim(line.substring(colon + 1));
2016
+ },
2017
+ /** Returns the number of tuple values read (1, 2 or 4). */
2018
+ readTuple: function (tuple) {
2019
+ var line = this.readLine();
2020
+ var colon = line.indexOf(":");
2021
+ if (colon == -1) throw "Invalid line: " + line;
2022
+ var i = 0, lastMatch = colon + 1;
2023
+ for (; i < 3; i++) {
2024
+ var comma = line.indexOf(",", lastMatch);
2025
+ if (comma == -1) break;
2026
+ tuple[i] = this.trim(line.substr(lastMatch, comma - lastMatch));
2027
+ lastMatch = comma + 1;
2028
+ }
2029
+ tuple[i] = this.trim(line.substring(lastMatch));
2030
+ return i + 1;
2031
+ }
2032
+ };
2033
+
2034
+ spine.AtlasAttachmentLoader = function (atlas) {
2035
+ this.atlas = atlas;
2036
+ };
2037
+ spine.AtlasAttachmentLoader.prototype = {
2038
+ newRegionAttachment: function (skin, name, path) {
2039
+ var region = this.atlas.findRegion(name);
2040
+ if (!region) throw "Region not found in atlas: " + path + " (region attachment: " + name + ")";
2041
+ var attachment = new spine.RegionAttachment(name);
2042
+ attachment.rendererObject = region;
2043
+ attachment.setUVs(region.u, region.v, region.u2, region.v2, region.rotate);
2044
+ attachment.regionOffsetX = region.offsetX;
2045
+ attachment.regionOffsetY = region.offsetY;
2046
+ attachment.regionWidth = region.width;
2047
+ attachment.regionHeight = region.height;
2048
+ attachment.regionOriginalWidth = region.originalWidth;
2049
+ attachment.regionOriginalHeight = region.originalHeight;
2050
+ return attachment;
2051
+ },
2052
+ newMeshAttachment: function (skin, name, path) {
2053
+ var region = this.atlas.findRegion(name);
2054
+ if (!region) throw "Region not found in atlas: " + path + " (mesh attachment: " + name + ")";
2055
+ var attachment = new spine.MeshAttachment(name);
2056
+ attachment.rendererObject = region;
2057
+ attachment.regionU = region.u;
2058
+ attachment.regionV = region.v;
2059
+ attachment.regionU2 = region.u2;
2060
+ attachment.regionV2 = region.v2;
2061
+ attachment.regionRotate = region.rotate;
2062
+ attachment.regionOffsetX = region.offsetX;
2063
+ attachment.regionOffsetY = region.offsetY;
2064
+ attachment.regionWidth = region.width;
2065
+ attachment.regionHeight = region.height;
2066
+ attachment.regionOriginalWidth = region.originalWidth;
2067
+ attachment.regionOriginalHeight = region.originalHeight;
2068
+ return attachment;
2069
+ },
2070
+ newSkinnedMeshAttachment: function (skin, name, path) {
2071
+ var region = this.atlas.findRegion(name);
2072
+ if (!region) throw "Region not found in atlas: " + path + " (skinned mesh attachment: " + name + ")";
2073
+ var attachment = new spine.SkinnedMeshAttachment(name);
2074
+ attachment.rendererObject = region;
2075
+ attachment.regionU = region.u;
2076
+ attachment.regionV = region.v;
2077
+ attachment.regionU2 = region.u2;
2078
+ attachment.regionV2 = region.v2;
2079
+ attachment.regionRotate = region.rotate;
2080
+ attachment.regionOffsetX = region.offsetX;
2081
+ attachment.regionOffsetY = region.offsetY;
2082
+ attachment.regionWidth = region.width;
2083
+ attachment.regionHeight = region.height;
2084
+ attachment.regionOriginalWidth = region.originalWidth;
2085
+ attachment.regionOriginalHeight = region.originalHeight;
2086
+ return attachment;
2087
+ },
2088
+ newBoundingBoxAttachment: function (skin, name) {
2089
+ return new spine.BoundingBoxAttachment(name);
2090
+ }
2091
+ };
2092
+
2093
+ spine.SkeletonBounds = function () {
2094
+ this.polygonPool = [];
2095
+ this.polygons = [];
2096
+ this.boundingBoxes = [];
2097
+ };
2098
+ spine.SkeletonBounds.prototype = {
2099
+ minX: 0, minY: 0, maxX: 0, maxY: 0,
2100
+ update: function (skeleton, updateAabb) {
2101
+ var slots = skeleton.slots;
2102
+ var slotCount = slots.length;
2103
+ var x = skeleton.x, y = skeleton.y;
2104
+ var boundingBoxes = this.boundingBoxes;
2105
+ var polygonPool = this.polygonPool;
2106
+ var polygons = this.polygons;
2107
+
2108
+ boundingBoxes.length = 0;
2109
+ for (var i = 0, n = polygons.length; i < n; i++)
2110
+ polygonPool.push(polygons[i]);
2111
+ polygons.length = 0;
2112
+
2113
+ for (var i = 0; i < slotCount; i++) {
2114
+ var slot = slots[i];
2115
+ var boundingBox = slot.attachment;
2116
+ if (boundingBox.type != spine.AttachmentType.boundingBox) continue;
2117
+ boundingBoxes.push(boundingBox);
2118
+
2119
+ var poolCount = polygonPool.length, polygon;
2120
+ if (poolCount > 0) {
2121
+ polygon = polygonPool[poolCount - 1];
2122
+ polygonPool.splice(poolCount - 1, 1);
2123
+ } else
2124
+ polygon = [];
2125
+ polygons.push(polygon);
2126
+
2127
+ polygon.length = boundingBox.vertices.length;
2128
+ boundingBox.computeWorldVertices(x, y, slot.bone, polygon);
2129
+ }
2130
+
2131
+ if (updateAabb) this.aabbCompute();
2132
+ },
2133
+ aabbCompute: function () {
2134
+ var polygons = this.polygons;
2135
+ var minX = Number.MAX_VALUE, minY = Number.MAX_VALUE, maxX = Number.MIN_VALUE, maxY = Number.MIN_VALUE;
2136
+ for (var i = 0, n = polygons.length; i < n; i++) {
2137
+ var vertices = polygons[i];
2138
+ for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {
2139
+ var x = vertices[ii];
2140
+ var y = vertices[ii + 1];
2141
+ minX = Math.min(minX, x);
2142
+ minY = Math.min(minY, y);
2143
+ maxX = Math.max(maxX, x);
2144
+ maxY = Math.max(maxY, y);
2145
+ }
2146
+ }
2147
+ this.minX = minX;
2148
+ this.minY = minY;
2149
+ this.maxX = maxX;
2150
+ this.maxY = maxY;
2151
+ },
2152
+ /** Returns true if the axis aligned bounding box contains the point. */
2153
+ aabbContainsPoint: function (x, y) {
2154
+ return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY;
2155
+ },
2156
+ /** Returns true if the axis aligned bounding box intersects the line segment. */
2157
+ aabbIntersectsSegment: function (x1, y1, x2, y2) {
2158
+ var minX = this.minX, minY = this.minY, maxX = this.maxX, maxY = this.maxY;
2159
+ if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY))
2160
+ return false;
2161
+ var m = (y2 - y1) / (x2 - x1);
2162
+ var y = m * (minX - x1) + y1;
2163
+ if (y > minY && y < maxY) return true;
2164
+ y = m * (maxX - x1) + y1;
2165
+ if (y > minY && y < maxY) return true;
2166
+ var x = (minY - y1) / m + x1;
2167
+ if (x > minX && x < maxX) return true;
2168
+ x = (maxY - y1) / m + x1;
2169
+ if (x > minX && x < maxX) return true;
2170
+ return false;
2171
+ },
2172
+ /** Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds. */
2173
+ aabbIntersectsSkeleton: function (bounds) {
2174
+ return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY;
2175
+ },
2176
+ /** Returns the first bounding box attachment that contains the point, or null. When doing many checks, it is usually more
2177
+ * efficient to only call this method if {@link #aabbContainsPoint(float, float)} returns true. */
2178
+ containsPoint: function (x, y) {
2179
+ var polygons = this.polygons;
2180
+ for (var i = 0, n = polygons.length; i < n; i++)
2181
+ if (this.polygonContainsPoint(polygons[i], x, y)) return this.boundingBoxes[i];
2182
+ return null;
2183
+ },
2184
+ /** Returns the first bounding box attachment that contains the line segment, or null. When doing many checks, it is usually
2185
+ * more efficient to only call this method if {@link #aabbIntersectsSegment(float, float, float, float)} returns true. */
2186
+ intersectsSegment: function (x1, y1, x2, y2) {
2187
+ var polygons = this.polygons;
2188
+ for (var i = 0, n = polygons.length; i < n; i++)
2189
+ if (polygons[i].intersectsSegment(x1, y1, x2, y2)) return this.boundingBoxes[i];
2190
+ return null;
2191
+ },
2192
+ /** Returns true if the polygon contains the point. */
2193
+ polygonContainsPoint: function (polygon, x, y) {
2194
+ var nn = polygon.length;
2195
+ var prevIndex = nn - 2;
2196
+ var inside = false;
2197
+ for (var ii = 0; ii < nn; ii += 2) {
2198
+ var vertexY = polygon[ii + 1];
2199
+ var prevY = polygon[prevIndex + 1];
2200
+ if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) {
2201
+ var vertexX = polygon[ii];
2202
+ if (vertexX + (y - vertexY) / (prevY - vertexY) * (polygon[prevIndex] - vertexX) < x) inside = !inside;
2203
+ }
2204
+ prevIndex = ii;
2205
+ }
2206
+ return inside;
2207
+ },
2208
+ /** Returns true if the polygon contains the line segment. */
2209
+ intersectsSegment: function (polygon, x1, y1, x2, y2) {
2210
+ var nn = polygon.length;
2211
+ var width12 = x1 - x2, height12 = y1 - y2;
2212
+ var det1 = x1 * y2 - y1 * x2;
2213
+ var x3 = polygon[nn - 2], y3 = polygon[nn - 1];
2214
+ for (var ii = 0; ii < nn; ii += 2) {
2215
+ var x4 = polygon[ii], y4 = polygon[ii + 1];
2216
+ var det2 = x3 * y4 - y3 * x4;
2217
+ var width34 = x3 - x4, height34 = y3 - y4;
2218
+ var det3 = width12 * height34 - height12 * width34;
2219
+ var x = (det1 * width34 - width12 * det2) / det3;
2220
+ if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) {
2221
+ var y = (det1 * height34 - height12 * det2) / det3;
2222
+ if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) return true;
2223
+ }
2224
+ x3 = x4;
2225
+ y3 = y4;
2226
+ }
2227
+ return false;
2228
+ },
2229
+ getPolygon: function (attachment) {
2230
+ var index = this.boundingBoxes.indexOf(attachment);
2231
+ return index == -1 ? null : this.polygons[index];
2232
+ },
2233
+ getWidth: function () {
2234
+ return this.maxX - this.minX;
2235
+ },
2236
+ getHeight: function () {
2237
+ return this.maxY - this.minY;
2238
+ }
2239
+ };