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,1014 @@
|
|
|
1
|
+
/****************************************************************************
|
|
2
|
+
Copyright (c) 2008-2010 Ricardo Quesada
|
|
3
|
+
Copyright (c) 2011-2012 cocos2d-x.org
|
|
4
|
+
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
5
|
+
|
|
6
|
+
http://www.cocos2d-x.org
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
****************************************************************************/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* <p>cc.Sprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) ) <br/>
|
|
29
|
+
*
|
|
30
|
+
* cc.Sprite can be created with an image, or with a sub-rectangle of an image. <br/>
|
|
31
|
+
*
|
|
32
|
+
* If the parent or any of its ancestors is a cc.SpriteBatchNode then the following features/limitations are valid <br/>
|
|
33
|
+
* - Features when the parent is a cc.BatchNode: <br/>
|
|
34
|
+
* - MUCH faster rendering, specially if the cc.SpriteBatchNode has many children. All the children will be drawn in a single batch. <br/>
|
|
35
|
+
*
|
|
36
|
+
* - Limitations <br/>
|
|
37
|
+
* - Camera is not supported yet (eg: CCOrbitCamera action doesn't work) <br/>
|
|
38
|
+
* - GridBase actions are not supported (eg: CCLens, CCRipple, CCTwirl) <br/>
|
|
39
|
+
* - The Alias/Antialias property belongs to CCSpriteBatchNode, so you can't individually set the aliased property. <br/>
|
|
40
|
+
* - The Blending function property belongs to CCSpriteBatchNode, so you can't individually set the blending function property. <br/>
|
|
41
|
+
* - Parallax scroller is not supported, but can be simulated with a "proxy" sprite. <br/>
|
|
42
|
+
*
|
|
43
|
+
* If the parent is an standard cc.Node, then cc.Sprite behaves like any other cc.Node: <br/>
|
|
44
|
+
* - It supports blending functions <br/>
|
|
45
|
+
* - It supports aliasing / antialiasing <br/>
|
|
46
|
+
* - But the rendering will be slower: 1 draw per children. <br/>
|
|
47
|
+
*
|
|
48
|
+
* The default anchorPoint in cc.Sprite is (0.5, 0.5). </p>
|
|
49
|
+
* @class
|
|
50
|
+
* @extends cc.Node
|
|
51
|
+
*
|
|
52
|
+
* @param {String|cc.SpriteFrame|HTMLImageElement|cc.Texture2D} fileName The string which indicates a path to image file, e.g., "scene1/monster.png".
|
|
53
|
+
* @param {cc.Rect} rect Only the contents inside rect of pszFileName's texture will be applied for this sprite.
|
|
54
|
+
* @param {Boolean} [rotated] Whether or not the texture rectangle is rotated.
|
|
55
|
+
* @example
|
|
56
|
+
*
|
|
57
|
+
* 1.Create a sprite with image path and rect
|
|
58
|
+
* var sprite1 = new cc.Sprite("res/HelloHTML5World.png");
|
|
59
|
+
* var sprite2 = new cc.Sprite("res/HelloHTML5World.png",cc.rect(0,0,480,320));
|
|
60
|
+
*
|
|
61
|
+
* 2.Create a sprite with a sprite frame name. Must add "#" before frame name.
|
|
62
|
+
* var sprite = new cc.Sprite('#grossini_dance_01.png');
|
|
63
|
+
*
|
|
64
|
+
* 3.Create a sprite with a sprite frame
|
|
65
|
+
* var spriteFrame = cc.spriteFrameCache.getSpriteFrame("grossini_dance_01.png");
|
|
66
|
+
* var sprite = new cc.Sprite(spriteFrame);
|
|
67
|
+
*
|
|
68
|
+
* 4.Create a sprite with an existing texture contained in a CCTexture2D object
|
|
69
|
+
* After creation, the rect will be the size of the texture, and the offset will be (0,0).
|
|
70
|
+
* var texture = cc.textureCache.addImage("HelloHTML5World.png");
|
|
71
|
+
* var sprite1 = new cc.Sprite(texture);
|
|
72
|
+
* var sprite2 = new cc.Sprite(texture, cc.rect(0,0,480,320));
|
|
73
|
+
*
|
|
74
|
+
* @property {Boolean} dirty - Indicates whether the sprite needs to be updated.
|
|
75
|
+
* @property {Boolean} flippedX - Indicates whether or not the sprite is flipped on x axis.
|
|
76
|
+
* @property {Boolean} flippedY - Indicates whether or not the sprite is flipped on y axis.
|
|
77
|
+
* @property {Number} offsetX - <@readonly> The offset position on x axis of the sprite in texture. Calculated automatically by editors like Zwoptex.
|
|
78
|
+
* @property {Number} offsetY - <@readonly> The offset position on x axis of the sprite in texture. Calculated automatically by editors like Zwoptex.
|
|
79
|
+
* @property {Number} atlasIndex - The index used on the TextureAtlas.
|
|
80
|
+
* @property {cc.Texture2D} texture - Texture used to render the sprite.
|
|
81
|
+
* @property {Boolean} textureRectRotated - <@readonly> Indicate whether the texture rectangle is rotated.
|
|
82
|
+
* @property {cc.TextureAtlas} textureAtlas - The weak reference of the cc.TextureAtlas when the sprite is rendered using via cc.SpriteBatchNode.
|
|
83
|
+
* @property {cc.SpriteBatchNode} batchNode - The batch node object if this sprite is rendered by cc.SpriteBatchNode.
|
|
84
|
+
* @property {cc.V3F_C4B_T2F_Quad} quad - <@readonly> The quad (tex coords, vertex coords and color) information.
|
|
85
|
+
*/
|
|
86
|
+
cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{
|
|
87
|
+
dirty:false,
|
|
88
|
+
atlasIndex:0,
|
|
89
|
+
textureAtlas:null,
|
|
90
|
+
|
|
91
|
+
_batchNode:null,
|
|
92
|
+
_recursiveDirty:null, //Whether all of the sprite's children needs to be updated
|
|
93
|
+
_hasChildren:null, //Whether the sprite contains children
|
|
94
|
+
_shouldBeHidden:false, //should not be drawn because one of the ancestors is not visible
|
|
95
|
+
_transformToBatch:null,
|
|
96
|
+
|
|
97
|
+
//
|
|
98
|
+
// Data used when the sprite is self-rendered
|
|
99
|
+
//
|
|
100
|
+
_blendFunc:null, //It's required for CCTextureProtocol inheritance
|
|
101
|
+
_texture:null, //cc.Texture2D object that is used to render the sprite
|
|
102
|
+
|
|
103
|
+
//
|
|
104
|
+
// Shared data
|
|
105
|
+
//
|
|
106
|
+
// texture
|
|
107
|
+
_rect:null, //Rectangle of cc.Texture2D
|
|
108
|
+
_rectRotated:false, //Whether the texture is rotated
|
|
109
|
+
|
|
110
|
+
// Offset Position (used by Zwoptex)
|
|
111
|
+
_offsetPosition:null, // absolute
|
|
112
|
+
_unflippedOffsetPositionFromCenter:null,
|
|
113
|
+
|
|
114
|
+
_opacityModifyRGB:false,
|
|
115
|
+
|
|
116
|
+
// image is flipped
|
|
117
|
+
_flippedX:false, //Whether the sprite is flipped horizontally or not.
|
|
118
|
+
_flippedY:false, //Whether the sprite is flipped vertically or not.
|
|
119
|
+
|
|
120
|
+
_textureLoaded:false,
|
|
121
|
+
_className:"Sprite",
|
|
122
|
+
|
|
123
|
+
ctor: function (fileName, rect, rotated) {
|
|
124
|
+
var self = this;
|
|
125
|
+
cc.Node.prototype.ctor.call(self);
|
|
126
|
+
self._shouldBeHidden = false;
|
|
127
|
+
self._offsetPosition = cc.p(0, 0);
|
|
128
|
+
self._unflippedOffsetPositionFromCenter = cc.p(0, 0);
|
|
129
|
+
self._blendFunc = {src: cc.BLEND_SRC, dst: cc.BLEND_DST};
|
|
130
|
+
self._rect = cc.rect(0, 0, 0, 0);
|
|
131
|
+
|
|
132
|
+
self._softInit(fileName, rect, rotated);
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Returns whether the texture have been loaded
|
|
137
|
+
* @returns {boolean}
|
|
138
|
+
*/
|
|
139
|
+
textureLoaded:function(){
|
|
140
|
+
return this._textureLoaded;
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Add a event listener for texture loaded event.
|
|
145
|
+
* @param {Function} callback
|
|
146
|
+
* @param {Object} target
|
|
147
|
+
* @deprecated since 3.1, please use addEventListener instead
|
|
148
|
+
*/
|
|
149
|
+
addLoadedEventListener:function(callback, target){
|
|
150
|
+
this.addEventListener("load", callback, target);
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Returns whether or not the Sprite needs to be updated in the Atlas
|
|
155
|
+
* @return {Boolean} True if the sprite needs to be updated in the Atlas, false otherwise.
|
|
156
|
+
*/
|
|
157
|
+
isDirty:function () {
|
|
158
|
+
return this.dirty;
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Makes the sprite to be updated in the Atlas.
|
|
163
|
+
* @param {Boolean} bDirty
|
|
164
|
+
*/
|
|
165
|
+
setDirty:function (bDirty) {
|
|
166
|
+
this.dirty = bDirty;
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Returns whether or not the texture rectangle is rotated.
|
|
171
|
+
* @return {Boolean}
|
|
172
|
+
*/
|
|
173
|
+
isTextureRectRotated:function () {
|
|
174
|
+
return this._rectRotated;
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Returns the index used on the TextureAtlas.
|
|
179
|
+
* @return {Number}
|
|
180
|
+
*/
|
|
181
|
+
getAtlasIndex:function () {
|
|
182
|
+
return this.atlasIndex;
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Sets the index used on the TextureAtlas.
|
|
187
|
+
* @warning Don't modify this value unless you know what you are doing
|
|
188
|
+
* @param {Number} atlasIndex
|
|
189
|
+
*/
|
|
190
|
+
setAtlasIndex:function (atlasIndex) {
|
|
191
|
+
this.atlasIndex = atlasIndex;
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Returns the rect of the cc.Sprite in points
|
|
196
|
+
* @return {cc.Rect}
|
|
197
|
+
*/
|
|
198
|
+
getTextureRect:function () {
|
|
199
|
+
return cc.rect(this._rect);
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Returns the weak reference of the cc.TextureAtlas when the sprite is rendered using via cc.SpriteBatchNode
|
|
204
|
+
* @return {cc.TextureAtlas}
|
|
205
|
+
*/
|
|
206
|
+
getTextureAtlas:function () {
|
|
207
|
+
return this.textureAtlas;
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Sets the weak reference of the cc.TextureAtlas when the sprite is rendered using via cc.SpriteBatchNode
|
|
212
|
+
* @param {cc.TextureAtlas} textureAtlas
|
|
213
|
+
*/
|
|
214
|
+
setTextureAtlas:function (textureAtlas) {
|
|
215
|
+
this.textureAtlas = textureAtlas;
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Returns the offset position of the sprite. Calculated automatically by editors like Zwoptex.
|
|
220
|
+
* @return {cc.Point}
|
|
221
|
+
*/
|
|
222
|
+
getOffsetPosition:function () {
|
|
223
|
+
return cc.p(this._offsetPosition);
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
_getOffsetX: function () {
|
|
227
|
+
return this._offsetPosition.x;
|
|
228
|
+
},
|
|
229
|
+
_getOffsetY: function () {
|
|
230
|
+
return this._offsetPosition.y;
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Returns the blend function
|
|
235
|
+
* @return {cc.BlendFunc}
|
|
236
|
+
*/
|
|
237
|
+
getBlendFunc:function () {
|
|
238
|
+
return this._blendFunc;
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Initializes a sprite with a SpriteFrame. The texture and rect in SpriteFrame will be applied on this sprite.<br/>
|
|
243
|
+
* Please pass parameters to the constructor to initialize the sprite, do not call this function yourself,
|
|
244
|
+
* @param {cc.SpriteFrame} spriteFrame A CCSpriteFrame object. It should includes a valid texture and a rect
|
|
245
|
+
* @return {Boolean} true if the sprite is initialized properly, false otherwise.
|
|
246
|
+
*/
|
|
247
|
+
initWithSpriteFrame:function (spriteFrame) {
|
|
248
|
+
cc.assert(spriteFrame, cc._LogInfos.Sprite_initWithSpriteFrame);
|
|
249
|
+
|
|
250
|
+
if(!spriteFrame.textureLoaded()){
|
|
251
|
+
//add event listener
|
|
252
|
+
this._textureLoaded = false;
|
|
253
|
+
spriteFrame.addEventListener("load", this._renderCmd._spriteFrameLoadedCallback, this);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
//TODO
|
|
257
|
+
var rotated = cc._renderType === cc._RENDER_TYPE_CANVAS ? false : spriteFrame._rotated;
|
|
258
|
+
var ret = this.initWithTexture(spriteFrame.getTexture(), spriteFrame.getRect(), rotated);
|
|
259
|
+
this.setSpriteFrame(spriteFrame);
|
|
260
|
+
|
|
261
|
+
return ret;
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Initializes a sprite with a sprite frame name. <br/>
|
|
266
|
+
* A cc.SpriteFrame will be fetched from the cc.SpriteFrameCache by name. <br/>
|
|
267
|
+
* If the cc.SpriteFrame doesn't exist it will raise an exception. <br/>
|
|
268
|
+
* Please pass parameters to the constructor to initialize the sprite, do not call this function yourself.
|
|
269
|
+
* @param {String} spriteFrameName A key string that can fected a valid cc.SpriteFrame from cc.SpriteFrameCache
|
|
270
|
+
* @return {Boolean} true if the sprite is initialized properly, false otherwise.
|
|
271
|
+
* @example
|
|
272
|
+
* var sprite = new cc.Sprite();
|
|
273
|
+
* sprite.initWithSpriteFrameName("grossini_dance_01.png");
|
|
274
|
+
*/
|
|
275
|
+
initWithSpriteFrameName:function (spriteFrameName) {
|
|
276
|
+
cc.assert(spriteFrameName, cc._LogInfos.Sprite_initWithSpriteFrameName);
|
|
277
|
+
var frame = cc.spriteFrameCache.getSpriteFrame(spriteFrameName);
|
|
278
|
+
cc.assert(frame, spriteFrameName + cc._LogInfos.Sprite_initWithSpriteFrameName1);
|
|
279
|
+
return this.initWithSpriteFrame(frame);
|
|
280
|
+
},
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Tell the sprite to use batch node render.
|
|
284
|
+
* @param {cc.SpriteBatchNode} batchNode
|
|
285
|
+
*/
|
|
286
|
+
useBatchNode:function (batchNode) {
|
|
287
|
+
this.textureAtlas = batchNode.getTextureAtlas(); // weak ref
|
|
288
|
+
this._batchNode = batchNode;
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* <p>
|
|
293
|
+
* set the vertex rect.<br/>
|
|
294
|
+
* It will be called internally by setTextureRect. <br/>
|
|
295
|
+
* Useful if you want to create 2x images from SD images in Retina Display. <br/>
|
|
296
|
+
* Do not call it manually. Use setTextureRect instead. <br/>
|
|
297
|
+
* (override this method to generate "double scale" sprites)
|
|
298
|
+
* </p>
|
|
299
|
+
* @param {cc.Rect} rect
|
|
300
|
+
*/
|
|
301
|
+
setVertexRect:function (rect) {
|
|
302
|
+
var locRect = this._rect;
|
|
303
|
+
locRect.x = rect.x;
|
|
304
|
+
locRect.y = rect.y;
|
|
305
|
+
locRect.width = rect.width;
|
|
306
|
+
locRect.height = rect.height;
|
|
307
|
+
},
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Sort all children of this sprite node.
|
|
311
|
+
* @override
|
|
312
|
+
*/
|
|
313
|
+
sortAllChildren:function () {
|
|
314
|
+
if (this._reorderChildDirty) {
|
|
315
|
+
var _children = this._children;
|
|
316
|
+
|
|
317
|
+
// insertion sort
|
|
318
|
+
var len = _children.length, i, j, tmp;
|
|
319
|
+
for(i=1; i<len; i++){
|
|
320
|
+
tmp = _children[i];
|
|
321
|
+
j = i - 1;
|
|
322
|
+
|
|
323
|
+
//continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller
|
|
324
|
+
while(j >= 0){
|
|
325
|
+
if(tmp._localZOrder < _children[j]._localZOrder){
|
|
326
|
+
_children[j+1] = _children[j];
|
|
327
|
+
}else if(tmp._localZOrder === _children[j]._localZOrder && tmp.arrivalOrder < _children[j].arrivalOrder){
|
|
328
|
+
_children[j+1] = _children[j];
|
|
329
|
+
}else{
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
j--;
|
|
333
|
+
}
|
|
334
|
+
_children[j+1] = tmp;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (this._batchNode) {
|
|
338
|
+
this._arrayMakeObjectsPerformSelector(_children, cc.Node._stateCallbackType.sortAllChildren);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
//don't need to check children recursively, that's done in visit of each child
|
|
342
|
+
this._reorderChildDirty = false;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Reorders a child according to a new z value. (override cc.Node )
|
|
349
|
+
* @param {cc.Node} child
|
|
350
|
+
* @param {Number} zOrder
|
|
351
|
+
* @override
|
|
352
|
+
*/
|
|
353
|
+
reorderChild:function (child, zOrder) {
|
|
354
|
+
cc.assert(child, cc._LogInfos.Sprite_reorderChild_2);
|
|
355
|
+
if(this._children.indexOf(child) === -1){
|
|
356
|
+
cc.log(cc._LogInfos.Sprite_reorderChild);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (zOrder === child.zIndex)
|
|
361
|
+
return;
|
|
362
|
+
|
|
363
|
+
if (this._batchNode && !this._reorderChildDirty) {
|
|
364
|
+
this._setReorderChildDirtyRecursively();
|
|
365
|
+
this._batchNode.reorderBatch(true);
|
|
366
|
+
}
|
|
367
|
+
cc.Node.prototype.reorderChild.call(this, child, zOrder);
|
|
368
|
+
},
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Removes a child from the sprite.
|
|
372
|
+
* @param child
|
|
373
|
+
* @param cleanup whether or not cleanup all running actions
|
|
374
|
+
* @override
|
|
375
|
+
*/
|
|
376
|
+
removeChild:function (child, cleanup) {
|
|
377
|
+
if (this._batchNode)
|
|
378
|
+
this._batchNode.removeSpriteFromAtlas(child);
|
|
379
|
+
cc.Node.prototype.removeChild.call(this, child, cleanup);
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Sets whether the sprite is visible or not.
|
|
384
|
+
* @param {Boolean} visible
|
|
385
|
+
* @override
|
|
386
|
+
*/
|
|
387
|
+
setVisible:function (visible) {
|
|
388
|
+
cc.Node.prototype.setVisible.call(this, visible);
|
|
389
|
+
this._renderCmd.setDirtyRecursively(true);
|
|
390
|
+
},
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Removes all children from the container.
|
|
394
|
+
* @param cleanup whether or not cleanup all running actions
|
|
395
|
+
* @override
|
|
396
|
+
*/
|
|
397
|
+
removeAllChildren:function (cleanup) {
|
|
398
|
+
var locChildren = this._children, locBatchNode = this._batchNode;
|
|
399
|
+
if (locBatchNode && locChildren != null) {
|
|
400
|
+
for (var i = 0, len = locChildren.length; i < len; i++)
|
|
401
|
+
locBatchNode.removeSpriteFromAtlas(locChildren[i]);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
cc.Node.prototype.removeAllChildren.call(this, cleanup);
|
|
405
|
+
this._hasChildren = false;
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
//
|
|
409
|
+
// cc.Node property overloads
|
|
410
|
+
//
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Sets whether ignore anchor point for positioning
|
|
414
|
+
* @param {Boolean} relative
|
|
415
|
+
* @override
|
|
416
|
+
*/
|
|
417
|
+
ignoreAnchorPointForPosition:function (relative) {
|
|
418
|
+
if(this._batchNode){
|
|
419
|
+
cc.log(cc._LogInfos.Sprite_ignoreAnchorPointForPosition);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
cc.Node.prototype.ignoreAnchorPointForPosition.call(this, relative);
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Sets whether the sprite should be flipped horizontally or not.
|
|
427
|
+
* @param {Boolean} flippedX true if the sprite should be flipped horizontally, false otherwise.
|
|
428
|
+
*/
|
|
429
|
+
setFlippedX:function (flippedX) {
|
|
430
|
+
if (this._flippedX != flippedX) {
|
|
431
|
+
this._flippedX = flippedX;
|
|
432
|
+
this.setTextureRect(this._rect, this._rectRotated, this._contentSize);
|
|
433
|
+
this.setNodeDirty(true);
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Sets whether the sprite should be flipped vertically or not.
|
|
439
|
+
* @param {Boolean} flippedY true if the sprite should be flipped vertically, false otherwise.
|
|
440
|
+
*/
|
|
441
|
+
setFlippedY:function (flippedY) {
|
|
442
|
+
if (this._flippedY != flippedY) {
|
|
443
|
+
this._flippedY = flippedY;
|
|
444
|
+
this.setTextureRect(this._rect, this._rectRotated, this._contentSize);
|
|
445
|
+
this.setNodeDirty(true);
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* <p>
|
|
451
|
+
* Returns the flag which indicates whether the sprite is flipped horizontally or not. <br/>
|
|
452
|
+
* <br/>
|
|
453
|
+
* It only flips the texture of the sprite, and not the texture of the sprite's children. <br/>
|
|
454
|
+
* Also, flipping the texture doesn't alter the anchorPoint. <br/>
|
|
455
|
+
* If you want to flip the anchorPoint too, and/or to flip the children too use: <br/>
|
|
456
|
+
* sprite.setScaleX(sprite.getScaleX() * -1); <p/>
|
|
457
|
+
* @return {Boolean} true if the sprite is flipped horizontally, false otherwise.
|
|
458
|
+
*/
|
|
459
|
+
isFlippedX:function () {
|
|
460
|
+
return this._flippedX;
|
|
461
|
+
},
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* <p>
|
|
465
|
+
* Return the flag which indicates whether the sprite is flipped vertically or not. <br/>
|
|
466
|
+
* <br/>
|
|
467
|
+
* It only flips the texture of the sprite, and not the texture of the sprite's children. <br/>
|
|
468
|
+
* Also, flipping the texture doesn't alter the anchorPoint. <br/>
|
|
469
|
+
* If you want to flip the anchorPoint too, and/or to flip the children too use: <br/>
|
|
470
|
+
* sprite.setScaleY(sprite.getScaleY() * -1); <p/>
|
|
471
|
+
* @return {Boolean} true if the sprite is flipped vertically, false otherwise.
|
|
472
|
+
*/
|
|
473
|
+
isFlippedY:function () {
|
|
474
|
+
return this._flippedY;
|
|
475
|
+
},
|
|
476
|
+
|
|
477
|
+
//
|
|
478
|
+
// RGBA protocol
|
|
479
|
+
//
|
|
480
|
+
/**
|
|
481
|
+
* Sets whether opacity modify color or not.
|
|
482
|
+
* @function
|
|
483
|
+
* @param {Boolean} modify
|
|
484
|
+
*/
|
|
485
|
+
setOpacityModifyRGB: function (modify) {
|
|
486
|
+
if (this._opacityModifyRGB !== modify) {
|
|
487
|
+
this._opacityModifyRGB = modify;
|
|
488
|
+
this._renderCmd._setColorDirty();
|
|
489
|
+
}
|
|
490
|
+
},
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Returns whether opacity modify color or not.
|
|
494
|
+
* @return {Boolean}
|
|
495
|
+
*/
|
|
496
|
+
isOpacityModifyRGB:function () {
|
|
497
|
+
return this._opacityModifyRGB;
|
|
498
|
+
},
|
|
499
|
+
|
|
500
|
+
// Animation
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Changes the display frame with animation name and index.<br/>
|
|
504
|
+
* The animation name will be get from the CCAnimationCache
|
|
505
|
+
* @param {String} animationName
|
|
506
|
+
* @param {Number} frameIndex
|
|
507
|
+
*/
|
|
508
|
+
setDisplayFrameWithAnimationName:function (animationName, frameIndex) {
|
|
509
|
+
cc.assert(animationName, cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3);
|
|
510
|
+
|
|
511
|
+
var cache = cc.animationCache.getAnimation(animationName);
|
|
512
|
+
if(!cache){
|
|
513
|
+
cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
var animFrame = cache.getFrames()[frameIndex];
|
|
517
|
+
if(!animFrame){
|
|
518
|
+
cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_2);
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
this.setSpriteFrame(animFrame.getSpriteFrame());
|
|
522
|
+
},
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Returns the batch node object if this sprite is rendered by cc.SpriteBatchNode
|
|
526
|
+
* @returns {cc.SpriteBatchNode|null} The cc.SpriteBatchNode object if this sprite is rendered by cc.SpriteBatchNode, null if the sprite isn't used batch node.
|
|
527
|
+
*/
|
|
528
|
+
getBatchNode:function () {
|
|
529
|
+
return this._batchNode;
|
|
530
|
+
},
|
|
531
|
+
|
|
532
|
+
_setReorderChildDirtyRecursively:function () {
|
|
533
|
+
//only set parents flag the first time
|
|
534
|
+
if (!this._reorderChildDirty) {
|
|
535
|
+
this._reorderChildDirty = true;
|
|
536
|
+
var pNode = this._parent;
|
|
537
|
+
while (pNode && pNode != this._batchNode) {
|
|
538
|
+
pNode._setReorderChildDirtyRecursively();
|
|
539
|
+
pNode = pNode.parent;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
|
|
544
|
+
// CCTextureProtocol
|
|
545
|
+
/**
|
|
546
|
+
* Returns the texture of the sprite node
|
|
547
|
+
* @returns {cc.Texture2D}
|
|
548
|
+
*/
|
|
549
|
+
getTexture:function () {
|
|
550
|
+
return this._texture;
|
|
551
|
+
},
|
|
552
|
+
|
|
553
|
+
_softInit: function (fileName, rect, rotated) {
|
|
554
|
+
if (fileName === undefined)
|
|
555
|
+
cc.Sprite.prototype.init.call(this);
|
|
556
|
+
else if (cc.isString(fileName)) {
|
|
557
|
+
if (fileName[0] === "#") {
|
|
558
|
+
// Init with a sprite frame name
|
|
559
|
+
var frameName = fileName.substr(1, fileName.length - 1);
|
|
560
|
+
var spriteFrame = cc.spriteFrameCache.getSpriteFrame(frameName);
|
|
561
|
+
this.initWithSpriteFrame(spriteFrame);
|
|
562
|
+
} else {
|
|
563
|
+
// Init with filename and rect
|
|
564
|
+
cc.Sprite.prototype.init.call(this, fileName, rect);
|
|
565
|
+
}
|
|
566
|
+
} else if (cc.isObject(fileName)) {
|
|
567
|
+
if (fileName instanceof cc.Texture2D) {
|
|
568
|
+
// Init with texture and rect
|
|
569
|
+
this.initWithTexture(fileName, rect, rotated);
|
|
570
|
+
} else if (fileName instanceof cc.SpriteFrame) {
|
|
571
|
+
// Init with a sprite frame
|
|
572
|
+
this.initWithSpriteFrame(fileName);
|
|
573
|
+
} else if ((fileName instanceof HTMLImageElement) || (fileName instanceof HTMLCanvasElement)) {
|
|
574
|
+
// Init with a canvas or image element
|
|
575
|
+
var texture2d = new cc.Texture2D();
|
|
576
|
+
texture2d.initWithElement(fileName);
|
|
577
|
+
texture2d.handleLoadedTexture();
|
|
578
|
+
this.initWithTexture(texture2d);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Returns the quad (tex coords, vertex coords and color) information.
|
|
585
|
+
* @return {cc.V3F_C4B_T2F_Quad|null} Returns a cc.V3F_C4B_T2F_Quad object when render mode is WebGL, returns null when render mode is Canvas.
|
|
586
|
+
*/
|
|
587
|
+
getQuad:function () {
|
|
588
|
+
return this._renderCmd.getQuad();
|
|
589
|
+
},
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* conforms to cc.TextureProtocol protocol
|
|
593
|
+
* @function
|
|
594
|
+
* @param {Number|cc.BlendFunc} src
|
|
595
|
+
* @param {Number} dst
|
|
596
|
+
*/
|
|
597
|
+
setBlendFunc: function (src, dst) {
|
|
598
|
+
var locBlendFunc = this._blendFunc;
|
|
599
|
+
if (dst === undefined) {
|
|
600
|
+
locBlendFunc.src = src.src;
|
|
601
|
+
locBlendFunc.dst = src.dst;
|
|
602
|
+
} else {
|
|
603
|
+
locBlendFunc.src = src;
|
|
604
|
+
locBlendFunc.dst = dst;
|
|
605
|
+
}
|
|
606
|
+
this._renderCmd.updateBlendFunc(locBlendFunc);
|
|
607
|
+
},
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* Initializes an empty sprite with nothing init.<br/>
|
|
611
|
+
* Please pass parameters to the constructor to initialize the sprite, do not call this function yourself.
|
|
612
|
+
* @function
|
|
613
|
+
* @return {Boolean}
|
|
614
|
+
*/
|
|
615
|
+
init: function () {
|
|
616
|
+
var _t = this;
|
|
617
|
+
if (arguments.length > 0)
|
|
618
|
+
return _t.initWithFile(arguments[0], arguments[1]);
|
|
619
|
+
|
|
620
|
+
cc.Node.prototype.init.call(_t);
|
|
621
|
+
_t.dirty = _t._recursiveDirty = false;
|
|
622
|
+
|
|
623
|
+
_t._blendFunc.src = cc.BLEND_SRC;
|
|
624
|
+
_t._blendFunc.dst = cc.BLEND_DST;
|
|
625
|
+
|
|
626
|
+
_t.texture = null;
|
|
627
|
+
_t._flippedX = _t._flippedY = false;
|
|
628
|
+
|
|
629
|
+
// default transform anchor: center
|
|
630
|
+
_t.anchorX = 0.5;
|
|
631
|
+
_t.anchorY = 0.5;
|
|
632
|
+
|
|
633
|
+
// zwoptex default values
|
|
634
|
+
_t._offsetPosition.x = 0;
|
|
635
|
+
_t._offsetPosition.y = 0;
|
|
636
|
+
_t._hasChildren = false;
|
|
637
|
+
|
|
638
|
+
this._renderCmd._init();
|
|
639
|
+
// updated in "useSelfRender"
|
|
640
|
+
// Atlas: TexCoords
|
|
641
|
+
_t.setTextureRect(cc.rect(0, 0, 0, 0), false, cc.size(0, 0));
|
|
642
|
+
return true;
|
|
643
|
+
},
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* <p>
|
|
647
|
+
* Initializes a sprite with an image filename.<br/>
|
|
648
|
+
*
|
|
649
|
+
* This method will find pszFilename from local file system, load its content to CCTexture2D,<br/>
|
|
650
|
+
* then use CCTexture2D to create a sprite.<br/>
|
|
651
|
+
* After initialization, the rect used will be the size of the image. The offset will be (0,0).<br/>
|
|
652
|
+
* Please pass parameters to the constructor to initialize the sprite, do not call this function yourself.
|
|
653
|
+
* </p>
|
|
654
|
+
* @param {String} filename The path to an image file in local file system
|
|
655
|
+
* @param {cc.Rect} rect The rectangle assigned the content area from texture.
|
|
656
|
+
* @return {Boolean} true if the sprite is initialized properly, false otherwise.
|
|
657
|
+
*/
|
|
658
|
+
initWithFile:function (filename, rect) {
|
|
659
|
+
cc.assert(filename, cc._LogInfos.Sprite_initWithFile);
|
|
660
|
+
|
|
661
|
+
var tex = cc.textureCache.getTextureForKey(filename);
|
|
662
|
+
if (!tex) {
|
|
663
|
+
tex = cc.textureCache.addImage(filename);
|
|
664
|
+
return this.initWithTexture(tex, rect || cc.rect(0, 0, tex._contentSize.width, tex._contentSize.height));
|
|
665
|
+
} else {
|
|
666
|
+
if (!rect) {
|
|
667
|
+
var size = tex.getContentSize();
|
|
668
|
+
rect = cc.rect(0, 0, size.width, size.height);
|
|
669
|
+
}
|
|
670
|
+
return this.initWithTexture(tex, rect);
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Initializes a sprite with a texture and a rect in points, optionally rotated. <br/>
|
|
676
|
+
* After initialization, the rect used will be the size of the texture, and the offset will be (0,0).<br/>
|
|
677
|
+
* Please pass parameters to the constructor to initialize the sprite, do not call this function yourself.
|
|
678
|
+
* @function
|
|
679
|
+
* @param {cc.Texture2D|HTMLImageElement|HTMLCanvasElement} texture A pointer to an existing CCTexture2D object. You can use a CCTexture2D object for many sprites.
|
|
680
|
+
* @param {cc.Rect} [rect] Only the contents inside rect of this texture will be applied for this sprite.
|
|
681
|
+
* @param {Boolean} [rotated] Whether or not the texture rectangle is rotated.
|
|
682
|
+
* @param {Boolean} [counterclockwise=true] Whether or not the texture rectangle rotation is counterclockwise (texture package is counterclockwise, spine is clockwise).
|
|
683
|
+
* @return {Boolean} true if the sprite is initialized properly, false otherwise.
|
|
684
|
+
*/
|
|
685
|
+
initWithTexture: function (texture, rect, rotated, counterclockwise) {
|
|
686
|
+
var _t = this;
|
|
687
|
+
cc.assert(arguments.length != 0, cc._LogInfos.CCSpriteBatchNode_initWithTexture);
|
|
688
|
+
|
|
689
|
+
rotated = rotated || false;
|
|
690
|
+
texture = this._renderCmd._handleTextureForRotatedTexture(texture, rect, rotated, counterclockwise);
|
|
691
|
+
|
|
692
|
+
if (!cc.Node.prototype.init.call(_t))
|
|
693
|
+
return false;
|
|
694
|
+
|
|
695
|
+
_t._batchNode = null;
|
|
696
|
+
_t._recursiveDirty = false;
|
|
697
|
+
_t.dirty = false;
|
|
698
|
+
_t._opacityModifyRGB = true;
|
|
699
|
+
|
|
700
|
+
_t._blendFunc.src = cc.BLEND_SRC;
|
|
701
|
+
_t._blendFunc.dst = cc.BLEND_DST;
|
|
702
|
+
|
|
703
|
+
_t._flippedX = _t._flippedY = false;
|
|
704
|
+
|
|
705
|
+
// default transform anchor: center
|
|
706
|
+
_t.setAnchorPoint(0.5, 0.5);
|
|
707
|
+
|
|
708
|
+
// zwoptex default values
|
|
709
|
+
_t._offsetPosition.x = 0;
|
|
710
|
+
_t._offsetPosition.y = 0;
|
|
711
|
+
_t._hasChildren = false;
|
|
712
|
+
|
|
713
|
+
this._renderCmd._init();
|
|
714
|
+
|
|
715
|
+
var locTextureLoaded = texture.isLoaded();
|
|
716
|
+
_t._textureLoaded = locTextureLoaded;
|
|
717
|
+
|
|
718
|
+
if (!locTextureLoaded) {
|
|
719
|
+
_t._rectRotated = rotated;
|
|
720
|
+
if (rect) {
|
|
721
|
+
_t._rect.x = rect.x;
|
|
722
|
+
_t._rect.y = rect.y;
|
|
723
|
+
_t._rect.width = rect.width;
|
|
724
|
+
_t._rect.height = rect.height;
|
|
725
|
+
}
|
|
726
|
+
if(_t.texture)
|
|
727
|
+
_t.texture.removeEventListener("load", _t);
|
|
728
|
+
texture.addEventListener("load", _t._renderCmd._textureLoadedCallback, _t);
|
|
729
|
+
_t.texture = texture;
|
|
730
|
+
return true;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
if (!rect)
|
|
734
|
+
rect = cc.rect(0, 0, texture.width, texture.height);
|
|
735
|
+
|
|
736
|
+
this._renderCmd._checkTextureBoundary(texture, rect, rotated);
|
|
737
|
+
|
|
738
|
+
_t.texture = texture;
|
|
739
|
+
_t.setTextureRect(rect, rotated);
|
|
740
|
+
|
|
741
|
+
// by default use "Self Render".
|
|
742
|
+
// if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render"
|
|
743
|
+
_t.setBatchNode(null);
|
|
744
|
+
return true;
|
|
745
|
+
},
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Updates the texture rect of the CCSprite in points.
|
|
749
|
+
* @function
|
|
750
|
+
* @param {cc.Rect} rect a rect of texture
|
|
751
|
+
* @param {Boolean} [rotated] Whether or not the texture is rotated
|
|
752
|
+
* @param {cc.Size} [untrimmedSize] The original pixels size of the texture
|
|
753
|
+
*/
|
|
754
|
+
setTextureRect: function (rect, rotated, untrimmedSize, needConvert) {
|
|
755
|
+
var _t = this;
|
|
756
|
+
_t._rectRotated = rotated || false;
|
|
757
|
+
_t.setContentSize(untrimmedSize || rect);
|
|
758
|
+
|
|
759
|
+
_t.setVertexRect(rect);
|
|
760
|
+
_t._renderCmd._setTextureCoords(rect, needConvert);
|
|
761
|
+
|
|
762
|
+
var relativeOffset = _t._unflippedOffsetPositionFromCenter;
|
|
763
|
+
if (_t._flippedX)
|
|
764
|
+
relativeOffset.x = -relativeOffset.x;
|
|
765
|
+
if (_t._flippedY)
|
|
766
|
+
relativeOffset.y = -relativeOffset.y;
|
|
767
|
+
var locRect = _t._rect;
|
|
768
|
+
_t._offsetPosition.x = relativeOffset.x + (_t._contentSize.width - locRect.width) / 2;
|
|
769
|
+
_t._offsetPosition.y = relativeOffset.y + (_t._contentSize.height - locRect.height) / 2;
|
|
770
|
+
|
|
771
|
+
// rendering using batch node
|
|
772
|
+
if (_t._batchNode) {
|
|
773
|
+
// update dirty, don't update _recursiveDirty
|
|
774
|
+
_t.dirty = true;
|
|
775
|
+
} else {
|
|
776
|
+
// self rendering
|
|
777
|
+
// Atlas: Vertex
|
|
778
|
+
this._renderCmd._resetForBatchNode();
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
|
|
782
|
+
// BatchNode methods
|
|
783
|
+
/**
|
|
784
|
+
* Updates the quad according the the rotation, position, scale values.
|
|
785
|
+
* @function
|
|
786
|
+
*/
|
|
787
|
+
updateTransform: function(){
|
|
788
|
+
this._renderCmd.updateTransform();
|
|
789
|
+
},
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Add child to sprite (override cc.Node)
|
|
793
|
+
* @function
|
|
794
|
+
* @param {cc.Sprite} child
|
|
795
|
+
* @param {Number} localZOrder child's zOrder
|
|
796
|
+
* @param {String} [tag] child's tag
|
|
797
|
+
* @override
|
|
798
|
+
*/
|
|
799
|
+
addChild: function (child, localZOrder, tag) {
|
|
800
|
+
cc.assert(child, cc._LogInfos.CCSpriteBatchNode_addChild_2);
|
|
801
|
+
|
|
802
|
+
if (localZOrder == null)
|
|
803
|
+
localZOrder = child._localZOrder;
|
|
804
|
+
if (tag == null)
|
|
805
|
+
tag = child.tag;
|
|
806
|
+
|
|
807
|
+
if(this._renderCmd._setBatchNodeForAddChild(child)){
|
|
808
|
+
//cc.Node already sets isReorderChildDirty_ so this needs to be after batchNode check
|
|
809
|
+
cc.Node.prototype.addChild.call(this, child, localZOrder, tag);
|
|
810
|
+
this._hasChildren = true;
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
|
|
814
|
+
// Frames
|
|
815
|
+
/**
|
|
816
|
+
* Sets a new sprite frame to the sprite.
|
|
817
|
+
* @function
|
|
818
|
+
* @param {cc.SpriteFrame|String} newFrame
|
|
819
|
+
*/
|
|
820
|
+
setSpriteFrame: function (newFrame) {
|
|
821
|
+
var _t = this;
|
|
822
|
+
if(cc.isString(newFrame)){
|
|
823
|
+
newFrame = cc.spriteFrameCache.getSpriteFrame(newFrame);
|
|
824
|
+
cc.assert(newFrame, cc._LogInfos.Sprite_setSpriteFrame)
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
this.setNodeDirty(true);
|
|
828
|
+
|
|
829
|
+
var frameOffset = newFrame.getOffset();
|
|
830
|
+
_t._unflippedOffsetPositionFromCenter.x = frameOffset.x;
|
|
831
|
+
_t._unflippedOffsetPositionFromCenter.y = frameOffset.y;
|
|
832
|
+
|
|
833
|
+
// update rect
|
|
834
|
+
var pNewTexture = newFrame.getTexture();
|
|
835
|
+
var locTextureLoaded = newFrame.textureLoaded();
|
|
836
|
+
if (!locTextureLoaded) {
|
|
837
|
+
_t._textureLoaded = false;
|
|
838
|
+
newFrame.addEventListener("load", function (sender) {
|
|
839
|
+
_t._textureLoaded = true;
|
|
840
|
+
var locNewTexture = sender.getTexture();
|
|
841
|
+
if (locNewTexture != _t._texture)
|
|
842
|
+
_t.texture = locNewTexture;
|
|
843
|
+
_t.setTextureRect(sender.getRect(), sender.isRotated(), sender.getOriginalSize());
|
|
844
|
+
_t.dispatchEvent("load");
|
|
845
|
+
_t.setColor(_t.color);
|
|
846
|
+
}, _t);
|
|
847
|
+
}else{
|
|
848
|
+
// update texture before updating texture rect
|
|
849
|
+
if (pNewTexture != _t._texture)
|
|
850
|
+
_t.texture = pNewTexture;
|
|
851
|
+
_t.setTextureRect(newFrame.getRect(), newFrame.isRotated(), newFrame.getOriginalSize());
|
|
852
|
+
}
|
|
853
|
+
this._renderCmd._updateForSetSpriteFrame(pNewTexture);
|
|
854
|
+
},
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Sets a new display frame to the sprite.
|
|
858
|
+
* @param {cc.SpriteFrame|String} newFrame
|
|
859
|
+
* @deprecated
|
|
860
|
+
*/
|
|
861
|
+
setDisplayFrame: function(newFrame){
|
|
862
|
+
cc.log(cc._LogInfos.Sprite_setDisplayFrame);
|
|
863
|
+
this.setSpriteFrame(newFrame);
|
|
864
|
+
},
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Returns whether or not a cc.SpriteFrame is being displayed
|
|
868
|
+
* @function
|
|
869
|
+
* @param {cc.SpriteFrame} frame
|
|
870
|
+
* @return {Boolean}
|
|
871
|
+
*/
|
|
872
|
+
isFrameDisplayed: function(frame){
|
|
873
|
+
return this._renderCmd.isFrameDisplayed(frame);
|
|
874
|
+
},
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Returns the current displayed frame.
|
|
878
|
+
* @return {cc.SpriteFrame}
|
|
879
|
+
*/
|
|
880
|
+
displayFrame: function () {
|
|
881
|
+
return new cc.SpriteFrame(this._texture,
|
|
882
|
+
cc.rectPointsToPixels(this._rect),
|
|
883
|
+
this._rectRotated,
|
|
884
|
+
cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter),
|
|
885
|
+
cc.sizePointsToPixels(this._contentSize));
|
|
886
|
+
},
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Sets the batch node to sprite
|
|
890
|
+
* @function
|
|
891
|
+
* @param {cc.SpriteBatchNode|null} spriteBatchNode
|
|
892
|
+
* @example
|
|
893
|
+
* var batch = new cc.SpriteBatchNode("Images/grossini_dance_atlas.png", 15);
|
|
894
|
+
* var sprite = new cc.Sprite(batch.texture, cc.rect(0, 0, 57, 57));
|
|
895
|
+
* batch.addChild(sprite);
|
|
896
|
+
* layer.addChild(batch);
|
|
897
|
+
*/
|
|
898
|
+
setBatchNode:function (spriteBatchNode) {
|
|
899
|
+
var _t = this;
|
|
900
|
+
_t._batchNode = spriteBatchNode; // weak reference
|
|
901
|
+
|
|
902
|
+
// self render
|
|
903
|
+
if (!_t._batchNode) {
|
|
904
|
+
_t.atlasIndex = cc.Sprite.INDEX_NOT_INITIALIZED;
|
|
905
|
+
_t.textureAtlas = null;
|
|
906
|
+
_t._recursiveDirty = false;
|
|
907
|
+
_t.dirty = false;
|
|
908
|
+
|
|
909
|
+
this._renderCmd._resetForBatchNode();
|
|
910
|
+
} else {
|
|
911
|
+
// using batch
|
|
912
|
+
_t._transformToBatch = cc.affineTransformIdentity();
|
|
913
|
+
_t.textureAtlas = _t._batchNode.getTextureAtlas(); // weak ref
|
|
914
|
+
}
|
|
915
|
+
},
|
|
916
|
+
|
|
917
|
+
// CCTextureProtocol
|
|
918
|
+
/**
|
|
919
|
+
* Sets the texture of sprite
|
|
920
|
+
* @function
|
|
921
|
+
* @param {cc.Texture2D|String} texture
|
|
922
|
+
*/
|
|
923
|
+
setTexture: function (texture) {
|
|
924
|
+
if(!texture)
|
|
925
|
+
return this._renderCmd._setTexture(null);
|
|
926
|
+
|
|
927
|
+
if(cc.isString(texture)){
|
|
928
|
+
texture = cc.textureCache.addImage(texture);
|
|
929
|
+
|
|
930
|
+
if(!texture._textureLoaded){
|
|
931
|
+
texture.addEventListener("load", function(){
|
|
932
|
+
this._renderCmd._setTexture(texture);
|
|
933
|
+
this._changeRectWithTexture(texture.getContentSize());
|
|
934
|
+
this.setColor(this._realColor);
|
|
935
|
+
this._textureLoaded = true;
|
|
936
|
+
}, this);
|
|
937
|
+
}else{
|
|
938
|
+
this._renderCmd._setTexture(texture);
|
|
939
|
+
this._changeRectWithTexture(texture.getContentSize());
|
|
940
|
+
this.setColor(this._realColor);
|
|
941
|
+
this._textureLoaded = true;
|
|
942
|
+
}
|
|
943
|
+
}else{
|
|
944
|
+
// CCSprite: setTexture doesn't work when the sprite is rendered using a CCSpriteSheet
|
|
945
|
+
cc.assert(texture instanceof cc.Texture2D, cc._LogInfos.Sprite_setTexture_2);
|
|
946
|
+
this._changeRectWithTexture(texture.getContentSize());
|
|
947
|
+
this._renderCmd._setTexture(texture);
|
|
948
|
+
}
|
|
949
|
+
},
|
|
950
|
+
|
|
951
|
+
_changeRectWithTexture: function(rect){
|
|
952
|
+
if(!rect || (!rect.width && !rect.height)) return;
|
|
953
|
+
var textureRect = this.getTextureRect();
|
|
954
|
+
if(textureRect.height || textureRect.width) return;
|
|
955
|
+
rect.x = rect.x || 0;
|
|
956
|
+
rect.y = rect.y || 0;
|
|
957
|
+
rect.width = rect.width || 0;
|
|
958
|
+
rect.height = rect.height || 0;
|
|
959
|
+
this.setTextureRect(rect);
|
|
960
|
+
},
|
|
961
|
+
|
|
962
|
+
_createRenderCmd: function(){
|
|
963
|
+
if(cc._renderType === cc._RENDER_TYPE_CANVAS)
|
|
964
|
+
return new cc.Sprite.CanvasRenderCmd(this);
|
|
965
|
+
else
|
|
966
|
+
return new cc.Sprite.WebGLRenderCmd(this);
|
|
967
|
+
}
|
|
968
|
+
});
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Create a sprite with image path or frame name or texture or spriteFrame.
|
|
972
|
+
* @deprecated since v3.0, please use new construction instead
|
|
973
|
+
* @see cc.Sprite
|
|
974
|
+
* @param {String|cc.SpriteFrame|HTMLImageElement|cc.Texture2D} fileName The string which indicates a path to image file, e.g., "scene1/monster.png".
|
|
975
|
+
* @param {cc.Rect} rect Only the contents inside rect of pszFileName's texture will be applied for this sprite.
|
|
976
|
+
* @param {Boolean} [rotated] Whether or not the texture rectangle is rotated.
|
|
977
|
+
* @return {cc.Sprite} A valid sprite object
|
|
978
|
+
*/
|
|
979
|
+
cc.Sprite.create = function (fileName, rect, rotated) {
|
|
980
|
+
return new cc.Sprite(fileName, rect, rotated);
|
|
981
|
+
};
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* @deprecated since v3.0, please use new construction instead
|
|
985
|
+
* @see cc.Sprite
|
|
986
|
+
* @function
|
|
987
|
+
*/
|
|
988
|
+
cc.Sprite.createWithTexture = cc.Sprite.create;
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* @deprecated since v3.0, please use new construction instead
|
|
992
|
+
* @see cc.Sprite
|
|
993
|
+
* @function
|
|
994
|
+
*/
|
|
995
|
+
cc.Sprite.createWithSpriteFrameName = cc.Sprite.create;
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* @deprecated since v3.0, please use new construction instead
|
|
999
|
+
* @see cc.Sprite
|
|
1000
|
+
* @function
|
|
1001
|
+
*/
|
|
1002
|
+
cc.Sprite.createWithSpriteFrame = cc.Sprite.create;
|
|
1003
|
+
/**
|
|
1004
|
+
* cc.Sprite invalid index on the cc.SpriteBatchNode
|
|
1005
|
+
* @constant
|
|
1006
|
+
* @type {Number}
|
|
1007
|
+
*/
|
|
1008
|
+
cc.Sprite.INDEX_NOT_INITIALIZED = -1;
|
|
1009
|
+
|
|
1010
|
+
cc.EventHelper.prototype.apply(cc.Sprite.prototype);
|
|
1011
|
+
|
|
1012
|
+
cc.assert(cc.isFunction(cc._tmp.PrototypeSprite), cc._LogInfos.MissingFile, "SpritesPropertyDefine.js");
|
|
1013
|
+
cc._tmp.PrototypeSprite();
|
|
1014
|
+
delete cc._tmp.PrototypeSprite;
|