ccb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +31 -0
- data/bin/ccb +4 -0
- data/lib/ccb/builder/project_builder.rb +14 -0
- data/lib/ccb/builder/scene_builder.rb +9 -0
- data/lib/ccb/builder/templates/project/GameConfig.js.tt +21 -0
- data/lib/ccb/builder/templates/project/_cocos-project.json +4 -0
- data/lib/ccb/builder/templates/project/folder/CMakeLists.txt +295 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/Base64Images.js +32 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/CCBoot.js +2271 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/CCDebugger.js +336 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCAction.js +694 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionCamera.js +293 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionCatmullRom.js +605 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionEase.js +3681 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionInstant.js +757 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionInterval.js +3554 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionTween.js +166 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionGrid.js +372 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionGrid3D.js +1257 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionPageTurn3D.js +113 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionTiledGrid.js +1289 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/audio/CCAudio.js +1024 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/clipping-nodes/CCClippingNode.js +224 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js +227 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js +226 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/ZipUtils.js +82 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/base64.js +95 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/gzip.js +731 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/zlib.min.js +55 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCActionManager.js +378 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCCamera.js +290 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCConfiguration.js +294 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDirector.js +1019 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDirectorWebGL.js +329 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDrawingPrimitivesCanvas.js +438 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDrawingPrimitivesWebGL.js +464 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCScheduler.js +744 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js +127 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCAtlasNode.js +294 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js +138 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js +145 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCNode.js +2386 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +504 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +254 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/cocoa/CCAffineTransform.js +259 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/cocoa/CCGeometry.js +327 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEvent.js +449 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEventExtension.js +126 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEventListener.js +519 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEventManager.js +1025 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCTouch.js +175 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/CCLabelTTF.js +829 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +420 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js +101 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/LabelTTFPropertyDefine.js +88 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/layers/CCLayer.js +642 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +434 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/layers/CCLayerWebGLRenderCmd.js +248 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCClass.js +333 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCCommon.js +303 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCConfig.js +303 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCEGLView.js +1245 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCInputExtension.js +135 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCInputManager.js +616 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCLoaders.js +142 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCMacro.js +830 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCSAXParser.js +160 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCScreen.js +155 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCTypes.js +374 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCTypesPropertyDefine.js +165 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCTypesWebGL.js +689 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCVisibleRect.js +100 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/miniFramework.js +264 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/renderer/RendererCanvas.js +274 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/renderer/RendererWebGL.js +137 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/scenes/CCLoaderScene.js +149 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/scenes/CCScene.js +62 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCAnimation.js +477 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCAnimationCache.js +213 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCBakeSprite.js +71 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSprite.js +1014 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteBatchNode.js +676 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js +101 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +243 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +518 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteFrame.js +420 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteFrameCache.js +341 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +493 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/SpritesPropertyDefine.js +67 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/support/CCPointExtension.js +515 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/support/CCVertex.js +170 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/support/TransformUtils.js +62 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/CCTexture2D.js +455 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/CCTextureAtlas.js +653 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/CCTextureCache.js +371 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/TexturesPropertyDefine.js +221 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/TexturesWebGL.js +899 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/utils/BinaryLoader.js +151 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/effects/CCGrabber.js +110 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/effects/CCGrid.js +737 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/aabb.js +68 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/gl/mat4stack.js +59 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/gl/matrix.js +169 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/mat3.js +329 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/mat4.js +810 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/plane.js +184 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/quaternion.js +497 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/ray2.js +163 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/utility.js +76 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/vec2.js +107 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/vec3.js +205 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/vec4.js +158 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelAtlas.js +239 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js +95 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js +132 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelBMFont.js +958 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js +142 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js +87 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/menus/CCMenu.js +600 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/menus/CCMenuItem.js +1422 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/motion-streak/CCMotionStreak.js +517 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js +66 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/node-grid/CCNodeGrid.js +129 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/node-grid/CCNodeGridWebGLRenderCmd.js +98 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/parallax/CCParallaxNode.js +252 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/parallax/CCParallaxNodeRenderCmd.js +69 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCPNGReader.js +330 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleBatchNode.js +527 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleBatchNodeCanvasRenderCmd.js +38 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js +74 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleExamples.js +1006 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleSystem.js +2294 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js +217 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js +402 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCTIFFReader.js +692 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsDebugNode.js +212 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsDebugNodeCanvasRenderCmd.js +52 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js +53 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsSprite.js +447 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js +93 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js +87 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCActionProgressTimer.js +227 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCProgressTimer.js +345 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js +270 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js +486 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/render-texture/CCRenderTexture.js +395 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js +105 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +367 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCGLProgram.js +767 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCGLStateCache.js +340 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCShaderCache.js +301 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCShaders.js +280 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shape-nodes/CCDrawNode.js +940 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js +129 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shape-nodes/CCDrawNodeWebGLRenderCmd.js +41 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/text-input/CCIMEDispatcher.js +526 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/text-input/CCTextFieldTTF.js +472 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTGAlib.js +437 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXLayer.js +914 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +232 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js +67 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXObjectGroup.js +146 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXTiledMap.js +479 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXXMLParser.js +950 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/transitions/CCTransition.js +1971 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/transitions/CCTransitionPageTurn.js +152 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/transitions/CCTransitionProgress.js +458 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBAnimationManager.js +770 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBKeyframe.js +60 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBReader.js +1129 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBReaderUtil.js +61 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBRelativePositioning.js +90 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBSequence.js +114 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBValue.js +81 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCControlLoader.js +318 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCNodeLoader.js +905 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCNodeLoaderLibrary.js +101 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCSpriteLoader.js +544 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccpool/CCPool.js +146 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/CCProtectedNode.js +305 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +246 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +159 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIScale9Sprite.js +1105 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js +142 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js +129 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIWidget.js +2059 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIWidgetRenderCmd.js +100 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UIHBox.js +80 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayout.js +1558 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js +179 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutComponent.js +585 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutManager.js +457 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutParameter.js +576 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js +240 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UIRelativeBox.js +79 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UIVBox.js +79 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/system/CocosGUI.js +62 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/system/UIHelper.js +164 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIButton.js +987 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UICheckBox.js +737 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIImageView.js +337 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UILoadingBar.js +432 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIRichText.js +579 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UISlider.js +762 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIText.js +512 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UITextAtlas.js +229 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UITextBMFont.js +216 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UITextField.js +915 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +602 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +657 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +1884 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/CocoStudio.js +68 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionFrame.js +528 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionManager.js +112 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionNode.js +417 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionObject.js +263 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCArmature.js +579 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js +190 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js +167 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCBone.js +711 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +669 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/animation/CCProcessBase.js +365 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/animation/CCTween.js +448 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/datas/CCDatas.js +807 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCDecorativeDisplay.js +118 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCDisplayFactory.js +220 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCDisplayManager.js +465 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCSkin.js +215 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js +58 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js +146 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/physics/CCColliderDetector.js +397 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +325 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCArmatureDefine.js +45 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +1223 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js +68 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCTransformHelp.js +183 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCTweenFunction.js +501 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCUtilMath.js +69 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComAttribute.js +210 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComAudio.js +285 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComController.js +76 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComRender.js +91 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComponent.js +136 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComponentContainer.js +159 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/load.js +221 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/action-1.x.js +238 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/action-2.x.js +266 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/compatible.js +251 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/scene-1.x.js +262 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/timelineParser-1.x.js +292 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +1288 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/uiParser-1.x.js +680 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/timeline/ActionTimeline.js +448 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/timeline/Frame.js +1268 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/timeline/Timeline.js +321 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/ObjectFactory.js +99 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/TriggerBase.js +49 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/TriggerMng.js +301 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/TriggerObj.js +263 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/editbox/CCEditBox.js +716 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/editbox/CCdomNode.js +657 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControl.js +381 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlButton.js +688 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlColourPicker.js +187 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlHuePicker.js +218 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlPotentiometer.js +300 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js +257 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlSlider.js +308 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlStepper.js +390 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlSwitch.js +425 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlUtils.js +177 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCInvocation.js +65 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCMenuPassive.js +415 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCScale9Sprite.js +1099 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js +142 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js +129 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCScrollView.js +827 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js +79 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCScrollViewWebGLRenderCmd.js +108 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCSorting.js +239 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCTableView.js +718 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeleton.js +357 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeletonAnimation.js +340 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeletonCanvasRenderCmd.js +165 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeletonWebGLRenderCmd.js +165 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/Spine.js +2239 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/box2d/box2d.js +10882 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/chipmunk/chipmunk.js +6196 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/pluginx/Plugin.js +254 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/pluginx/platform/facebook.js +557 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/pluginx/platform/facebook_sdk.js +151 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/socketio/socket.io.min.js +2 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/jsb_apis.js +618 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/moduleConfig.json +453 -0
- data/lib/ccb/builder/templates/project/folder/project.json +42 -0
- data/lib/ccb/builder/templates/project/folder/res/CloseNormal.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/CloseSelected.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/HelloWorld.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/favicon.ico +0 -0
- data/lib/ccb/builder/templates/project/folder/res/gameOver/cocos2d-html5.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/gameOver/gameOver.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/mainMenu/bg.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/mainMenu/menu.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/setting/menuTitle.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/shared/arial-14.fnt +182 -0
- data/lib/ccb/builder/templates/project/folder/res/shared/arial-14.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/sound/music/bgMusic.mp3 +0 -0
- data/lib/ccb/builder/templates/project/folder/src/about/layer/ABBackgroundLayer.js +23 -0
- data/lib/ccb/builder/templates/project/folder/src/about/layer/ABTouchLayer.js +51 -0
- data/lib/ccb/builder/templates/project/folder/src/about/scene/About.js +36 -0
- data/lib/ccb/builder/templates/project/folder/src/config/Level.js +7 -0
- data/lib/ccb/builder/templates/project/folder/src/gameOver/layer/GOBackgroundLayer.js +50 -0
- data/lib/ccb/builder/templates/project/folder/src/gameOver/layer/GOTouchLayer.js +51 -0
- data/lib/ccb/builder/templates/project/folder/src/gameOver/scene/GameOver.js +38 -0
- data/lib/ccb/builder/templates/project/folder/src/gamePlay/classes/LevelManager.js +21 -0
- data/lib/ccb/builder/templates/project/folder/src/gamePlay/layer/GPBackgroundLayer.js +25 -0
- data/lib/ccb/builder/templates/project/folder/src/gamePlay/layer/GPTouchLayer.js +51 -0
- data/lib/ccb/builder/templates/project/folder/src/gamePlay/scene/GamePlay.js +44 -0
- data/lib/ccb/builder/templates/project/folder/src/mainMenu/layer/MMBackgroundLayer.js +43 -0
- data/lib/ccb/builder/templates/project/folder/src/mainMenu/layer/MMMainMenuLayer.js +38 -0
- data/lib/ccb/builder/templates/project/folder/src/mainMenu/layer/MMTouchLayer.js +96 -0
- data/lib/ccb/builder/templates/project/folder/src/mainMenu/scene/MainMenu.js +45 -0
- data/lib/ccb/builder/templates/project/folder/src/resource.js +29 -0
- data/lib/ccb/builder/templates/project/folder/src/setting/layer/STBackgroundLayer.js +25 -0
- data/lib/ccb/builder/templates/project/folder/src/setting/layer/STTouchLayer.js +89 -0
- data/lib/ccb/builder/templates/project/folder/src/setting/scene/Setting.js +40 -0
- data/lib/ccb/builder/templates/project/index.html.tt +27 -0
- data/lib/ccb/builder/templates/project/main.js.tt +62 -0
- data/lib/ccb/cli.rb +32 -0
- data/lib/ccb/ext/method_hooker.rb +68 -0
- data/lib/ccb/ext/string_extention.rb +7 -0
- data/lib/ccb.rb +1 -0
- metadata +449 -0
|
@@ -0,0 +1,2294 @@
|
|
|
1
|
+
/****************************************************************************
|
|
2
|
+
Copyright (c) 2008-2010 Ricardo Quesada
|
|
3
|
+
Copyright (c) 2011-2012 cocos2d-x.org
|
|
4
|
+
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
5
|
+
|
|
6
|
+
http://www.cocos2d-x.org
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
****************************************************************************/
|
|
26
|
+
|
|
27
|
+
// ideas taken from:
|
|
28
|
+
// . The ocean spray in your face [Jeff Lander]
|
|
29
|
+
// http://www.double.co.nz/dust/col0798.pdf
|
|
30
|
+
// . Building an Advanced Particle System [John van der Burg]
|
|
31
|
+
// http://www.gamasutra.com/features/20000623/vanderburg_01.htm
|
|
32
|
+
// . LOVE game engine
|
|
33
|
+
// http://love2d.org/
|
|
34
|
+
//
|
|
35
|
+
//
|
|
36
|
+
// Radius mode support, from 71 squared
|
|
37
|
+
// http://particledesigner.71squared.com/
|
|
38
|
+
//
|
|
39
|
+
// IMPORTANT: Particle Designer is supported by cocos2d, but
|
|
40
|
+
// 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
|
|
41
|
+
// cocos2d uses a another approach, but the results are almost identical.
|
|
42
|
+
//
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// tCCPositionType
|
|
46
|
+
// possible types of particle positions
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Structure that contains the values of each particle
|
|
51
|
+
* @Class
|
|
52
|
+
* @Construct
|
|
53
|
+
* @param {cc.Point} [pos=cc.p(0,0)] Position of particle
|
|
54
|
+
* @param {cc.Point} [startPos=cc.p(0,0)]
|
|
55
|
+
* @param {cc.Color} [color= cc.color(0, 0, 0, 255)]
|
|
56
|
+
* @param {cc.Color} [deltaColor=cc.color(0, 0, 0, 255)]
|
|
57
|
+
* @param {cc.Size} [size=0]
|
|
58
|
+
* @param {cc.Size} [deltaSize=0]
|
|
59
|
+
* @param {Number} [rotation=0]
|
|
60
|
+
* @param {Number} [deltaRotation=0]
|
|
61
|
+
* @param {Number} [timeToLive=0]
|
|
62
|
+
* @param {Number} [atlasIndex=0]
|
|
63
|
+
* @param {cc.Particle.ModeA} [modeA=]
|
|
64
|
+
* @param {cc.Particle.ModeA} [modeB=]
|
|
65
|
+
*/
|
|
66
|
+
cc.Particle = function (pos, startPos, color, deltaColor, size, deltaSize, rotation, deltaRotation, timeToLive, atlasIndex, modeA, modeB) {
|
|
67
|
+
this.pos = pos ? pos : cc.p(0,0);
|
|
68
|
+
this.startPos = startPos ? startPos : cc.p(0,0);
|
|
69
|
+
this.color = color ? color : {r:0, g: 0, b:0, a:255};
|
|
70
|
+
this.deltaColor = deltaColor ? deltaColor : {r:0, g: 0, b:0, a:255} ;
|
|
71
|
+
this.size = size || 0;
|
|
72
|
+
this.deltaSize = deltaSize || 0;
|
|
73
|
+
this.rotation = rotation || 0;
|
|
74
|
+
this.deltaRotation = deltaRotation || 0;
|
|
75
|
+
this.timeToLive = timeToLive || 0;
|
|
76
|
+
this.atlasIndex = atlasIndex || 0;
|
|
77
|
+
this.modeA = modeA ? modeA : new cc.Particle.ModeA();
|
|
78
|
+
this.modeB = modeB ? modeB : new cc.Particle.ModeB();
|
|
79
|
+
this.isChangeColor = false;
|
|
80
|
+
this.drawPos = cc.p(0, 0);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Mode A: gravity, direction, radial accel, tangential accel
|
|
85
|
+
* @Class
|
|
86
|
+
* @Construct
|
|
87
|
+
* @param {cc.Point} dir direction of particle
|
|
88
|
+
* @param {Number} radialAccel
|
|
89
|
+
* @param {Number} tangentialAccel
|
|
90
|
+
*/
|
|
91
|
+
cc.Particle.ModeA = function (dir, radialAccel, tangentialAccel) {
|
|
92
|
+
this.dir = dir ? dir : cc.p(0,0);
|
|
93
|
+
this.radialAccel = radialAccel || 0;
|
|
94
|
+
this.tangentialAccel = tangentialAccel || 0;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Mode B: radius mode
|
|
99
|
+
* @Class
|
|
100
|
+
* @Construct
|
|
101
|
+
* @param {Number} angle
|
|
102
|
+
* @param {Number} degreesPerSecond
|
|
103
|
+
* @param {Number} radius
|
|
104
|
+
* @param {Number} deltaRadius
|
|
105
|
+
*/
|
|
106
|
+
cc.Particle.ModeB = function (angle, degreesPerSecond, radius, deltaRadius) {
|
|
107
|
+
this.angle = angle || 0;
|
|
108
|
+
this.degreesPerSecond = degreesPerSecond || 0;
|
|
109
|
+
this.radius = radius || 0;
|
|
110
|
+
this.deltaRadius = deltaRadius || 0;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Array of Point instances used to optimize particle updates
|
|
115
|
+
*/
|
|
116
|
+
cc.Particle.TemporaryPoints = [
|
|
117
|
+
cc.p(),
|
|
118
|
+
cc.p(),
|
|
119
|
+
cc.p(),
|
|
120
|
+
cc.p()
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* <p>
|
|
125
|
+
* Particle System base class. <br/>
|
|
126
|
+
* Attributes of a Particle System:<br/>
|
|
127
|
+
* - emmision rate of the particles<br/>
|
|
128
|
+
* - Gravity Mode (Mode A): <br/>
|
|
129
|
+
* - gravity <br/>
|
|
130
|
+
* - direction <br/>
|
|
131
|
+
* - speed +- variance <br/>
|
|
132
|
+
* - tangential acceleration +- variance<br/>
|
|
133
|
+
* - radial acceleration +- variance<br/>
|
|
134
|
+
* - Radius Mode (Mode B): <br/>
|
|
135
|
+
* - startRadius +- variance <br/>
|
|
136
|
+
* - endRadius +- variance <br/>
|
|
137
|
+
* - rotate +- variance <br/>
|
|
138
|
+
* - Properties common to all modes: <br/>
|
|
139
|
+
* - life +- life variance <br/>
|
|
140
|
+
* - start spin +- variance <br/>
|
|
141
|
+
* - end spin +- variance <br/>
|
|
142
|
+
* - start size +- variance <br/>
|
|
143
|
+
* - end size +- variance <br/>
|
|
144
|
+
* - start color +- variance <br/>
|
|
145
|
+
* - end color +- variance <br/>
|
|
146
|
+
* - life +- variance <br/>
|
|
147
|
+
* - blending function <br/>
|
|
148
|
+
* - texture <br/>
|
|
149
|
+
* <br/>
|
|
150
|
+
* cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).<br/>
|
|
151
|
+
* 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, <br/>
|
|
152
|
+
* cocos2d uses a another approach, but the results are almost identical.<br/>
|
|
153
|
+
* cocos2d supports all the variables used by Particle Designer plus a bit more: <br/>
|
|
154
|
+
* - spinning particles (supported when using ParticleSystem) <br/>
|
|
155
|
+
* - tangential acceleration (Gravity mode) <br/>
|
|
156
|
+
* - radial acceleration (Gravity mode) <br/>
|
|
157
|
+
* - radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only) <br/>
|
|
158
|
+
* It is possible to customize any of the above mentioned properties in runtime. Example: <br/>
|
|
159
|
+
* </p>
|
|
160
|
+
* @class
|
|
161
|
+
* @extends cc.Node
|
|
162
|
+
*
|
|
163
|
+
* @property {Boolean} opacityModifyRGB - Indicate whether the alpha value modify color.
|
|
164
|
+
* @property {cc.SpriteBatchNode} batchNode - Weak reference to the sprite batch node.
|
|
165
|
+
* @property {Boolean} active - <@readonly> Indicate whether the particle system is activated.
|
|
166
|
+
* @property {Number} shapeType - ShapeType of ParticleSystem : cc.ParticleSystem.BALL_SHAPE | cc.ParticleSystem.STAR_SHAPE.
|
|
167
|
+
* @property {Number} atlasIndex - Index of system in batch node array.
|
|
168
|
+
* @property {Number} particleCount - Current quantity of particles that are being simulated.
|
|
169
|
+
* @property {Number} duration - How many seconds the emitter wil run. -1 means 'forever'
|
|
170
|
+
* @property {cc.Point} sourcePos - Source position of the emitter.
|
|
171
|
+
* @property {cc.Point} posVar - Variation of source position.
|
|
172
|
+
* @property {Number} life - Life of each particle setter.
|
|
173
|
+
* @property {Number} lifeVar - Variation of life.
|
|
174
|
+
* @property {Number} angle - Angle of each particle setter.
|
|
175
|
+
* @property {Number} angleVar - Variation of angle of each particle setter.
|
|
176
|
+
* @property {Number} startSize - Start size in pixels of each particle.
|
|
177
|
+
* @property {Number} startSizeVar - Variation of start size in pixels.
|
|
178
|
+
* @property {Number} endSize - End size in pixels of each particle.
|
|
179
|
+
* @property {Number} endSizeVar - Variation of end size in pixels.
|
|
180
|
+
* @property {Number} startSpin - Start angle of each particle.
|
|
181
|
+
* @property {Number} startSpinVar - Variation of start angle.
|
|
182
|
+
* @property {Number} endSpin - End angle of each particle.
|
|
183
|
+
* @property {Number} endSpinVar - Variation of end angle.
|
|
184
|
+
* @property {cc.Point} gravity - Gravity of the emitter.
|
|
185
|
+
* @property {cc.Point} speed - Speed of the emitter.
|
|
186
|
+
* @property {cc.Point} speedVar - Variation of the speed.
|
|
187
|
+
* @property {Number} tangentialAccel - Tangential acceleration of each particle. Only available in 'Gravity' mode.
|
|
188
|
+
* @property {Number} tangentialAccelVar - Variation of the tangential acceleration.
|
|
189
|
+
* @property {Number} tangentialAccel - Radial acceleration of each particle. Only available in 'Gravity' mode.
|
|
190
|
+
* @property {Number} tangentialAccelVar - Variation of the radial acceleration.
|
|
191
|
+
* @property {Boolean} rotationIsDir - Indicate whether the rotation of each particle equals to its direction. Only available in 'Gravity' mode.
|
|
192
|
+
* @property {Number} startRadius - Starting radius of the particles. Only available in 'Radius' mode.
|
|
193
|
+
* @property {Number} startRadiusVar - Variation of the starting radius.
|
|
194
|
+
* @property {Number} endRadius - Ending radius of the particles. Only available in 'Radius' mode.
|
|
195
|
+
* @property {Number} endRadiusVar - Variation of the ending radius.
|
|
196
|
+
* @property {Number} rotatePerS - Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
|
|
197
|
+
* @property {Number} rotatePerSVar - Variation of the degress to rotate a particle around the source pos per second.
|
|
198
|
+
* @property {cc.Color} startColor - Start color of each particle.
|
|
199
|
+
* @property {cc.Color} startColorVar - Variation of the start color.
|
|
200
|
+
* @property {cc.Color} endColor - Ending color of each particle.
|
|
201
|
+
* @property {cc.Color} endColorVar - Variation of the end color.
|
|
202
|
+
* @property {Number} emissionRate - Emission rate of the particles.
|
|
203
|
+
* @property {Number} emitterMode - Emitter modes: CCParticleSystem.MODE_GRAVITY: uses gravity, speed, radial and tangential acceleration; CCParticleSystem.MODE_RADIUS: uses radius movement + rotation.
|
|
204
|
+
* @property {Number} positionType - Particles movement type: cc.ParticleSystem.TYPE_FREE | cc.ParticleSystem.TYPE_GROUPED.
|
|
205
|
+
* @property {Number} totalParticles - Maximum particles of the system.
|
|
206
|
+
* @property {Boolean} autoRemoveOnFinish - Indicate whether the node will be auto-removed when it has no particles left.
|
|
207
|
+
* @property {cc.Texture2D} texture - Texture of Particle System.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* emitter.radialAccel = 15;
|
|
211
|
+
* emitter.startSpin = 0;
|
|
212
|
+
*/
|
|
213
|
+
cc.ParticleSystem = cc.Node.extend(/** @lends cc.ParticleSystem# */{
|
|
214
|
+
_className:"ParticleSystem",
|
|
215
|
+
//***********variables*************
|
|
216
|
+
_plistFile: "",
|
|
217
|
+
//! time elapsed since the start of the system (in seconds)
|
|
218
|
+
_elapsed: 0,
|
|
219
|
+
_dontTint: false,
|
|
220
|
+
|
|
221
|
+
// Different modes
|
|
222
|
+
//! Mode A:Gravity + Tangential Accel + Radial Accel
|
|
223
|
+
modeA: null,
|
|
224
|
+
//! Mode B: circular movement (gravity, radial accel and tangential accel don't are not used in this mode)
|
|
225
|
+
modeB: null,
|
|
226
|
+
|
|
227
|
+
//private POINTZERO for ParticleSystem
|
|
228
|
+
_pointZeroForParticle: cc.p(0, 0),
|
|
229
|
+
|
|
230
|
+
//! Array of particles
|
|
231
|
+
_particles: null,
|
|
232
|
+
|
|
233
|
+
// color modulate
|
|
234
|
+
// BOOL colorModulate;
|
|
235
|
+
|
|
236
|
+
//! How many particles can be emitted per second
|
|
237
|
+
_emitCounter: 0,
|
|
238
|
+
//! particle idx
|
|
239
|
+
_particleIdx: 0,
|
|
240
|
+
|
|
241
|
+
_batchNode: null,
|
|
242
|
+
atlasIndex: 0,
|
|
243
|
+
|
|
244
|
+
//true if scaled or rotated
|
|
245
|
+
_transformSystemDirty: false,
|
|
246
|
+
_allocatedParticles: 0,
|
|
247
|
+
|
|
248
|
+
_isActive: false,
|
|
249
|
+
particleCount: 0,
|
|
250
|
+
duration: 0,
|
|
251
|
+
_sourcePosition: null,
|
|
252
|
+
_posVar: null,
|
|
253
|
+
life: 0,
|
|
254
|
+
lifeVar: 0,
|
|
255
|
+
angle: 0,
|
|
256
|
+
angleVar: 0,
|
|
257
|
+
startSize: 0,
|
|
258
|
+
startSizeVar: 0,
|
|
259
|
+
endSize: 0,
|
|
260
|
+
endSizeVar: 0,
|
|
261
|
+
_startColor: null,
|
|
262
|
+
_startColorVar: null,
|
|
263
|
+
_endColor: null,
|
|
264
|
+
_endColorVar: null,
|
|
265
|
+
startSpin: 0,
|
|
266
|
+
startSpinVar: 0,
|
|
267
|
+
endSpin: 0,
|
|
268
|
+
endSpinVar: 0,
|
|
269
|
+
emissionRate: 0,
|
|
270
|
+
_totalParticles: 0,
|
|
271
|
+
_texture: null,
|
|
272
|
+
_blendFunc: null,
|
|
273
|
+
_opacityModifyRGB: false,
|
|
274
|
+
positionType: null,
|
|
275
|
+
autoRemoveOnFinish: false,
|
|
276
|
+
emitterMode: 0,
|
|
277
|
+
|
|
278
|
+
_textureLoaded: null,
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* <p> return the string found by key in dict. <br/>
|
|
282
|
+
* This plist files can be create manually or with Particle Designer:<br/>
|
|
283
|
+
* http://particledesigner.71squared.com/<br/>
|
|
284
|
+
* </p>
|
|
285
|
+
* Constructor of cc.ParticleSystem
|
|
286
|
+
* @param {String|Number} plistFile
|
|
287
|
+
*/
|
|
288
|
+
ctor:function (plistFile) {
|
|
289
|
+
cc.Node.prototype.ctor.call(this);
|
|
290
|
+
this.emitterMode = cc.ParticleSystem.MODE_GRAVITY;
|
|
291
|
+
this.modeA = new cc.ParticleSystem.ModeA();
|
|
292
|
+
this.modeB = new cc.ParticleSystem.ModeB();
|
|
293
|
+
this._blendFunc = {src:cc.BLEND_SRC, dst:cc.BLEND_DST};
|
|
294
|
+
|
|
295
|
+
this._particles = [];
|
|
296
|
+
this._sourcePosition = cc.p(0, 0);
|
|
297
|
+
this._posVar = cc.p(0, 0);
|
|
298
|
+
|
|
299
|
+
this._startColor = cc.color(255, 255, 255, 255);
|
|
300
|
+
this._startColorVar = cc.color(255, 255, 255, 255);
|
|
301
|
+
this._endColor = cc.color(255, 255, 255, 255);
|
|
302
|
+
this._endColorVar = cc.color(255, 255, 255, 255);
|
|
303
|
+
|
|
304
|
+
this._plistFile = "";
|
|
305
|
+
this._elapsed = 0;
|
|
306
|
+
this._dontTint = false;
|
|
307
|
+
this._pointZeroForParticle = cc.p(0, 0);
|
|
308
|
+
this._emitCounter = 0;
|
|
309
|
+
this._particleIdx = 0;
|
|
310
|
+
this._batchNode = null;
|
|
311
|
+
this.atlasIndex = 0;
|
|
312
|
+
|
|
313
|
+
this._transformSystemDirty = false;
|
|
314
|
+
this._allocatedParticles = 0;
|
|
315
|
+
this._isActive = false;
|
|
316
|
+
this.particleCount = 0;
|
|
317
|
+
this.duration = 0;
|
|
318
|
+
this.life = 0;
|
|
319
|
+
this.lifeVar = 0;
|
|
320
|
+
this.angle = 0;
|
|
321
|
+
this.angleVar = 0;
|
|
322
|
+
this.startSize = 0;
|
|
323
|
+
this.startSizeVar = 0;
|
|
324
|
+
this.endSize = 0;
|
|
325
|
+
this.endSizeVar = 0;
|
|
326
|
+
|
|
327
|
+
this.startSpin = 0;
|
|
328
|
+
this.startSpinVar = 0;
|
|
329
|
+
this.endSpin = 0;
|
|
330
|
+
this.endSpinVar = 0;
|
|
331
|
+
this.emissionRate = 0;
|
|
332
|
+
this._totalParticles = 0;
|
|
333
|
+
this._texture = null;
|
|
334
|
+
this._opacityModifyRGB = false;
|
|
335
|
+
this.positionType = cc.ParticleSystem.TYPE_FREE;
|
|
336
|
+
this.autoRemoveOnFinish = false;
|
|
337
|
+
|
|
338
|
+
this._textureLoaded = true;
|
|
339
|
+
|
|
340
|
+
if (!plistFile || cc.isNumber(plistFile)) {
|
|
341
|
+
var ton = plistFile || 100;
|
|
342
|
+
this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE);
|
|
343
|
+
this.initWithTotalParticles(ton);
|
|
344
|
+
} else if (plistFile) {
|
|
345
|
+
this.initWithFile(plistFile);
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
_createRenderCmd: function(){
|
|
350
|
+
if(cc._renderType === cc._RENDER_TYPE_CANVAS)
|
|
351
|
+
return new cc.ParticleSystem.CanvasRenderCmd(this);
|
|
352
|
+
else
|
|
353
|
+
return new cc.ParticleSystem.WebGLRenderCmd(this);
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* This is a hack function for performance, it's only available on Canvas mode. <br/>
|
|
358
|
+
* It's very expensive to change color on Canvas mode, so if set it to true, particle system will ignore the changing color operation.
|
|
359
|
+
* @param {boolean} ignore
|
|
360
|
+
*/
|
|
361
|
+
ignoreColor: function(ignore){
|
|
362
|
+
this._dontTint = ignore;
|
|
363
|
+
},
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* <p> initializes the texture with a rectangle measured Points<br/>
|
|
367
|
+
* pointRect should be in Texture coordinates, not pixel coordinates
|
|
368
|
+
* </p>
|
|
369
|
+
* @param {cc.Rect} pointRect
|
|
370
|
+
*/
|
|
371
|
+
initTexCoordsWithRect:function (pointRect) {
|
|
372
|
+
this._renderCmd.initTexCoordsWithRect(pointRect);
|
|
373
|
+
},
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* return weak reference to the cc.SpriteBatchNode that renders the cc.Sprite
|
|
377
|
+
* @return {cc.ParticleBatchNode}
|
|
378
|
+
*/
|
|
379
|
+
getBatchNode:function () {
|
|
380
|
+
return this._batchNode;
|
|
381
|
+
},
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* set weak reference to the cc.SpriteBatchNode that renders the cc.Sprite
|
|
385
|
+
* @param {cc.ParticleBatchNode} batchNode
|
|
386
|
+
*/
|
|
387
|
+
setBatchNode:function (batchNode) {
|
|
388
|
+
this._renderCmd.setBatchNode(batchNode);
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* return index of system in batch node array
|
|
393
|
+
* @return {Number}
|
|
394
|
+
*/
|
|
395
|
+
getAtlasIndex:function () {
|
|
396
|
+
return this.atlasIndex;
|
|
397
|
+
},
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* set index of system in batch node array
|
|
401
|
+
* @param {Number} atlasIndex
|
|
402
|
+
*/
|
|
403
|
+
setAtlasIndex:function (atlasIndex) {
|
|
404
|
+
this.atlasIndex = atlasIndex;
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Return DrawMode of ParticleSystem (Canvas Mode only)
|
|
409
|
+
* @return {Number}
|
|
410
|
+
*/
|
|
411
|
+
getDrawMode:function () {
|
|
412
|
+
return this._renderCmd.getDrawMode();
|
|
413
|
+
},
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* DrawMode of ParticleSystem setter (Canvas Mode only)
|
|
417
|
+
* @param {Number} drawMode
|
|
418
|
+
*/
|
|
419
|
+
setDrawMode:function (drawMode) {
|
|
420
|
+
this._renderCmd.setDrawMode(drawMode);
|
|
421
|
+
},
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Return ShapeType of ParticleSystem (Canvas Mode only)
|
|
425
|
+
* @return {Number}
|
|
426
|
+
*/
|
|
427
|
+
getShapeType:function () {
|
|
428
|
+
return this._renderCmd.getShapeType();
|
|
429
|
+
},
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* ShapeType of ParticleSystem setter (Canvas Mode only)
|
|
433
|
+
* @param {Number} shapeType
|
|
434
|
+
*/
|
|
435
|
+
setShapeType:function (shapeType) {
|
|
436
|
+
this._renderCmd.setShapeType(shapeType);
|
|
437
|
+
},
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Return ParticleSystem is active
|
|
441
|
+
* @return {Boolean}
|
|
442
|
+
*/
|
|
443
|
+
isActive:function () {
|
|
444
|
+
return this._isActive;
|
|
445
|
+
},
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Quantity of particles that are being simulated at the moment
|
|
449
|
+
* @return {Number}
|
|
450
|
+
*/
|
|
451
|
+
getParticleCount:function () {
|
|
452
|
+
return this.particleCount;
|
|
453
|
+
},
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Quantity of particles setter
|
|
457
|
+
* @param {Number} particleCount
|
|
458
|
+
*/
|
|
459
|
+
setParticleCount:function (particleCount) {
|
|
460
|
+
this.particleCount = particleCount;
|
|
461
|
+
},
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* How many seconds the emitter wil run. -1 means 'forever'
|
|
465
|
+
* @return {Number}
|
|
466
|
+
*/
|
|
467
|
+
getDuration:function () {
|
|
468
|
+
return this.duration;
|
|
469
|
+
},
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* set run seconds of the emitter
|
|
473
|
+
* @param {Number} duration
|
|
474
|
+
*/
|
|
475
|
+
setDuration:function (duration) {
|
|
476
|
+
this.duration = duration;
|
|
477
|
+
},
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Return sourcePosition of the emitter
|
|
481
|
+
* @return {cc.Point | Object}
|
|
482
|
+
*/
|
|
483
|
+
getSourcePosition:function () {
|
|
484
|
+
return {x: this._sourcePosition.x, y: this._sourcePosition.y};
|
|
485
|
+
},
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* sourcePosition of the emitter setter
|
|
489
|
+
* @param sourcePosition
|
|
490
|
+
*/
|
|
491
|
+
setSourcePosition:function (sourcePosition) {
|
|
492
|
+
this._sourcePosition = sourcePosition;
|
|
493
|
+
},
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Return Position variance of the emitter
|
|
497
|
+
* @return {cc.Point | Object}
|
|
498
|
+
*/
|
|
499
|
+
getPosVar:function () {
|
|
500
|
+
return {x: this._posVar.x, y: this._posVar.y};
|
|
501
|
+
},
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Position variance of the emitter setter
|
|
505
|
+
* @param {cc.Point} posVar
|
|
506
|
+
*/
|
|
507
|
+
setPosVar:function (posVar) {
|
|
508
|
+
this._posVar = posVar;
|
|
509
|
+
},
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Return life of each particle
|
|
513
|
+
* @return {Number}
|
|
514
|
+
*/
|
|
515
|
+
getLife:function () {
|
|
516
|
+
return this.life;
|
|
517
|
+
},
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* life of each particle setter
|
|
521
|
+
* @param {Number} life
|
|
522
|
+
*/
|
|
523
|
+
setLife:function (life) {
|
|
524
|
+
this.life = life;
|
|
525
|
+
},
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Return life variance of each particle
|
|
529
|
+
* @return {Number}
|
|
530
|
+
*/
|
|
531
|
+
getLifeVar:function () {
|
|
532
|
+
return this.lifeVar;
|
|
533
|
+
},
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* life variance of each particle setter
|
|
537
|
+
* @param {Number} lifeVar
|
|
538
|
+
*/
|
|
539
|
+
setLifeVar:function (lifeVar) {
|
|
540
|
+
this.lifeVar = lifeVar;
|
|
541
|
+
},
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Return angle of each particle
|
|
545
|
+
* @return {Number}
|
|
546
|
+
*/
|
|
547
|
+
getAngle:function () {
|
|
548
|
+
return this.angle;
|
|
549
|
+
},
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* angle of each particle setter
|
|
553
|
+
* @param {Number} angle
|
|
554
|
+
*/
|
|
555
|
+
setAngle:function (angle) {
|
|
556
|
+
this.angle = angle;
|
|
557
|
+
},
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Return angle variance of each particle
|
|
561
|
+
* @return {Number}
|
|
562
|
+
*/
|
|
563
|
+
getAngleVar:function () {
|
|
564
|
+
return this.angleVar;
|
|
565
|
+
},
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* angle variance of each particle setter
|
|
569
|
+
* @param angleVar
|
|
570
|
+
*/
|
|
571
|
+
setAngleVar:function (angleVar) {
|
|
572
|
+
this.angleVar = angleVar;
|
|
573
|
+
},
|
|
574
|
+
|
|
575
|
+
// mode A
|
|
576
|
+
/**
|
|
577
|
+
* Return Gravity of emitter
|
|
578
|
+
* @return {cc.Point}
|
|
579
|
+
*/
|
|
580
|
+
getGravity:function () {
|
|
581
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
582
|
+
cc.log("cc.ParticleBatchNode.getGravity() : Particle Mode should be Gravity");
|
|
583
|
+
var locGravity = this.modeA.gravity;
|
|
584
|
+
return cc.p(locGravity.x, locGravity.y);
|
|
585
|
+
},
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Gravity of emitter setter
|
|
589
|
+
* @param {cc.Point} gravity
|
|
590
|
+
*/
|
|
591
|
+
setGravity:function (gravity) {
|
|
592
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
593
|
+
cc.log("cc.ParticleBatchNode.setGravity() : Particle Mode should be Gravity");
|
|
594
|
+
this.modeA.gravity = gravity;
|
|
595
|
+
},
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Return Speed of each particle
|
|
599
|
+
* @return {Number}
|
|
600
|
+
*/
|
|
601
|
+
getSpeed:function () {
|
|
602
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
603
|
+
cc.log("cc.ParticleBatchNode.getSpeed() : Particle Mode should be Gravity");
|
|
604
|
+
return this.modeA.speed;
|
|
605
|
+
},
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Speed of each particle setter
|
|
609
|
+
* @param {Number} speed
|
|
610
|
+
*/
|
|
611
|
+
setSpeed:function (speed) {
|
|
612
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
613
|
+
cc.log("cc.ParticleBatchNode.setSpeed() : Particle Mode should be Gravity");
|
|
614
|
+
this.modeA.speed = speed;
|
|
615
|
+
},
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* return speed variance of each particle. Only available in 'Gravity' mode.
|
|
619
|
+
* @return {Number}
|
|
620
|
+
*/
|
|
621
|
+
getSpeedVar:function () {
|
|
622
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
623
|
+
cc.log("cc.ParticleBatchNode.getSpeedVar() : Particle Mode should be Gravity");
|
|
624
|
+
return this.modeA.speedVar;
|
|
625
|
+
},
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* speed variance of each particle setter. Only available in 'Gravity' mode.
|
|
629
|
+
* @param {Number} speedVar
|
|
630
|
+
*/
|
|
631
|
+
setSpeedVar:function (speedVar) {
|
|
632
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
633
|
+
cc.log("cc.ParticleBatchNode.setSpeedVar() : Particle Mode should be Gravity");
|
|
634
|
+
this.modeA.speedVar = speedVar;
|
|
635
|
+
},
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Return tangential acceleration of each particle. Only available in 'Gravity' mode.
|
|
639
|
+
* @return {Number}
|
|
640
|
+
*/
|
|
641
|
+
getTangentialAccel:function () {
|
|
642
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
643
|
+
cc.log("cc.ParticleBatchNode.getTangentialAccel() : Particle Mode should be Gravity");
|
|
644
|
+
return this.modeA.tangentialAccel;
|
|
645
|
+
},
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Tangential acceleration of each particle setter. Only available in 'Gravity' mode.
|
|
649
|
+
* @param {Number} tangentialAccel
|
|
650
|
+
*/
|
|
651
|
+
setTangentialAccel:function (tangentialAccel) {
|
|
652
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
653
|
+
cc.log("cc.ParticleBatchNode.setTangentialAccel() : Particle Mode should be Gravity");
|
|
654
|
+
this.modeA.tangentialAccel = tangentialAccel;
|
|
655
|
+
},
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Return tangential acceleration variance of each particle. Only available in 'Gravity' mode.
|
|
659
|
+
* @return {Number}
|
|
660
|
+
*/
|
|
661
|
+
getTangentialAccelVar:function () {
|
|
662
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
663
|
+
cc.log("cc.ParticleBatchNode.getTangentialAccelVar() : Particle Mode should be Gravity");
|
|
664
|
+
return this.modeA.tangentialAccelVar;
|
|
665
|
+
},
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* tangential acceleration variance of each particle setter. Only available in 'Gravity' mode.
|
|
669
|
+
* @param {Number} tangentialAccelVar
|
|
670
|
+
*/
|
|
671
|
+
setTangentialAccelVar:function (tangentialAccelVar) {
|
|
672
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
673
|
+
cc.log("cc.ParticleBatchNode.setTangentialAccelVar() : Particle Mode should be Gravity");
|
|
674
|
+
this.modeA.tangentialAccelVar = tangentialAccelVar;
|
|
675
|
+
},
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Return radial acceleration of each particle. Only available in 'Gravity' mode.
|
|
679
|
+
* @return {Number}
|
|
680
|
+
*/
|
|
681
|
+
getRadialAccel:function () {
|
|
682
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
683
|
+
cc.log("cc.ParticleBatchNode.getRadialAccel() : Particle Mode should be Gravity");
|
|
684
|
+
return this.modeA.radialAccel;
|
|
685
|
+
},
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* radial acceleration of each particle setter. Only available in 'Gravity' mode.
|
|
689
|
+
* @param {Number} radialAccel
|
|
690
|
+
*/
|
|
691
|
+
setRadialAccel:function (radialAccel) {
|
|
692
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
693
|
+
cc.log("cc.ParticleBatchNode.setRadialAccel() : Particle Mode should be Gravity");
|
|
694
|
+
this.modeA.radialAccel = radialAccel;
|
|
695
|
+
},
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Return radial acceleration variance of each particle. Only available in 'Gravity' mode.
|
|
699
|
+
* @return {Number}
|
|
700
|
+
*/
|
|
701
|
+
getRadialAccelVar:function () {
|
|
702
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
703
|
+
cc.log("cc.ParticleBatchNode.getRadialAccelVar() : Particle Mode should be Gravity");
|
|
704
|
+
return this.modeA.radialAccelVar;
|
|
705
|
+
},
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* radial acceleration variance of each particle setter. Only available in 'Gravity' mode.
|
|
709
|
+
* @param {Number} radialAccelVar
|
|
710
|
+
*/
|
|
711
|
+
setRadialAccelVar:function (radialAccelVar) {
|
|
712
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
713
|
+
cc.log("cc.ParticleBatchNode.setRadialAccelVar() : Particle Mode should be Gravity");
|
|
714
|
+
this.modeA.radialAccelVar = radialAccelVar;
|
|
715
|
+
},
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* get the rotation of each particle to its direction Only available in 'Gravity' mode.
|
|
719
|
+
* @returns {boolean}
|
|
720
|
+
*/
|
|
721
|
+
getRotationIsDir: function(){
|
|
722
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
723
|
+
cc.log("cc.ParticleBatchNode.getRotationIsDir() : Particle Mode should be Gravity");
|
|
724
|
+
return this.modeA.rotationIsDir;
|
|
725
|
+
},
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* set the rotation of each particle to its direction Only available in 'Gravity' mode.
|
|
729
|
+
* @param {boolean} t
|
|
730
|
+
*/
|
|
731
|
+
setRotationIsDir: function(t){
|
|
732
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_GRAVITY)
|
|
733
|
+
cc.log("cc.ParticleBatchNode.setRotationIsDir() : Particle Mode should be Gravity");
|
|
734
|
+
this.modeA.rotationIsDir = t;
|
|
735
|
+
},
|
|
736
|
+
|
|
737
|
+
// mode B
|
|
738
|
+
/**
|
|
739
|
+
* Return starting radius of the particles. Only available in 'Radius' mode.
|
|
740
|
+
* @return {Number}
|
|
741
|
+
*/
|
|
742
|
+
getStartRadius:function () {
|
|
743
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
744
|
+
cc.log("cc.ParticleBatchNode.getStartRadius() : Particle Mode should be Radius");
|
|
745
|
+
return this.modeB.startRadius;
|
|
746
|
+
},
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* starting radius of the particles setter. Only available in 'Radius' mode.
|
|
750
|
+
* @param {Number} startRadius
|
|
751
|
+
*/
|
|
752
|
+
setStartRadius:function (startRadius) {
|
|
753
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
754
|
+
cc.log("cc.ParticleBatchNode.setStartRadius() : Particle Mode should be Radius");
|
|
755
|
+
this.modeB.startRadius = startRadius;
|
|
756
|
+
},
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Return starting radius variance of the particles. Only available in 'Radius' mode.
|
|
760
|
+
* @return {Number}
|
|
761
|
+
*/
|
|
762
|
+
getStartRadiusVar:function () {
|
|
763
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
764
|
+
cc.log("cc.ParticleBatchNode.getStartRadiusVar() : Particle Mode should be Radius");
|
|
765
|
+
return this.modeB.startRadiusVar;
|
|
766
|
+
},
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* starting radius variance of the particles setter. Only available in 'Radius' mode.
|
|
770
|
+
* @param {Number} startRadiusVar
|
|
771
|
+
*/
|
|
772
|
+
setStartRadiusVar:function (startRadiusVar) {
|
|
773
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
774
|
+
cc.log("cc.ParticleBatchNode.setStartRadiusVar() : Particle Mode should be Radius");
|
|
775
|
+
this.modeB.startRadiusVar = startRadiusVar;
|
|
776
|
+
},
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Return ending radius of the particles. Only available in 'Radius' mode.
|
|
780
|
+
* @return {Number}
|
|
781
|
+
*/
|
|
782
|
+
getEndRadius:function () {
|
|
783
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
784
|
+
cc.log("cc.ParticleBatchNode.getEndRadius() : Particle Mode should be Radius");
|
|
785
|
+
return this.modeB.endRadius;
|
|
786
|
+
},
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* ending radius of the particles setter. Only available in 'Radius' mode.
|
|
790
|
+
* @param {Number} endRadius
|
|
791
|
+
*/
|
|
792
|
+
setEndRadius:function (endRadius) {
|
|
793
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
794
|
+
cc.log("cc.ParticleBatchNode.setEndRadius() : Particle Mode should be Radius");
|
|
795
|
+
this.modeB.endRadius = endRadius;
|
|
796
|
+
},
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Return ending radius variance of the particles. Only available in 'Radius' mode.
|
|
800
|
+
* @return {Number}
|
|
801
|
+
*/
|
|
802
|
+
getEndRadiusVar:function () {
|
|
803
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
804
|
+
cc.log("cc.ParticleBatchNode.getEndRadiusVar() : Particle Mode should be Radius");
|
|
805
|
+
return this.modeB.endRadiusVar;
|
|
806
|
+
},
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* ending radius variance of the particles setter. Only available in 'Radius' mode.
|
|
810
|
+
* @param endRadiusVar
|
|
811
|
+
*/
|
|
812
|
+
setEndRadiusVar:function (endRadiusVar) {
|
|
813
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
814
|
+
cc.log("cc.ParticleBatchNode.setEndRadiusVar() : Particle Mode should be Radius");
|
|
815
|
+
this.modeB.endRadiusVar = endRadiusVar;
|
|
816
|
+
},
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* get Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
|
|
820
|
+
* @return {Number}
|
|
821
|
+
*/
|
|
822
|
+
getRotatePerSecond:function () {
|
|
823
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
824
|
+
cc.log("cc.ParticleBatchNode.getRotatePerSecond() : Particle Mode should be Radius");
|
|
825
|
+
return this.modeB.rotatePerSecond;
|
|
826
|
+
},
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* set Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
|
|
830
|
+
* @param {Number} degrees
|
|
831
|
+
*/
|
|
832
|
+
setRotatePerSecond:function (degrees) {
|
|
833
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
834
|
+
cc.log("cc.ParticleBatchNode.setRotatePerSecond() : Particle Mode should be Radius");
|
|
835
|
+
this.modeB.rotatePerSecond = degrees;
|
|
836
|
+
},
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Return Variance in degrees for rotatePerSecond. Only available in 'Radius' mode.
|
|
840
|
+
* @return {Number}
|
|
841
|
+
*/
|
|
842
|
+
getRotatePerSecondVar:function () {
|
|
843
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
844
|
+
cc.log("cc.ParticleBatchNode.getRotatePerSecondVar() : Particle Mode should be Radius");
|
|
845
|
+
return this.modeB.rotatePerSecondVar;
|
|
846
|
+
},
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Variance in degrees for rotatePerSecond setter. Only available in 'Radius' mode.
|
|
850
|
+
* @param degrees
|
|
851
|
+
*/
|
|
852
|
+
setRotatePerSecondVar:function (degrees) {
|
|
853
|
+
if(this.emitterMode !== cc.ParticleSystem.MODE_RADIUS)
|
|
854
|
+
cc.log("cc.ParticleBatchNode.setRotatePerSecondVar() : Particle Mode should be Radius");
|
|
855
|
+
this.modeB.rotatePerSecondVar = degrees;
|
|
856
|
+
},
|
|
857
|
+
//////////////////////////////////////////////////////////////////////////
|
|
858
|
+
|
|
859
|
+
//don't use a transform matrix, this is faster
|
|
860
|
+
setScale:function (scale, scaleY) {
|
|
861
|
+
this._transformSystemDirty = true;
|
|
862
|
+
cc.Node.prototype.setScale.call(this, scale, scaleY);
|
|
863
|
+
},
|
|
864
|
+
|
|
865
|
+
setRotation:function (newRotation) {
|
|
866
|
+
this._transformSystemDirty = true;
|
|
867
|
+
cc.Node.prototype.setRotation.call(this, newRotation);
|
|
868
|
+
},
|
|
869
|
+
|
|
870
|
+
setScaleX:function (newScaleX) {
|
|
871
|
+
this._transformSystemDirty = true;
|
|
872
|
+
cc.Node.prototype.setScaleX.call(this, newScaleX);
|
|
873
|
+
},
|
|
874
|
+
|
|
875
|
+
setScaleY:function (newScaleY) {
|
|
876
|
+
this._transformSystemDirty = true;
|
|
877
|
+
cc.Node.prototype.setScaleY.call(this, newScaleY);
|
|
878
|
+
},
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* get start size in pixels of each particle
|
|
882
|
+
* @return {Number}
|
|
883
|
+
*/
|
|
884
|
+
getStartSize:function () {
|
|
885
|
+
return this.startSize;
|
|
886
|
+
},
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* set start size in pixels of each particle
|
|
890
|
+
* @param {Number} startSize
|
|
891
|
+
*/
|
|
892
|
+
setStartSize:function (startSize) {
|
|
893
|
+
this.startSize = startSize;
|
|
894
|
+
},
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* get size variance in pixels of each particle
|
|
898
|
+
* @return {Number}
|
|
899
|
+
*/
|
|
900
|
+
getStartSizeVar:function () {
|
|
901
|
+
return this.startSizeVar;
|
|
902
|
+
},
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* set size variance in pixels of each particle
|
|
906
|
+
* @param {Number} startSizeVar
|
|
907
|
+
*/
|
|
908
|
+
setStartSizeVar:function (startSizeVar) {
|
|
909
|
+
this.startSizeVar = startSizeVar;
|
|
910
|
+
},
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* get end size in pixels of each particle
|
|
914
|
+
* @return {Number}
|
|
915
|
+
*/
|
|
916
|
+
getEndSize:function () {
|
|
917
|
+
return this.endSize;
|
|
918
|
+
},
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* set end size in pixels of each particle
|
|
922
|
+
* @param endSize
|
|
923
|
+
*/
|
|
924
|
+
setEndSize:function (endSize) {
|
|
925
|
+
this.endSize = endSize;
|
|
926
|
+
},
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* get end size variance in pixels of each particle
|
|
930
|
+
* @return {Number}
|
|
931
|
+
*/
|
|
932
|
+
getEndSizeVar:function () {
|
|
933
|
+
return this.endSizeVar;
|
|
934
|
+
},
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* set end size variance in pixels of each particle
|
|
938
|
+
* @param {Number} endSizeVar
|
|
939
|
+
*/
|
|
940
|
+
setEndSizeVar:function (endSizeVar) {
|
|
941
|
+
this.endSizeVar = endSizeVar;
|
|
942
|
+
},
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* set start color of each particle
|
|
946
|
+
* @return {cc.Color}
|
|
947
|
+
*/
|
|
948
|
+
getStartColor:function () {
|
|
949
|
+
return cc.color(this._startColor.r, this._startColor.g, this._startColor.b, this._startColor.a);
|
|
950
|
+
},
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* get start color of each particle
|
|
954
|
+
* @param {cc.Color} startColor
|
|
955
|
+
*/
|
|
956
|
+
setStartColor:function (startColor) {
|
|
957
|
+
this._startColor = cc.color(startColor);
|
|
958
|
+
},
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* get start color variance of each particle
|
|
962
|
+
* @return {cc.Color}
|
|
963
|
+
*/
|
|
964
|
+
getStartColorVar:function () {
|
|
965
|
+
return cc.color(this._startColorVar.r, this._startColorVar.g, this._startColorVar.b, this._startColorVar.a);
|
|
966
|
+
},
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* set start color variance of each particle
|
|
970
|
+
* @param {cc.Color} startColorVar
|
|
971
|
+
*/
|
|
972
|
+
setStartColorVar:function (startColorVar) {
|
|
973
|
+
this._startColorVar = cc.color(startColorVar);
|
|
974
|
+
},
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* get end color and end color variation of each particle
|
|
978
|
+
* @return {cc.Color}
|
|
979
|
+
*/
|
|
980
|
+
getEndColor:function () {
|
|
981
|
+
return cc.color(this._endColor.r, this._endColor.g, this._endColor.b, this._endColor.a);
|
|
982
|
+
},
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* set end color and end color variation of each particle
|
|
986
|
+
* @param {cc.Color} endColor
|
|
987
|
+
*/
|
|
988
|
+
setEndColor:function (endColor) {
|
|
989
|
+
this._endColor = cc.color(endColor);
|
|
990
|
+
},
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* get end color variance of each particle
|
|
994
|
+
* @return {cc.Color}
|
|
995
|
+
*/
|
|
996
|
+
getEndColorVar:function () {
|
|
997
|
+
return cc.color(this._endColorVar.r, this._endColorVar.g, this._endColorVar.b, this._endColorVar.a);
|
|
998
|
+
},
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* set end color variance of each particle
|
|
1002
|
+
* @param {cc.Color} endColorVar
|
|
1003
|
+
*/
|
|
1004
|
+
setEndColorVar:function (endColorVar) {
|
|
1005
|
+
this._endColorVar = cc.color(endColorVar);
|
|
1006
|
+
},
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* get initial angle of each particle
|
|
1010
|
+
* @return {Number}
|
|
1011
|
+
*/
|
|
1012
|
+
getStartSpin:function () {
|
|
1013
|
+
return this.startSpin;
|
|
1014
|
+
},
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* set initial angle of each particle
|
|
1018
|
+
* @param {Number} startSpin
|
|
1019
|
+
*/
|
|
1020
|
+
setStartSpin:function (startSpin) {
|
|
1021
|
+
this.startSpin = startSpin;
|
|
1022
|
+
},
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* get initial angle variance of each particle
|
|
1026
|
+
* @return {Number}
|
|
1027
|
+
*/
|
|
1028
|
+
getStartSpinVar:function () {
|
|
1029
|
+
return this.startSpinVar;
|
|
1030
|
+
},
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* set initial angle variance of each particle
|
|
1034
|
+
* @param {Number} startSpinVar
|
|
1035
|
+
*/
|
|
1036
|
+
setStartSpinVar:function (startSpinVar) {
|
|
1037
|
+
this.startSpinVar = startSpinVar;
|
|
1038
|
+
},
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* get end angle of each particle
|
|
1042
|
+
* @return {Number}
|
|
1043
|
+
*/
|
|
1044
|
+
getEndSpin:function () {
|
|
1045
|
+
return this.endSpin;
|
|
1046
|
+
},
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* set end angle of each particle
|
|
1050
|
+
* @param {Number} endSpin
|
|
1051
|
+
*/
|
|
1052
|
+
setEndSpin:function (endSpin) {
|
|
1053
|
+
this.endSpin = endSpin;
|
|
1054
|
+
},
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* get end angle variance of each particle
|
|
1058
|
+
* @return {Number}
|
|
1059
|
+
*/
|
|
1060
|
+
getEndSpinVar:function () {
|
|
1061
|
+
return this.endSpinVar;
|
|
1062
|
+
},
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* set end angle variance of each particle
|
|
1066
|
+
* @param {Number} endSpinVar
|
|
1067
|
+
*/
|
|
1068
|
+
setEndSpinVar:function (endSpinVar) {
|
|
1069
|
+
this.endSpinVar = endSpinVar;
|
|
1070
|
+
},
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* get emission rate of the particles
|
|
1074
|
+
* @return {Number}
|
|
1075
|
+
*/
|
|
1076
|
+
getEmissionRate:function () {
|
|
1077
|
+
return this.emissionRate;
|
|
1078
|
+
},
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* set emission rate of the particles
|
|
1082
|
+
* @param {Number} emissionRate
|
|
1083
|
+
*/
|
|
1084
|
+
setEmissionRate:function (emissionRate) {
|
|
1085
|
+
this.emissionRate = emissionRate;
|
|
1086
|
+
},
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* get maximum particles of the system
|
|
1090
|
+
* @return {Number}
|
|
1091
|
+
*/
|
|
1092
|
+
getTotalParticles:function () {
|
|
1093
|
+
return this._totalParticles;
|
|
1094
|
+
},
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* set maximum particles of the system
|
|
1098
|
+
* @param {Number} tp totalParticles
|
|
1099
|
+
*/
|
|
1100
|
+
setTotalParticles:function (tp) {
|
|
1101
|
+
this._renderCmd.setTotalParticles(tp);
|
|
1102
|
+
},
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* get Texture of Particle System
|
|
1106
|
+
* @return {cc.Texture2D}
|
|
1107
|
+
*/
|
|
1108
|
+
getTexture:function () {
|
|
1109
|
+
return this._texture;
|
|
1110
|
+
},
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* set Texture of Particle System
|
|
1114
|
+
* @param {cc.Texture2D } texture
|
|
1115
|
+
*/
|
|
1116
|
+
setTexture:function (texture) {
|
|
1117
|
+
if(!texture)
|
|
1118
|
+
return;
|
|
1119
|
+
|
|
1120
|
+
if(texture.isLoaded()){
|
|
1121
|
+
this.setTextureWithRect(texture, cc.rect(0, 0, texture.width, texture.height));
|
|
1122
|
+
} else {
|
|
1123
|
+
this._textureLoaded = false;
|
|
1124
|
+
texture.addEventListener("load", function(sender){
|
|
1125
|
+
this._textureLoaded = true;
|
|
1126
|
+
this.setTextureWithRect(sender, cc.rect(0, 0, sender.width, sender.height));
|
|
1127
|
+
}, this);
|
|
1128
|
+
}
|
|
1129
|
+
},
|
|
1130
|
+
|
|
1131
|
+
/** conforms to CocosNodeTexture protocol */
|
|
1132
|
+
/**
|
|
1133
|
+
* get BlendFunc of Particle System
|
|
1134
|
+
* @return {cc.BlendFunc}
|
|
1135
|
+
*/
|
|
1136
|
+
getBlendFunc:function () {
|
|
1137
|
+
return this._blendFunc;
|
|
1138
|
+
},
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* set BlendFunc of Particle System
|
|
1142
|
+
* @param {Number} src
|
|
1143
|
+
* @param {Number} dst
|
|
1144
|
+
*/
|
|
1145
|
+
setBlendFunc:function (src, dst) {
|
|
1146
|
+
if (dst === undefined) {
|
|
1147
|
+
if (this._blendFunc != src) {
|
|
1148
|
+
this._blendFunc = src;
|
|
1149
|
+
this._updateBlendFunc();
|
|
1150
|
+
}
|
|
1151
|
+
} else {
|
|
1152
|
+
if (this._blendFunc.src != src || this._blendFunc.dst != dst) {
|
|
1153
|
+
this._blendFunc = {src:src, dst:dst};
|
|
1154
|
+
this._updateBlendFunc();
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
},
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* does the alpha value modify color getter
|
|
1161
|
+
* @return {Boolean}
|
|
1162
|
+
*/
|
|
1163
|
+
isOpacityModifyRGB:function () {
|
|
1164
|
+
return this._opacityModifyRGB;
|
|
1165
|
+
},
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* does the alpha value modify color setter
|
|
1169
|
+
* @param newValue
|
|
1170
|
+
*/
|
|
1171
|
+
setOpacityModifyRGB:function (newValue) {
|
|
1172
|
+
this._opacityModifyRGB = newValue;
|
|
1173
|
+
},
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* <p>whether or not the particles are using blend additive.<br/>
|
|
1177
|
+
* If enabled, the following blending function will be used.<br/>
|
|
1178
|
+
* </p>
|
|
1179
|
+
* @return {Boolean}
|
|
1180
|
+
* @example
|
|
1181
|
+
* source blend function = GL_SRC_ALPHA;
|
|
1182
|
+
* dest blend function = GL_ONE;
|
|
1183
|
+
*/
|
|
1184
|
+
isBlendAdditive:function () {
|
|
1185
|
+
return (( this._blendFunc.src == cc.SRC_ALPHA && this._blendFunc.dst == cc.ONE) || (this._blendFunc.src == cc.ONE && this._blendFunc.dst == cc.ONE));
|
|
1186
|
+
},
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* <p>whether or not the particles are using blend additive.<br/>
|
|
1190
|
+
* If enabled, the following blending function will be used.<br/>
|
|
1191
|
+
* </p>
|
|
1192
|
+
* @param {Boolean} isBlendAdditive
|
|
1193
|
+
*/
|
|
1194
|
+
setBlendAdditive:function (isBlendAdditive) {
|
|
1195
|
+
var locBlendFunc = this._blendFunc;
|
|
1196
|
+
if (isBlendAdditive) {
|
|
1197
|
+
locBlendFunc.src = cc.SRC_ALPHA;
|
|
1198
|
+
locBlendFunc.dst = cc.ONE;
|
|
1199
|
+
} else {
|
|
1200
|
+
this._renderCmd._setBlendAdditive();
|
|
1201
|
+
}
|
|
1202
|
+
},
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* get particles movement type: Free or Grouped
|
|
1206
|
+
* @return {Number}
|
|
1207
|
+
*/
|
|
1208
|
+
getPositionType:function () {
|
|
1209
|
+
return this.positionType;
|
|
1210
|
+
},
|
|
1211
|
+
|
|
1212
|
+
/**
|
|
1213
|
+
* set particles movement type: Free or Grouped
|
|
1214
|
+
* @param {Number} positionType
|
|
1215
|
+
*/
|
|
1216
|
+
setPositionType:function (positionType) {
|
|
1217
|
+
this.positionType = positionType;
|
|
1218
|
+
},
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* <p> return whether or not the node will be auto-removed when it has no particles left.<br/>
|
|
1222
|
+
* By default it is false.<br/>
|
|
1223
|
+
* </p>
|
|
1224
|
+
* @return {Boolean}
|
|
1225
|
+
*/
|
|
1226
|
+
isAutoRemoveOnFinish:function () {
|
|
1227
|
+
return this.autoRemoveOnFinish;
|
|
1228
|
+
},
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* <p> set whether or not the node will be auto-removed when it has no particles left.<br/>
|
|
1232
|
+
* By default it is false.<br/>
|
|
1233
|
+
* </p>
|
|
1234
|
+
* @param {Boolean} isAutoRemoveOnFinish
|
|
1235
|
+
*/
|
|
1236
|
+
setAutoRemoveOnFinish:function (isAutoRemoveOnFinish) {
|
|
1237
|
+
this.autoRemoveOnFinish = isAutoRemoveOnFinish;
|
|
1238
|
+
},
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* return kind of emitter modes
|
|
1242
|
+
* @return {Number}
|
|
1243
|
+
*/
|
|
1244
|
+
getEmitterMode:function () {
|
|
1245
|
+
return this.emitterMode;
|
|
1246
|
+
},
|
|
1247
|
+
|
|
1248
|
+
/**
|
|
1249
|
+
* <p>Switch between different kind of emitter modes:<br/>
|
|
1250
|
+
* - CCParticleSystem.MODE_GRAVITY: uses gravity, speed, radial and tangential acceleration<br/>
|
|
1251
|
+
* - CCParticleSystem.MODE_RADIUS: uses radius movement + rotation <br/>
|
|
1252
|
+
* </p>
|
|
1253
|
+
* @param {Number} emitterMode
|
|
1254
|
+
*/
|
|
1255
|
+
setEmitterMode:function (emitterMode) {
|
|
1256
|
+
this.emitterMode = emitterMode;
|
|
1257
|
+
},
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* initializes a cc.ParticleSystem
|
|
1261
|
+
*/
|
|
1262
|
+
init:function () {
|
|
1263
|
+
return this.initWithTotalParticles(150);
|
|
1264
|
+
},
|
|
1265
|
+
|
|
1266
|
+
/**
|
|
1267
|
+
* <p>
|
|
1268
|
+
* initializes a CCParticleSystem from a plist file. <br/>
|
|
1269
|
+
* This plist files can be creted manually or with Particle Designer:<br/>
|
|
1270
|
+
* http://particledesigner.71squared.com/
|
|
1271
|
+
* </p>
|
|
1272
|
+
* @param {String} plistFile
|
|
1273
|
+
* @return {boolean}
|
|
1274
|
+
*/
|
|
1275
|
+
initWithFile:function (plistFile) {
|
|
1276
|
+
this._plistFile = plistFile;
|
|
1277
|
+
var dict = cc.loader.getRes(plistFile);
|
|
1278
|
+
if(!dict){
|
|
1279
|
+
cc.log("cc.ParticleSystem.initWithFile(): Particles: file not found");
|
|
1280
|
+
return false;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
// XXX compute path from a path, should define a function somewhere to do it
|
|
1284
|
+
return this.initWithDictionary(dict, "");
|
|
1285
|
+
},
|
|
1286
|
+
|
|
1287
|
+
/**
|
|
1288
|
+
* return bounding box of particle system in world space
|
|
1289
|
+
* @return {cc.Rect}
|
|
1290
|
+
*/
|
|
1291
|
+
getBoundingBoxToWorld:function () {
|
|
1292
|
+
return cc.rect(0, 0, cc._canvas.width, cc._canvas.height);
|
|
1293
|
+
},
|
|
1294
|
+
|
|
1295
|
+
/**
|
|
1296
|
+
* initializes a particle system from a NSDictionary and the path from where to load the png
|
|
1297
|
+
* @param {object} dictionary
|
|
1298
|
+
* @param {String} dirname
|
|
1299
|
+
* @return {Boolean}
|
|
1300
|
+
*/
|
|
1301
|
+
initWithDictionary:function (dictionary, dirname) {
|
|
1302
|
+
var ret = false;
|
|
1303
|
+
var buffer = null;
|
|
1304
|
+
var image = null;
|
|
1305
|
+
var locValueForKey = this._valueForKey;
|
|
1306
|
+
|
|
1307
|
+
var maxParticles = parseInt(locValueForKey("maxParticles", dictionary));
|
|
1308
|
+
// self, not super
|
|
1309
|
+
if (this.initWithTotalParticles(maxParticles)) {
|
|
1310
|
+
// angle
|
|
1311
|
+
this.angle = parseFloat(locValueForKey("angle", dictionary));
|
|
1312
|
+
this.angleVar = parseFloat(locValueForKey("angleVariance", dictionary));
|
|
1313
|
+
|
|
1314
|
+
// duration
|
|
1315
|
+
this.duration = parseFloat(locValueForKey("duration", dictionary));
|
|
1316
|
+
|
|
1317
|
+
// blend function
|
|
1318
|
+
this._blendFunc.src = parseInt(locValueForKey("blendFuncSource", dictionary));
|
|
1319
|
+
this._blendFunc.dst = parseInt(locValueForKey("blendFuncDestination", dictionary));
|
|
1320
|
+
|
|
1321
|
+
// color
|
|
1322
|
+
var locStartColor = this._startColor;
|
|
1323
|
+
locStartColor.r = parseFloat(locValueForKey("startColorRed", dictionary)) * 255;
|
|
1324
|
+
locStartColor.g = parseFloat(locValueForKey("startColorGreen", dictionary)) * 255;
|
|
1325
|
+
locStartColor.b = parseFloat(locValueForKey("startColorBlue", dictionary)) * 255;
|
|
1326
|
+
locStartColor.a = parseFloat(locValueForKey("startColorAlpha", dictionary)) * 255;
|
|
1327
|
+
|
|
1328
|
+
var locStartColorVar = this._startColorVar;
|
|
1329
|
+
locStartColorVar.r = parseFloat(locValueForKey("startColorVarianceRed", dictionary)) * 255;
|
|
1330
|
+
locStartColorVar.g = parseFloat(locValueForKey("startColorVarianceGreen", dictionary)) * 255;
|
|
1331
|
+
locStartColorVar.b = parseFloat(locValueForKey("startColorVarianceBlue", dictionary)) * 255;
|
|
1332
|
+
locStartColorVar.a = parseFloat(locValueForKey("startColorVarianceAlpha", dictionary)) * 255;
|
|
1333
|
+
|
|
1334
|
+
var locEndColor = this._endColor;
|
|
1335
|
+
locEndColor.r = parseFloat(locValueForKey("finishColorRed", dictionary)) * 255;
|
|
1336
|
+
locEndColor.g = parseFloat(locValueForKey("finishColorGreen", dictionary)) * 255;
|
|
1337
|
+
locEndColor.b = parseFloat(locValueForKey("finishColorBlue", dictionary)) * 255;
|
|
1338
|
+
locEndColor.a = parseFloat(locValueForKey("finishColorAlpha", dictionary)) * 255;
|
|
1339
|
+
|
|
1340
|
+
var locEndColorVar = this._endColorVar;
|
|
1341
|
+
locEndColorVar.r = parseFloat(locValueForKey("finishColorVarianceRed", dictionary)) * 255;
|
|
1342
|
+
locEndColorVar.g = parseFloat(locValueForKey("finishColorVarianceGreen", dictionary)) * 255;
|
|
1343
|
+
locEndColorVar.b = parseFloat(locValueForKey("finishColorVarianceBlue", dictionary)) * 255;
|
|
1344
|
+
locEndColorVar.a = parseFloat(locValueForKey("finishColorVarianceAlpha", dictionary)) * 255;
|
|
1345
|
+
|
|
1346
|
+
// particle size
|
|
1347
|
+
this.startSize = parseFloat(locValueForKey("startParticleSize", dictionary));
|
|
1348
|
+
this.startSizeVar = parseFloat(locValueForKey("startParticleSizeVariance", dictionary));
|
|
1349
|
+
this.endSize = parseFloat(locValueForKey("finishParticleSize", dictionary));
|
|
1350
|
+
this.endSizeVar = parseFloat(locValueForKey("finishParticleSizeVariance", dictionary));
|
|
1351
|
+
|
|
1352
|
+
// position
|
|
1353
|
+
this.setPosition(parseFloat(locValueForKey("sourcePositionx", dictionary)),
|
|
1354
|
+
parseFloat(locValueForKey("sourcePositiony", dictionary)));
|
|
1355
|
+
this._posVar.x = parseFloat(locValueForKey("sourcePositionVariancex", dictionary));
|
|
1356
|
+
this._posVar.y = parseFloat(locValueForKey("sourcePositionVariancey", dictionary));
|
|
1357
|
+
|
|
1358
|
+
// Spinning
|
|
1359
|
+
this.startSpin = parseFloat(locValueForKey("rotationStart", dictionary));
|
|
1360
|
+
this.startSpinVar = parseFloat(locValueForKey("rotationStartVariance", dictionary));
|
|
1361
|
+
this.endSpin = parseFloat(locValueForKey("rotationEnd", dictionary));
|
|
1362
|
+
this.endSpinVar = parseFloat(locValueForKey("rotationEndVariance", dictionary));
|
|
1363
|
+
|
|
1364
|
+
this.emitterMode = parseInt(locValueForKey("emitterType", dictionary));
|
|
1365
|
+
|
|
1366
|
+
// Mode A: Gravity + tangential accel + radial accel
|
|
1367
|
+
if (this.emitterMode == cc.ParticleSystem.MODE_GRAVITY) {
|
|
1368
|
+
var locModeA = this.modeA;
|
|
1369
|
+
// gravity
|
|
1370
|
+
locModeA.gravity.x = parseFloat(locValueForKey("gravityx", dictionary));
|
|
1371
|
+
locModeA.gravity.y = parseFloat(locValueForKey("gravityy", dictionary));
|
|
1372
|
+
|
|
1373
|
+
// speed
|
|
1374
|
+
locModeA.speed = parseFloat(locValueForKey("speed", dictionary));
|
|
1375
|
+
locModeA.speedVar = parseFloat(locValueForKey("speedVariance", dictionary));
|
|
1376
|
+
|
|
1377
|
+
// radial acceleration
|
|
1378
|
+
var pszTmp = locValueForKey("radialAcceleration", dictionary);
|
|
1379
|
+
locModeA.radialAccel = (pszTmp) ? parseFloat(pszTmp) : 0;
|
|
1380
|
+
|
|
1381
|
+
pszTmp = locValueForKey("radialAccelVariance", dictionary);
|
|
1382
|
+
locModeA.radialAccelVar = (pszTmp) ? parseFloat(pszTmp) : 0;
|
|
1383
|
+
|
|
1384
|
+
// tangential acceleration
|
|
1385
|
+
pszTmp = locValueForKey("tangentialAcceleration", dictionary);
|
|
1386
|
+
locModeA.tangentialAccel = (pszTmp) ? parseFloat(pszTmp) : 0;
|
|
1387
|
+
|
|
1388
|
+
pszTmp = locValueForKey("tangentialAccelVariance", dictionary);
|
|
1389
|
+
locModeA.tangentialAccelVar = (pszTmp) ? parseFloat(pszTmp) : 0;
|
|
1390
|
+
|
|
1391
|
+
// rotation is dir
|
|
1392
|
+
var locRotationIsDir = locValueForKey("rotationIsDir", dictionary).toLowerCase();
|
|
1393
|
+
locModeA.rotationIsDir = (locRotationIsDir != null && (locRotationIsDir === "true" || locRotationIsDir === "1"));
|
|
1394
|
+
} else if (this.emitterMode == cc.ParticleSystem.MODE_RADIUS) {
|
|
1395
|
+
// or Mode B: radius movement
|
|
1396
|
+
var locModeB = this.modeB;
|
|
1397
|
+
locModeB.startRadius = parseFloat(locValueForKey("maxRadius", dictionary));
|
|
1398
|
+
locModeB.startRadiusVar = parseFloat(locValueForKey("maxRadiusVariance", dictionary));
|
|
1399
|
+
locModeB.endRadius = parseFloat(locValueForKey("minRadius", dictionary));
|
|
1400
|
+
locModeB.endRadiusVar = 0;
|
|
1401
|
+
locModeB.rotatePerSecond = parseFloat(locValueForKey("rotatePerSecond", dictionary));
|
|
1402
|
+
locModeB.rotatePerSecondVar = parseFloat(locValueForKey("rotatePerSecondVariance", dictionary));
|
|
1403
|
+
} else {
|
|
1404
|
+
cc.log("cc.ParticleSystem.initWithDictionary(): Invalid emitterType in config file");
|
|
1405
|
+
return false;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
// life span
|
|
1409
|
+
this.life = parseFloat(locValueForKey("particleLifespan", dictionary));
|
|
1410
|
+
this.lifeVar = parseFloat(locValueForKey("particleLifespanVariance", dictionary));
|
|
1411
|
+
|
|
1412
|
+
// emission Rate
|
|
1413
|
+
this.emissionRate = this._totalParticles / this.life;
|
|
1414
|
+
|
|
1415
|
+
//don't get the internal texture if a batchNode is used
|
|
1416
|
+
if (!this._batchNode) {
|
|
1417
|
+
// Set a compatible default for the alpha transfer
|
|
1418
|
+
this._opacityModifyRGB = false;
|
|
1419
|
+
|
|
1420
|
+
// texture
|
|
1421
|
+
// Try to get the texture from the cache
|
|
1422
|
+
var textureName = locValueForKey("textureFileName", dictionary);
|
|
1423
|
+
var imgPath = cc.path.changeBasename(this._plistFile, textureName);
|
|
1424
|
+
var tex = cc.textureCache.getTextureForKey(imgPath);
|
|
1425
|
+
|
|
1426
|
+
if (tex) {
|
|
1427
|
+
this.setTexture(tex);
|
|
1428
|
+
} else {
|
|
1429
|
+
var textureData = locValueForKey("textureImageData", dictionary);
|
|
1430
|
+
|
|
1431
|
+
if (!textureData || textureData.length === 0) {
|
|
1432
|
+
tex = cc.textureCache.addImage(imgPath);
|
|
1433
|
+
if (!tex)
|
|
1434
|
+
return false;
|
|
1435
|
+
this.setTexture(tex);
|
|
1436
|
+
} else {
|
|
1437
|
+
buffer = cc.unzipBase64AsArray(textureData, 1);
|
|
1438
|
+
if (!buffer) {
|
|
1439
|
+
cc.log("cc.ParticleSystem: error decoding or ungzipping textureImageData");
|
|
1440
|
+
return false;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
var imageFormat = cc.getImageFormatByData(buffer);
|
|
1444
|
+
|
|
1445
|
+
if(imageFormat !== cc.FMT_TIFF && imageFormat !== cc.FMT_PNG){
|
|
1446
|
+
cc.log("cc.ParticleSystem: unknown image format with Data");
|
|
1447
|
+
return false;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
var canvasObj = cc.newElement("canvas");
|
|
1451
|
+
if(imageFormat === cc.FMT_PNG){
|
|
1452
|
+
var myPngObj = new cc.PNGReader(buffer);
|
|
1453
|
+
myPngObj.render(canvasObj);
|
|
1454
|
+
} else {
|
|
1455
|
+
var myTIFFObj = cc.tiffReader;
|
|
1456
|
+
myTIFFObj.parseTIFF(buffer,canvasObj);
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
cc.textureCache.cacheImage(imgPath, canvasObj);
|
|
1460
|
+
|
|
1461
|
+
var addTexture = cc.textureCache.getTextureForKey(imgPath);
|
|
1462
|
+
if(!addTexture)
|
|
1463
|
+
cc.log("cc.ParticleSystem.initWithDictionary() : error loading the texture");
|
|
1464
|
+
this.setTexture(addTexture);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
ret = true;
|
|
1469
|
+
}
|
|
1470
|
+
return ret;
|
|
1471
|
+
},
|
|
1472
|
+
|
|
1473
|
+
/**
|
|
1474
|
+
* Initializes a system with a fixed number of particles
|
|
1475
|
+
* @param {Number} numberOfParticles
|
|
1476
|
+
* @return {Boolean}
|
|
1477
|
+
*/
|
|
1478
|
+
initWithTotalParticles:function (numberOfParticles) {
|
|
1479
|
+
this._totalParticles = numberOfParticles;
|
|
1480
|
+
|
|
1481
|
+
var i, locParticles = this._particles;
|
|
1482
|
+
locParticles.length = 0;
|
|
1483
|
+
for(i = 0; i< numberOfParticles; i++){
|
|
1484
|
+
locParticles[i] = new cc.Particle();
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
if (!locParticles) {
|
|
1488
|
+
cc.log("Particle system: not enough memory");
|
|
1489
|
+
return false;
|
|
1490
|
+
}
|
|
1491
|
+
this._allocatedParticles = numberOfParticles;
|
|
1492
|
+
|
|
1493
|
+
if (this._batchNode)
|
|
1494
|
+
for (i = 0; i < this._totalParticles; i++)
|
|
1495
|
+
locParticles[i].atlasIndex = i;
|
|
1496
|
+
|
|
1497
|
+
// default, active
|
|
1498
|
+
this._isActive = true;
|
|
1499
|
+
|
|
1500
|
+
// default blend function
|
|
1501
|
+
this._blendFunc.src = cc.BLEND_SRC;
|
|
1502
|
+
this._blendFunc.dst = cc.BLEND_DST;
|
|
1503
|
+
|
|
1504
|
+
// default movement type;
|
|
1505
|
+
this.positionType = cc.ParticleSystem.TYPE_FREE;
|
|
1506
|
+
|
|
1507
|
+
// by default be in mode A:
|
|
1508
|
+
this.emitterMode = cc.ParticleSystem.MODE_GRAVITY;
|
|
1509
|
+
|
|
1510
|
+
// default: modulate
|
|
1511
|
+
// XXX: not used
|
|
1512
|
+
// colorModulate = YES;
|
|
1513
|
+
this.autoRemoveOnFinish = false;
|
|
1514
|
+
|
|
1515
|
+
//for batchNode
|
|
1516
|
+
this._transformSystemDirty = false;
|
|
1517
|
+
|
|
1518
|
+
// udpate after action in run!
|
|
1519
|
+
this.scheduleUpdateWithPriority(1);
|
|
1520
|
+
this._renderCmd._initWithTotalParticles(numberOfParticles);
|
|
1521
|
+
return true;
|
|
1522
|
+
},
|
|
1523
|
+
|
|
1524
|
+
/**
|
|
1525
|
+
* Unschedules the "update" method.
|
|
1526
|
+
* @function
|
|
1527
|
+
* @see scheduleUpdate();
|
|
1528
|
+
*/
|
|
1529
|
+
destroyParticleSystem:function () {
|
|
1530
|
+
this.unscheduleUpdate();
|
|
1531
|
+
},
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Add a particle to the emitter
|
|
1535
|
+
* @return {Boolean}
|
|
1536
|
+
*/
|
|
1537
|
+
addParticle: function () {
|
|
1538
|
+
if (this.isFull())
|
|
1539
|
+
return false;
|
|
1540
|
+
|
|
1541
|
+
var particle = this._renderCmd.addParticle();
|
|
1542
|
+
this.initParticle(particle);
|
|
1543
|
+
++this.particleCount;
|
|
1544
|
+
return true;
|
|
1545
|
+
},
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* Initializes a particle
|
|
1549
|
+
* @param {cc.Particle} particle
|
|
1550
|
+
*/
|
|
1551
|
+
initParticle:function (particle) {
|
|
1552
|
+
var locRandomMinus11 = cc.randomMinus1To1;
|
|
1553
|
+
// timeToLive
|
|
1554
|
+
// no negative life. prevent division by 0
|
|
1555
|
+
particle.timeToLive = this.life + this.lifeVar * locRandomMinus11();
|
|
1556
|
+
particle.timeToLive = Math.max(0, particle.timeToLive);
|
|
1557
|
+
|
|
1558
|
+
// position
|
|
1559
|
+
particle.pos.x = this._sourcePosition.x + this._posVar.x * locRandomMinus11();
|
|
1560
|
+
particle.pos.y = this._sourcePosition.y + this._posVar.y * locRandomMinus11();
|
|
1561
|
+
|
|
1562
|
+
// Color
|
|
1563
|
+
var start, end;
|
|
1564
|
+
var locStartColor = this._startColor, locStartColorVar = this._startColorVar;
|
|
1565
|
+
var locEndColor = this._endColor, locEndColorVar = this._endColorVar;
|
|
1566
|
+
start = {
|
|
1567
|
+
r: cc.clampf(locStartColor.r + locStartColorVar.r * locRandomMinus11(), 0, 255),
|
|
1568
|
+
g: cc.clampf(locStartColor.g + locStartColorVar.g * locRandomMinus11(), 0, 255),
|
|
1569
|
+
b: cc.clampf(locStartColor.b + locStartColorVar.b * locRandomMinus11(), 0, 255),
|
|
1570
|
+
a: cc.clampf(locStartColor.a + locStartColorVar.a * locRandomMinus11(), 0, 255)
|
|
1571
|
+
};
|
|
1572
|
+
end = {
|
|
1573
|
+
r: cc.clampf(locEndColor.r + locEndColorVar.r * locRandomMinus11(), 0, 255),
|
|
1574
|
+
g: cc.clampf(locEndColor.g + locEndColorVar.g * locRandomMinus11(), 0, 255),
|
|
1575
|
+
b: cc.clampf(locEndColor.b + locEndColorVar.b * locRandomMinus11(), 0, 255),
|
|
1576
|
+
a: cc.clampf(locEndColor.a + locEndColorVar.a * locRandomMinus11(), 0, 255)
|
|
1577
|
+
};
|
|
1578
|
+
|
|
1579
|
+
particle.color = start;
|
|
1580
|
+
var locParticleDeltaColor = particle.deltaColor, locParticleTimeToLive = particle.timeToLive;
|
|
1581
|
+
locParticleDeltaColor.r = (end.r - start.r) / locParticleTimeToLive;
|
|
1582
|
+
locParticleDeltaColor.g = (end.g - start.g) / locParticleTimeToLive;
|
|
1583
|
+
locParticleDeltaColor.b = (end.b - start.b) / locParticleTimeToLive;
|
|
1584
|
+
locParticleDeltaColor.a = (end.a - start.a) / locParticleTimeToLive;
|
|
1585
|
+
|
|
1586
|
+
// size
|
|
1587
|
+
var startS = this.startSize + this.startSizeVar * locRandomMinus11();
|
|
1588
|
+
startS = Math.max(0, startS); // No negative value
|
|
1589
|
+
|
|
1590
|
+
particle.size = startS;
|
|
1591
|
+
if (this.endSize === cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE) {
|
|
1592
|
+
particle.deltaSize = 0;
|
|
1593
|
+
} else {
|
|
1594
|
+
var endS = this.endSize + this.endSizeVar * locRandomMinus11();
|
|
1595
|
+
endS = Math.max(0, endS); // No negative values
|
|
1596
|
+
particle.deltaSize = (endS - startS) / locParticleTimeToLive;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
// rotation
|
|
1600
|
+
var startA = this.startSpin + this.startSpinVar * locRandomMinus11();
|
|
1601
|
+
var endA = this.endSpin + this.endSpinVar * locRandomMinus11();
|
|
1602
|
+
particle.rotation = startA;
|
|
1603
|
+
particle.deltaRotation = (endA - startA) / locParticleTimeToLive;
|
|
1604
|
+
|
|
1605
|
+
// position
|
|
1606
|
+
if (this.positionType == cc.ParticleSystem.TYPE_FREE)
|
|
1607
|
+
particle.startPos = this.convertToWorldSpace(this._pointZeroForParticle);
|
|
1608
|
+
else if (this.positionType == cc.ParticleSystem.TYPE_RELATIVE){
|
|
1609
|
+
particle.startPos.x = this._position.x;
|
|
1610
|
+
particle.startPos.y = this._position.y;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
// direction
|
|
1614
|
+
var a = cc.degreesToRadians(this.angle + this.angleVar * locRandomMinus11());
|
|
1615
|
+
|
|
1616
|
+
// Mode Gravity: A
|
|
1617
|
+
if (this.emitterMode === cc.ParticleSystem.MODE_GRAVITY) {
|
|
1618
|
+
var locModeA = this.modeA, locParticleModeA = particle.modeA;
|
|
1619
|
+
var s = locModeA.speed + locModeA.speedVar * locRandomMinus11();
|
|
1620
|
+
|
|
1621
|
+
// direction
|
|
1622
|
+
locParticleModeA.dir.x = Math.cos(a);
|
|
1623
|
+
locParticleModeA.dir.y = Math.sin(a);
|
|
1624
|
+
cc.pMultIn(locParticleModeA.dir, s);
|
|
1625
|
+
|
|
1626
|
+
// radial accel
|
|
1627
|
+
locParticleModeA.radialAccel = locModeA.radialAccel + locModeA.radialAccelVar * locRandomMinus11();
|
|
1628
|
+
|
|
1629
|
+
// tangential accel
|
|
1630
|
+
locParticleModeA.tangentialAccel = locModeA.tangentialAccel + locModeA.tangentialAccelVar * locRandomMinus11();
|
|
1631
|
+
|
|
1632
|
+
// rotation is dir
|
|
1633
|
+
if(locModeA.rotationIsDir)
|
|
1634
|
+
particle.rotation = -cc.radiansToDegrees(cc.pToAngle(locParticleModeA.dir));
|
|
1635
|
+
} else {
|
|
1636
|
+
// Mode Radius: B
|
|
1637
|
+
var locModeB = this.modeB, locParitlceModeB = particle.modeB;
|
|
1638
|
+
|
|
1639
|
+
// Set the default diameter of the particle from the source position
|
|
1640
|
+
var startRadius = locModeB.startRadius + locModeB.startRadiusVar * locRandomMinus11();
|
|
1641
|
+
var endRadius = locModeB.endRadius + locModeB.endRadiusVar * locRandomMinus11();
|
|
1642
|
+
|
|
1643
|
+
locParitlceModeB.radius = startRadius;
|
|
1644
|
+
locParitlceModeB.deltaRadius = (locModeB.endRadius === cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS) ? 0 : (endRadius - startRadius) / locParticleTimeToLive;
|
|
1645
|
+
|
|
1646
|
+
locParitlceModeB.angle = a;
|
|
1647
|
+
locParitlceModeB.degreesPerSecond = cc.degreesToRadians(locModeB.rotatePerSecond + locModeB.rotatePerSecondVar * locRandomMinus11());
|
|
1648
|
+
}
|
|
1649
|
+
},
|
|
1650
|
+
|
|
1651
|
+
/**
|
|
1652
|
+
* stop emitting particles. Running particles will continue to run until they die
|
|
1653
|
+
*/
|
|
1654
|
+
stopSystem:function () {
|
|
1655
|
+
this._isActive = false;
|
|
1656
|
+
this._elapsed = this.duration;
|
|
1657
|
+
this._emitCounter = 0;
|
|
1658
|
+
},
|
|
1659
|
+
|
|
1660
|
+
/**
|
|
1661
|
+
* Kill all living particles.
|
|
1662
|
+
*/
|
|
1663
|
+
resetSystem:function () {
|
|
1664
|
+
this._isActive = true;
|
|
1665
|
+
this._elapsed = 0;
|
|
1666
|
+
var locParticles = this._particles;
|
|
1667
|
+
for (this._particleIdx = 0; this._particleIdx < this.particleCount; ++this._particleIdx)
|
|
1668
|
+
locParticles[this._particleIdx].timeToLive = 0 ;
|
|
1669
|
+
},
|
|
1670
|
+
|
|
1671
|
+
/**
|
|
1672
|
+
* whether or not the system is full
|
|
1673
|
+
* @return {Boolean}
|
|
1674
|
+
*/
|
|
1675
|
+
isFull:function () {
|
|
1676
|
+
return (this.particleCount >= this._totalParticles);
|
|
1677
|
+
},
|
|
1678
|
+
|
|
1679
|
+
/**
|
|
1680
|
+
* should be overridden by subclasses
|
|
1681
|
+
* @param {cc.Particle} particle
|
|
1682
|
+
* @param {cc.Point} newPosition
|
|
1683
|
+
*/
|
|
1684
|
+
updateQuadWithParticle:function (particle, newPosition) {
|
|
1685
|
+
this._renderCmd.updateQuadWithParticle(particle, newPosition);
|
|
1686
|
+
},
|
|
1687
|
+
|
|
1688
|
+
/**
|
|
1689
|
+
* should be overridden by subclasses
|
|
1690
|
+
*/
|
|
1691
|
+
postStep:function () {
|
|
1692
|
+
this._renderCmd.postStep();
|
|
1693
|
+
},
|
|
1694
|
+
|
|
1695
|
+
/**
|
|
1696
|
+
* update emitter's status
|
|
1697
|
+
* @override
|
|
1698
|
+
* @param {Number} dt delta time
|
|
1699
|
+
*/
|
|
1700
|
+
update:function (dt) {
|
|
1701
|
+
if (this._isActive && this.emissionRate) {
|
|
1702
|
+
var rate = 1.0 / this.emissionRate;
|
|
1703
|
+
//issue #1201, prevent bursts of particles, due to too high emitCounter
|
|
1704
|
+
if (this.particleCount < this._totalParticles)
|
|
1705
|
+
this._emitCounter += dt;
|
|
1706
|
+
|
|
1707
|
+
while ((this.particleCount < this._totalParticles) && (this._emitCounter > rate)) {
|
|
1708
|
+
this.addParticle();
|
|
1709
|
+
this._emitCounter -= rate;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
this._elapsed += dt;
|
|
1713
|
+
if (this.duration != -1 && this.duration < this._elapsed)
|
|
1714
|
+
this.stopSystem();
|
|
1715
|
+
}
|
|
1716
|
+
this._particleIdx = 0;
|
|
1717
|
+
|
|
1718
|
+
var currentPosition = cc.Particle.TemporaryPoints[0];
|
|
1719
|
+
if (this.positionType == cc.ParticleSystem.TYPE_FREE) {
|
|
1720
|
+
cc.pIn(currentPosition, this.convertToWorldSpace(this._pointZeroForParticle));
|
|
1721
|
+
} else if (this.positionType == cc.ParticleSystem.TYPE_RELATIVE) {
|
|
1722
|
+
currentPosition.x = this._position.x;
|
|
1723
|
+
currentPosition.y = this._position.y;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
if (this._visible) {
|
|
1727
|
+
// Used to reduce memory allocation / creation within the loop
|
|
1728
|
+
var tpa = cc.Particle.TemporaryPoints[1],
|
|
1729
|
+
tpb = cc.Particle.TemporaryPoints[2],
|
|
1730
|
+
tpc = cc.Particle.TemporaryPoints[3];
|
|
1731
|
+
|
|
1732
|
+
var locParticles = this._particles;
|
|
1733
|
+
while (this._particleIdx < this.particleCount) {
|
|
1734
|
+
|
|
1735
|
+
// Reset the working particles
|
|
1736
|
+
cc.pZeroIn(tpa);
|
|
1737
|
+
cc.pZeroIn(tpb);
|
|
1738
|
+
cc.pZeroIn(tpc);
|
|
1739
|
+
|
|
1740
|
+
var selParticle = locParticles[this._particleIdx];
|
|
1741
|
+
|
|
1742
|
+
// life
|
|
1743
|
+
selParticle.timeToLive -= dt;
|
|
1744
|
+
|
|
1745
|
+
if (selParticle.timeToLive > 0) {
|
|
1746
|
+
// Mode A: gravity, direction, tangential accel & radial accel
|
|
1747
|
+
if (this.emitterMode == cc.ParticleSystem.MODE_GRAVITY) {
|
|
1748
|
+
|
|
1749
|
+
var tmp = tpc, radial = tpa, tangential = tpb;
|
|
1750
|
+
|
|
1751
|
+
// radial acceleration
|
|
1752
|
+
if (selParticle.pos.x || selParticle.pos.y) {
|
|
1753
|
+
cc.pIn(radial, selParticle.pos);
|
|
1754
|
+
cc.pNormalizeIn(radial);
|
|
1755
|
+
} else {
|
|
1756
|
+
cc.pZeroIn(radial);
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
cc.pIn(tangential, radial);
|
|
1760
|
+
cc.pMultIn(radial, selParticle.modeA.radialAccel);
|
|
1761
|
+
|
|
1762
|
+
// tangential acceleration
|
|
1763
|
+
var newy = tangential.x;
|
|
1764
|
+
tangential.x = -tangential.y;
|
|
1765
|
+
tangential.y = newy;
|
|
1766
|
+
|
|
1767
|
+
cc.pMultIn(tangential, selParticle.modeA.tangentialAccel);
|
|
1768
|
+
|
|
1769
|
+
cc.pIn(tmp, radial);
|
|
1770
|
+
cc.pAddIn(tmp, tangential);
|
|
1771
|
+
cc.pAddIn(tmp, this.modeA.gravity);
|
|
1772
|
+
cc.pMultIn(tmp, dt);
|
|
1773
|
+
cc.pAddIn(selParticle.modeA.dir, tmp);
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
cc.pIn(tmp, selParticle.modeA.dir);
|
|
1777
|
+
cc.pMultIn(tmp, dt);
|
|
1778
|
+
cc.pAddIn(selParticle.pos, tmp);
|
|
1779
|
+
} else {
|
|
1780
|
+
// Mode B: radius movement
|
|
1781
|
+
var selModeB = selParticle.modeB;
|
|
1782
|
+
// Update the angle and radius of the particle.
|
|
1783
|
+
selModeB.angle += selModeB.degreesPerSecond * dt;
|
|
1784
|
+
selModeB.radius += selModeB.deltaRadius * dt;
|
|
1785
|
+
|
|
1786
|
+
selParticle.pos.x = -Math.cos(selModeB.angle) * selModeB.radius;
|
|
1787
|
+
selParticle.pos.y = -Math.sin(selModeB.angle) * selModeB.radius;
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
// color
|
|
1791
|
+
this._renderCmd._updateDeltaColor(selParticle, dt);
|
|
1792
|
+
|
|
1793
|
+
// size
|
|
1794
|
+
selParticle.size += (selParticle.deltaSize * dt);
|
|
1795
|
+
selParticle.size = Math.max(0, selParticle.size);
|
|
1796
|
+
|
|
1797
|
+
// angle
|
|
1798
|
+
selParticle.rotation += (selParticle.deltaRotation * dt);
|
|
1799
|
+
|
|
1800
|
+
//
|
|
1801
|
+
// update values in quad
|
|
1802
|
+
//
|
|
1803
|
+
var newPos = tpa;
|
|
1804
|
+
if (this.positionType == cc.ParticleSystem.TYPE_FREE || this.positionType == cc.ParticleSystem.TYPE_RELATIVE) {
|
|
1805
|
+
var diff = tpb;
|
|
1806
|
+
cc.pIn(diff, currentPosition);
|
|
1807
|
+
cc.pSubIn(diff, selParticle.startPos);
|
|
1808
|
+
|
|
1809
|
+
cc.pIn(newPos, selParticle.pos);
|
|
1810
|
+
cc.pSubIn(newPos, diff);
|
|
1811
|
+
} else {
|
|
1812
|
+
cc.pIn(newPos, selParticle.pos);
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
// translate newPos to correct position, since matrix transform isn't performed in batchnode
|
|
1816
|
+
// don't update the particle with the new position information, it will interfere with the radius and tangential calculations
|
|
1817
|
+
if (this._batchNode) {
|
|
1818
|
+
newPos.x += this._position.x;
|
|
1819
|
+
newPos.y += this._position.y;
|
|
1820
|
+
}
|
|
1821
|
+
this._renderCmd.updateParticlePosition(selParticle, newPos);
|
|
1822
|
+
|
|
1823
|
+
// update particle counter
|
|
1824
|
+
++this._particleIdx;
|
|
1825
|
+
} else {
|
|
1826
|
+
// life < 0
|
|
1827
|
+
var currentIndex = selParticle.atlasIndex;
|
|
1828
|
+
if(this._particleIdx !== this.particleCount -1){
|
|
1829
|
+
var deadParticle = locParticles[this._particleIdx];
|
|
1830
|
+
locParticles[this._particleIdx] = locParticles[this.particleCount -1];
|
|
1831
|
+
locParticles[this.particleCount -1] = deadParticle;
|
|
1832
|
+
}
|
|
1833
|
+
if (this._batchNode) {
|
|
1834
|
+
//disable the switched particle
|
|
1835
|
+
this._batchNode.disableParticle(this.atlasIndex + currentIndex);
|
|
1836
|
+
//switch indexes
|
|
1837
|
+
locParticles[this.particleCount - 1].atlasIndex = currentIndex;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
--this.particleCount;
|
|
1841
|
+
if (this.particleCount == 0 && this.autoRemoveOnFinish) {
|
|
1842
|
+
this.unscheduleUpdate();
|
|
1843
|
+
this._parent.removeChild(this, true);
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
this._transformSystemDirty = false;
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
if (!this._batchNode)
|
|
1852
|
+
this.postStep();
|
|
1853
|
+
},
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* update emitter's status (dt = 0)
|
|
1857
|
+
*/
|
|
1858
|
+
updateWithNoTime:function () {
|
|
1859
|
+
this.update(0);
|
|
1860
|
+
},
|
|
1861
|
+
|
|
1862
|
+
//
|
|
1863
|
+
// return the string found by key in dict.
|
|
1864
|
+
// @param {string} key
|
|
1865
|
+
// @param {object} dict
|
|
1866
|
+
// @return {String} "" if not found; return the string if found.
|
|
1867
|
+
// @private
|
|
1868
|
+
//
|
|
1869
|
+
_valueForKey:function (key, dict) {
|
|
1870
|
+
if (dict) {
|
|
1871
|
+
var pString = dict[key];
|
|
1872
|
+
return pString != null ? pString : "";
|
|
1873
|
+
}
|
|
1874
|
+
return "";
|
|
1875
|
+
},
|
|
1876
|
+
|
|
1877
|
+
_updateBlendFunc:function () {
|
|
1878
|
+
if(this._batchNode){
|
|
1879
|
+
cc.log("Can't change blending functions when the particle is being batched");
|
|
1880
|
+
return;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
var locTexture = this._texture;
|
|
1884
|
+
if (locTexture && locTexture instanceof cc.Texture2D) {
|
|
1885
|
+
this._opacityModifyRGB = false;
|
|
1886
|
+
var locBlendFunc = this._blendFunc;
|
|
1887
|
+
if (locBlendFunc.src == cc.BLEND_SRC && locBlendFunc.dst == cc.BLEND_DST) {
|
|
1888
|
+
if (locTexture.hasPremultipliedAlpha()) {
|
|
1889
|
+
this._opacityModifyRGB = true;
|
|
1890
|
+
} else {
|
|
1891
|
+
locBlendFunc.src = cc.SRC_ALPHA;
|
|
1892
|
+
locBlendFunc.dst = cc.ONE_MINUS_SRC_ALPHA;
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
},
|
|
1897
|
+
|
|
1898
|
+
/**
|
|
1899
|
+
* to copy object with deep copy.
|
|
1900
|
+
* returns a clone of action.
|
|
1901
|
+
*
|
|
1902
|
+
* @return {cc.ParticleSystem}
|
|
1903
|
+
*/
|
|
1904
|
+
clone:function () {
|
|
1905
|
+
var retParticle = new cc.ParticleSystem();
|
|
1906
|
+
|
|
1907
|
+
// self, not super
|
|
1908
|
+
if (retParticle.initWithTotalParticles(this.getTotalParticles())) {
|
|
1909
|
+
// angle
|
|
1910
|
+
retParticle.setAngle(this.getAngle());
|
|
1911
|
+
retParticle.setAngleVar(this.getAngleVar());
|
|
1912
|
+
|
|
1913
|
+
// duration
|
|
1914
|
+
retParticle.setDuration(this.getDuration());
|
|
1915
|
+
|
|
1916
|
+
// blend function
|
|
1917
|
+
var blend = this.getBlendFunc();
|
|
1918
|
+
retParticle.setBlendFunc(blend.src,blend.dst);
|
|
1919
|
+
|
|
1920
|
+
// color
|
|
1921
|
+
retParticle.setStartColor(this.getStartColor());
|
|
1922
|
+
|
|
1923
|
+
retParticle.setStartColorVar(this.getStartColorVar());
|
|
1924
|
+
|
|
1925
|
+
retParticle.setEndColor(this.getEndColor());
|
|
1926
|
+
|
|
1927
|
+
retParticle.setEndColorVar(this.getEndColorVar());
|
|
1928
|
+
|
|
1929
|
+
// this size
|
|
1930
|
+
retParticle.setStartSize(this.getStartSize());
|
|
1931
|
+
retParticle.setStartSizeVar(this.getStartSizeVar());
|
|
1932
|
+
retParticle.setEndSize(this.getEndSize());
|
|
1933
|
+
retParticle.setEndSizeVar(this.getEndSizeVar());
|
|
1934
|
+
|
|
1935
|
+
// position
|
|
1936
|
+
retParticle.setPosition(cc.p(this.x, this.y));
|
|
1937
|
+
retParticle.setPosVar(cc.p(this.getPosVar().x,this.getPosVar().y));
|
|
1938
|
+
|
|
1939
|
+
// Spinning
|
|
1940
|
+
retParticle.setStartSpin(this.getStartSpin()||0);
|
|
1941
|
+
retParticle.setStartSpinVar(this.getStartSpinVar()||0);
|
|
1942
|
+
retParticle.setEndSpin(this.getEndSpin()||0);
|
|
1943
|
+
retParticle.setEndSpinVar(this.getEndSpinVar()||0);
|
|
1944
|
+
|
|
1945
|
+
retParticle.setEmitterMode(this.getEmitterMode());
|
|
1946
|
+
|
|
1947
|
+
// Mode A: Gravity + tangential accel + radial accel
|
|
1948
|
+
if (this.getEmitterMode() == cc.ParticleSystem.MODE_GRAVITY) {
|
|
1949
|
+
// gravity
|
|
1950
|
+
var gra = this.getGravity();
|
|
1951
|
+
retParticle.setGravity(cc.p(gra.x,gra.y));
|
|
1952
|
+
|
|
1953
|
+
// speed
|
|
1954
|
+
retParticle.setSpeed(this.getSpeed());
|
|
1955
|
+
retParticle.setSpeedVar(this.getSpeedVar());
|
|
1956
|
+
|
|
1957
|
+
// radial acceleration
|
|
1958
|
+
retParticle.setRadialAccel(this.getRadialAccel());
|
|
1959
|
+
retParticle.setRadialAccelVar(this.getRadialAccelVar());
|
|
1960
|
+
|
|
1961
|
+
// tangential acceleration
|
|
1962
|
+
retParticle.setTangentialAccel(this.getTangentialAccel());
|
|
1963
|
+
retParticle.setTangentialAccelVar(this.getTangentialAccelVar());
|
|
1964
|
+
|
|
1965
|
+
} else if (this.getEmitterMode() == cc.ParticleSystem.MODE_RADIUS) {
|
|
1966
|
+
// or Mode B: radius movement
|
|
1967
|
+
retParticle.setStartRadius(this.getStartRadius());
|
|
1968
|
+
retParticle.setStartRadiusVar(this.getStartRadiusVar());
|
|
1969
|
+
retParticle.setEndRadius(this.getEndRadius());
|
|
1970
|
+
retParticle.setEndRadiusVar(this.getEndRadiusVar());
|
|
1971
|
+
|
|
1972
|
+
retParticle.setRotatePerSecond(this.getRotatePerSecond());
|
|
1973
|
+
retParticle.setRotatePerSecondVar(this.getRotatePerSecondVar());
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
// life span
|
|
1977
|
+
retParticle.setLife(this.getLife());
|
|
1978
|
+
retParticle.setLifeVar(this.getLifeVar());
|
|
1979
|
+
|
|
1980
|
+
// emission Rate
|
|
1981
|
+
retParticle.setEmissionRate(this.getEmissionRate());
|
|
1982
|
+
|
|
1983
|
+
//don't get the internal texture if a batchNode is used
|
|
1984
|
+
if (!this.getBatchNode()) {
|
|
1985
|
+
// Set a compatible default for the alpha transfer
|
|
1986
|
+
retParticle.setOpacityModifyRGB(this.isOpacityModifyRGB());
|
|
1987
|
+
// texture
|
|
1988
|
+
var texture = this.getTexture();
|
|
1989
|
+
if(texture){
|
|
1990
|
+
var size = texture.getContentSize();
|
|
1991
|
+
retParticle.setTextureWithRect(texture, cc.rect(0, 0, size.width, size.height));
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
return retParticle;
|
|
1996
|
+
},
|
|
1997
|
+
|
|
1998
|
+
/**
|
|
1999
|
+
* <p> Sets a new CCSpriteFrame as particle.</br>
|
|
2000
|
+
* WARNING: this method is experimental. Use setTextureWithRect instead.
|
|
2001
|
+
* </p>
|
|
2002
|
+
* @param {cc.SpriteFrame} spriteFrame
|
|
2003
|
+
*/
|
|
2004
|
+
setDisplayFrame: function (spriteFrame) {
|
|
2005
|
+
if (!spriteFrame)
|
|
2006
|
+
return;
|
|
2007
|
+
|
|
2008
|
+
var locOffset = spriteFrame.getOffsetInPixels();
|
|
2009
|
+
if (locOffset.x != 0 || locOffset.y != 0)
|
|
2010
|
+
cc.log("cc.ParticleSystem.setDisplayFrame(): QuadParticle only supports SpriteFrames with no offsets");
|
|
2011
|
+
|
|
2012
|
+
// update texture before updating texture rect
|
|
2013
|
+
var texture = spriteFrame.getTexture(), locTexture = this._texture;
|
|
2014
|
+
if (locTexture != texture)
|
|
2015
|
+
this.setTexture(texture);
|
|
2016
|
+
},
|
|
2017
|
+
|
|
2018
|
+
/**
|
|
2019
|
+
* Sets a new texture with a rect. The rect is in Points.
|
|
2020
|
+
* @param {cc.Texture2D} texture
|
|
2021
|
+
* @param {cc.Rect} rect
|
|
2022
|
+
*/
|
|
2023
|
+
setTextureWithRect: function (texture, rect) {
|
|
2024
|
+
var locTexture = this._texture;
|
|
2025
|
+
if (locTexture != texture) {
|
|
2026
|
+
this._texture = texture;
|
|
2027
|
+
this._updateBlendFunc();
|
|
2028
|
+
}
|
|
2029
|
+
this.initTexCoordsWithRect(rect);
|
|
2030
|
+
},
|
|
2031
|
+
|
|
2032
|
+
/**
|
|
2033
|
+
* listen the event that coming to foreground on Android (An empty function for native)
|
|
2034
|
+
* @param {cc.Class} obj
|
|
2035
|
+
*/
|
|
2036
|
+
listenBackToForeground:function (obj) {
|
|
2037
|
+
//do nothing
|
|
2038
|
+
}
|
|
2039
|
+
});
|
|
2040
|
+
|
|
2041
|
+
var _p = cc.ParticleSystem.prototype;
|
|
2042
|
+
|
|
2043
|
+
// Extended properties
|
|
2044
|
+
/** @expose */
|
|
2045
|
+
_p.opacityModifyRGB;
|
|
2046
|
+
cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB, _p.setOpacityModifyRGB);
|
|
2047
|
+
/** @expose */
|
|
2048
|
+
_p.batchNode;
|
|
2049
|
+
cc.defineGetterSetter(_p, "batchNode", _p.getBatchNode, _p.setBatchNode);
|
|
2050
|
+
/** @expose */
|
|
2051
|
+
_p.drawMode;
|
|
2052
|
+
cc.defineGetterSetter(_p, "drawMode", _p.getDrawMode, _p.setDrawMode);
|
|
2053
|
+
/** @expose */
|
|
2054
|
+
_p.shapeType;
|
|
2055
|
+
cc.defineGetterSetter(_p, "shapeType", _p.getShapeType, _p.setShapeType);
|
|
2056
|
+
/** @expose */
|
|
2057
|
+
_p.active;
|
|
2058
|
+
cc.defineGetterSetter(_p, "active", _p.isActive);
|
|
2059
|
+
/** @expose */
|
|
2060
|
+
_p.sourcePos;
|
|
2061
|
+
cc.defineGetterSetter(_p, "sourcePos", _p.getSourcePosition, _p.setSourcePosition);
|
|
2062
|
+
/** @expose */
|
|
2063
|
+
_p.posVar;
|
|
2064
|
+
cc.defineGetterSetter(_p, "posVar", _p.getPosVar, _p.setPosVar);
|
|
2065
|
+
/** @expose */
|
|
2066
|
+
_p.gravity;
|
|
2067
|
+
cc.defineGetterSetter(_p, "gravity", _p.getGravity, _p.setGravity);
|
|
2068
|
+
/** @expose */
|
|
2069
|
+
_p.speed;
|
|
2070
|
+
cc.defineGetterSetter(_p, "speed", _p.getSpeed, _p.setSpeed);
|
|
2071
|
+
/** @expose */
|
|
2072
|
+
_p.speedVar;
|
|
2073
|
+
cc.defineGetterSetter(_p, "speedVar", _p.getSpeedVar, _p.setSpeedVar);
|
|
2074
|
+
/** @expose */
|
|
2075
|
+
_p.tangentialAccel;
|
|
2076
|
+
cc.defineGetterSetter(_p, "tangentialAccel", _p.getTangentialAccel, _p.setTangentialAccel);
|
|
2077
|
+
/** @expose */
|
|
2078
|
+
_p.tangentialAccelVar;
|
|
2079
|
+
cc.defineGetterSetter(_p, "tangentialAccelVar", _p.getTangentialAccelVar, _p.setTangentialAccelVar);
|
|
2080
|
+
/** @expose */
|
|
2081
|
+
_p.radialAccel;
|
|
2082
|
+
cc.defineGetterSetter(_p, "radialAccel", _p.getRadialAccel, _p.setRadialAccel);
|
|
2083
|
+
/** @expose */
|
|
2084
|
+
_p.radialAccelVar;
|
|
2085
|
+
cc.defineGetterSetter(_p, "radialAccelVar", _p.getRadialAccelVar, _p.setRadialAccelVar);
|
|
2086
|
+
/** @expose */
|
|
2087
|
+
_p.rotationIsDir;
|
|
2088
|
+
cc.defineGetterSetter(_p, "rotationIsDir", _p.getRotationIsDir, _p.setRotationIsDir);
|
|
2089
|
+
/** @expose */
|
|
2090
|
+
_p.startRadius;
|
|
2091
|
+
cc.defineGetterSetter(_p, "startRadius", _p.getStartRadius, _p.setStartRadius);
|
|
2092
|
+
/** @expose */
|
|
2093
|
+
_p.startRadiusVar;
|
|
2094
|
+
cc.defineGetterSetter(_p, "startRadiusVar", _p.getStartRadiusVar, _p.setStartRadiusVar);
|
|
2095
|
+
/** @expose */
|
|
2096
|
+
_p.endRadius;
|
|
2097
|
+
cc.defineGetterSetter(_p, "endRadius", _p.getEndRadius, _p.setEndRadius);
|
|
2098
|
+
/** @expose */
|
|
2099
|
+
_p.endRadiusVar;
|
|
2100
|
+
cc.defineGetterSetter(_p, "endRadiusVar", _p.getEndRadiusVar, _p.setEndRadiusVar);
|
|
2101
|
+
/** @expose */
|
|
2102
|
+
_p.rotatePerS;
|
|
2103
|
+
cc.defineGetterSetter(_p, "rotatePerS", _p.getRotatePerSecond, _p.setRotatePerSecond);
|
|
2104
|
+
/** @expose */
|
|
2105
|
+
_p.rotatePerSVar;
|
|
2106
|
+
cc.defineGetterSetter(_p, "rotatePerSVar", _p.getRotatePerSecondVar, _p.setRotatePerSecondVar);
|
|
2107
|
+
/** @expose */
|
|
2108
|
+
_p.startColor;
|
|
2109
|
+
cc.defineGetterSetter(_p, "startColor", _p.getStartColor, _p.setStartColor);
|
|
2110
|
+
/** @expose */
|
|
2111
|
+
_p.startColorVar;
|
|
2112
|
+
cc.defineGetterSetter(_p, "startColorVar", _p.getStartColorVar, _p.setStartColorVar);
|
|
2113
|
+
/** @expose */
|
|
2114
|
+
_p.endColor;
|
|
2115
|
+
cc.defineGetterSetter(_p, "endColor", _p.getEndColor, _p.setEndColor);
|
|
2116
|
+
/** @expose */
|
|
2117
|
+
_p.endColorVar;
|
|
2118
|
+
cc.defineGetterSetter(_p, "endColorVar", _p.getEndColorVar, _p.setEndColorVar);
|
|
2119
|
+
/** @expose */
|
|
2120
|
+
_p.totalParticles;
|
|
2121
|
+
cc.defineGetterSetter(_p, "totalParticles", _p.getTotalParticles, _p.setTotalParticles);
|
|
2122
|
+
/** @expose */
|
|
2123
|
+
_p.texture;
|
|
2124
|
+
cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture);
|
|
2125
|
+
|
|
2126
|
+
|
|
2127
|
+
/**
|
|
2128
|
+
* <p> return the string found by key in dict. <br/>
|
|
2129
|
+
* This plist files can be create manually or with Particle Designer:<br/>
|
|
2130
|
+
* http://particledesigner.71squared.com/<br/>
|
|
2131
|
+
* </p>
|
|
2132
|
+
* @deprecated since v3.0 please use new cc.ParticleSysytem(plistFile) instead.
|
|
2133
|
+
* @param {String|Number} plistFile
|
|
2134
|
+
* @return {cc.ParticleSystem}
|
|
2135
|
+
*/
|
|
2136
|
+
cc.ParticleSystem.create = function (plistFile) {
|
|
2137
|
+
return new cc.ParticleSystem(plistFile);
|
|
2138
|
+
};
|
|
2139
|
+
|
|
2140
|
+
/**
|
|
2141
|
+
* <p> return the string found by key in dict. <br/>
|
|
2142
|
+
* This plist files can be create manually or with Particle Designer:<br/>
|
|
2143
|
+
* http://particledesigner.71squared.com/<br/>
|
|
2144
|
+
* </p>
|
|
2145
|
+
* @deprecated since v3.0 please use new cc.ParticleSysytem(plistFile) instead.
|
|
2146
|
+
* @function
|
|
2147
|
+
* @param {String|Number} plistFile
|
|
2148
|
+
* @return {cc.ParticleSystem}
|
|
2149
|
+
*/
|
|
2150
|
+
cc.ParticleSystem.createWithTotalParticles = cc.ParticleSystem.create;
|
|
2151
|
+
|
|
2152
|
+
// Different modes
|
|
2153
|
+
/**
|
|
2154
|
+
* Mode A:Gravity + Tangential Accel + Radial Accel
|
|
2155
|
+
* @Class
|
|
2156
|
+
* @Construct
|
|
2157
|
+
* @param {cc.Point} [gravity=] Gravity value.
|
|
2158
|
+
* @param {Number} [speed=0] speed of each particle.
|
|
2159
|
+
* @param {Number} [speedVar=0] speed variance of each particle.
|
|
2160
|
+
* @param {Number} [tangentialAccel=0] tangential acceleration of each particle.
|
|
2161
|
+
* @param {Number} [tangentialAccelVar=0] tangential acceleration variance of each particle.
|
|
2162
|
+
* @param {Number} [radialAccel=0] radial acceleration of each particle.
|
|
2163
|
+
* @param {Number} [radialAccelVar=0] radial acceleration variance of each particle.
|
|
2164
|
+
* @param {boolean} [rotationIsDir=false]
|
|
2165
|
+
*/
|
|
2166
|
+
cc.ParticleSystem.ModeA = function (gravity, speed, speedVar, tangentialAccel, tangentialAccelVar, radialAccel, radialAccelVar, rotationIsDir) {
|
|
2167
|
+
/** Gravity value. Only available in 'Gravity' mode. */
|
|
2168
|
+
this.gravity = gravity ? gravity : cc.p(0,0);
|
|
2169
|
+
/** speed of each particle. Only available in 'Gravity' mode. */
|
|
2170
|
+
this.speed = speed || 0;
|
|
2171
|
+
/** speed variance of each particle. Only available in 'Gravity' mode. */
|
|
2172
|
+
this.speedVar = speedVar || 0;
|
|
2173
|
+
/** tangential acceleration of each particle. Only available in 'Gravity' mode. */
|
|
2174
|
+
this.tangentialAccel = tangentialAccel || 0;
|
|
2175
|
+
/** tangential acceleration variance of each particle. Only available in 'Gravity' mode. */
|
|
2176
|
+
this.tangentialAccelVar = tangentialAccelVar || 0;
|
|
2177
|
+
/** radial acceleration of each particle. Only available in 'Gravity' mode. */
|
|
2178
|
+
this.radialAccel = radialAccel || 0;
|
|
2179
|
+
/** radial acceleration variance of each particle. Only available in 'Gravity' mode. */
|
|
2180
|
+
this.radialAccelVar = radialAccelVar || 0;
|
|
2181
|
+
/** set the rotation of each particle to its direction Only available in 'Gravity' mode. */
|
|
2182
|
+
this.rotationIsDir = rotationIsDir || false;
|
|
2183
|
+
};
|
|
2184
|
+
|
|
2185
|
+
/**
|
|
2186
|
+
* Mode B: circular movement (gravity, radial accel and tangential accel don't are not used in this mode)
|
|
2187
|
+
* @Class
|
|
2188
|
+
* @Construct
|
|
2189
|
+
* @param {Number} [startRadius=0] The starting radius of the particles.
|
|
2190
|
+
* @param {Number} [startRadiusVar=0] The starting radius variance of the particles.
|
|
2191
|
+
* @param {Number} [endRadius=0] The ending radius of the particles.
|
|
2192
|
+
* @param {Number} [endRadiusVar=0] The ending radius variance of the particles.
|
|
2193
|
+
* @param {Number} [rotatePerSecond=0] Number of degrees to rotate a particle around the source pos per second.
|
|
2194
|
+
* @param {Number} [rotatePerSecondVar=0] Variance in degrees for rotatePerSecond.
|
|
2195
|
+
*/
|
|
2196
|
+
cc.ParticleSystem.ModeB = function (startRadius, startRadiusVar, endRadius, endRadiusVar, rotatePerSecond, rotatePerSecondVar) {
|
|
2197
|
+
/** The starting radius of the particles. Only available in 'Radius' mode. */
|
|
2198
|
+
this.startRadius = startRadius || 0;
|
|
2199
|
+
/** The starting radius variance of the particles. Only available in 'Radius' mode. */
|
|
2200
|
+
this.startRadiusVar = startRadiusVar || 0;
|
|
2201
|
+
/** The ending radius of the particles. Only available in 'Radius' mode. */
|
|
2202
|
+
this.endRadius = endRadius || 0;
|
|
2203
|
+
/** The ending radius variance of the particles. Only available in 'Radius' mode. */
|
|
2204
|
+
this.endRadiusVar = endRadiusVar || 0;
|
|
2205
|
+
/** Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. */
|
|
2206
|
+
this.rotatePerSecond = rotatePerSecond || 0;
|
|
2207
|
+
/** Variance in degrees for rotatePerSecond. Only available in 'Radius' mode. */
|
|
2208
|
+
this.rotatePerSecondVar = rotatePerSecondVar || 0;
|
|
2209
|
+
};
|
|
2210
|
+
|
|
2211
|
+
/**
|
|
2212
|
+
* Shape Mode of Particle Draw
|
|
2213
|
+
* @constant
|
|
2214
|
+
* @type Number
|
|
2215
|
+
*/
|
|
2216
|
+
cc.ParticleSystem.SHAPE_MODE = 0;
|
|
2217
|
+
|
|
2218
|
+
/**
|
|
2219
|
+
* Texture Mode of Particle Draw
|
|
2220
|
+
* @constant
|
|
2221
|
+
* @type Number
|
|
2222
|
+
*/
|
|
2223
|
+
cc.ParticleSystem.TEXTURE_MODE = 1;
|
|
2224
|
+
|
|
2225
|
+
/**
|
|
2226
|
+
* Star Shape for ShapeMode of Particle
|
|
2227
|
+
* @constant
|
|
2228
|
+
* @type Number
|
|
2229
|
+
*/
|
|
2230
|
+
cc.ParticleSystem.STAR_SHAPE = 0;
|
|
2231
|
+
|
|
2232
|
+
/**
|
|
2233
|
+
* Ball Shape for ShapeMode of Particle
|
|
2234
|
+
* @constant
|
|
2235
|
+
* @type Number
|
|
2236
|
+
*/
|
|
2237
|
+
cc.ParticleSystem.BALL_SHAPE = 1;
|
|
2238
|
+
|
|
2239
|
+
/**
|
|
2240
|
+
* The Particle emitter lives forever
|
|
2241
|
+
* @constant
|
|
2242
|
+
* @type Number
|
|
2243
|
+
*/
|
|
2244
|
+
cc.ParticleSystem.DURATION_INFINITY = -1;
|
|
2245
|
+
|
|
2246
|
+
/**
|
|
2247
|
+
* The starting size of the particle is equal to the ending size
|
|
2248
|
+
* @constant
|
|
2249
|
+
* @type Number
|
|
2250
|
+
*/
|
|
2251
|
+
cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE = -1;
|
|
2252
|
+
|
|
2253
|
+
/**
|
|
2254
|
+
* The starting radius of the particle is equal to the ending radius
|
|
2255
|
+
* @constant
|
|
2256
|
+
* @type Number
|
|
2257
|
+
*/
|
|
2258
|
+
cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS = -1;
|
|
2259
|
+
|
|
2260
|
+
/**
|
|
2261
|
+
* Gravity mode (A mode)
|
|
2262
|
+
* @constant
|
|
2263
|
+
* @type Number
|
|
2264
|
+
*/
|
|
2265
|
+
cc.ParticleSystem.MODE_GRAVITY = 0;
|
|
2266
|
+
|
|
2267
|
+
/**
|
|
2268
|
+
* Radius mode (B mode)
|
|
2269
|
+
* @constant
|
|
2270
|
+
* @type Number
|
|
2271
|
+
*/
|
|
2272
|
+
cc.ParticleSystem.MODE_RADIUS = 1;
|
|
2273
|
+
|
|
2274
|
+
/**
|
|
2275
|
+
* Living particles are attached to the world and are unaffected by emitter repositioning.
|
|
2276
|
+
* @constant
|
|
2277
|
+
* @type Number
|
|
2278
|
+
*/
|
|
2279
|
+
cc.ParticleSystem.TYPE_FREE = 0;
|
|
2280
|
+
|
|
2281
|
+
/**
|
|
2282
|
+
* Living particles are attached to the world but will follow the emitter repositioning.<br/>
|
|
2283
|
+
* Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite.
|
|
2284
|
+
* @constant
|
|
2285
|
+
* @type Number
|
|
2286
|
+
*/
|
|
2287
|
+
cc.ParticleSystem.TYPE_RELATIVE = 1;
|
|
2288
|
+
|
|
2289
|
+
/**
|
|
2290
|
+
* Living particles are attached to the emitter and are translated along with it.
|
|
2291
|
+
* @constant
|
|
2292
|
+
* @type Number
|
|
2293
|
+
*/
|
|
2294
|
+
cc.ParticleSystem.TYPE_GROUPED = 2;
|