ccb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,1099 @@
|
|
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
|
+
Copyright (c) 2012 Neofect. All rights reserved.
|
6
|
+
|
7
|
+
http://www.cocos2d-x.org
|
8
|
+
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
11
|
+
in the Software without restriction, including without limitation the rights
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
14
|
+
furnished to do so, subject to the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be included in
|
17
|
+
all copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
25
|
+
THE SOFTWARE.
|
26
|
+
|
27
|
+
Created by Jung Sang-Taik on 2012-03-16
|
28
|
+
****************************************************************************/
|
29
|
+
|
30
|
+
/**
|
31
|
+
* A 9-slice sprite for cocos2d.
|
32
|
+
*
|
33
|
+
* 9-slice scaling allows you to specify how scaling is applied
|
34
|
+
* to specific areas of a sprite. With 9-slice scaling (3x3 grid),
|
35
|
+
* you can ensure that the sprite does not become distorted when
|
36
|
+
* scaled.
|
37
|
+
*
|
38
|
+
* @see http://yannickloriot.com/library/ios/cccontrolextension/Classes/CCScale9Sprite.html
|
39
|
+
* @class
|
40
|
+
* @extends cc.Node
|
41
|
+
*
|
42
|
+
* @property {cc.Size} preferredSize - The preferred size of the 9-slice sprite
|
43
|
+
* @property {cc.Rect} capInsets - The cap insets of the 9-slice sprite
|
44
|
+
* @property {Number} insetLeft - The left inset of the 9-slice sprite
|
45
|
+
* @property {Number} insetTop - The top inset of the 9-slice sprite
|
46
|
+
* @property {Number} insetRight - The right inset of the 9-slice sprite
|
47
|
+
* @property {Number} insetBottom - The bottom inset of the 9-slice sprite
|
48
|
+
*/
|
49
|
+
cc.Scale9Sprite = cc.Node.extend(/** @lends cc.Scale9Sprite# */{
|
50
|
+
_spriteRect: null,
|
51
|
+
_capInsetsInternal: null,
|
52
|
+
_positionsAreDirty: false,
|
53
|
+
|
54
|
+
_scale9Image: null,
|
55
|
+
_topLeft: null,
|
56
|
+
_top: null,
|
57
|
+
_topRight: null,
|
58
|
+
_left: null,
|
59
|
+
_centre: null,
|
60
|
+
_right: null,
|
61
|
+
_bottomLeft: null,
|
62
|
+
_bottom: null,
|
63
|
+
_bottomRight: null,
|
64
|
+
|
65
|
+
_scale9Dirty: true,
|
66
|
+
|
67
|
+
_opacityModifyRGB: false,
|
68
|
+
|
69
|
+
_originalSize: null,
|
70
|
+
_preferredSize: null,
|
71
|
+
_opacity: 0,
|
72
|
+
_color: null,
|
73
|
+
_capInsets: null,
|
74
|
+
_insetLeft: 0,
|
75
|
+
_insetTop: 0,
|
76
|
+
_insetRight: 0,
|
77
|
+
_insetBottom: 0,
|
78
|
+
|
79
|
+
_spritesGenerated: false,
|
80
|
+
_spriteFrameRotated: false,
|
81
|
+
_textureLoaded:false,
|
82
|
+
_className:"Scale9Sprite",
|
83
|
+
|
84
|
+
//v3.3
|
85
|
+
_flippedX: false,
|
86
|
+
_flippedY: false,
|
87
|
+
|
88
|
+
/**
|
89
|
+
* return texture is loaded
|
90
|
+
* @returns {boolean}
|
91
|
+
*/
|
92
|
+
textureLoaded:function(){
|
93
|
+
return this._textureLoaded;
|
94
|
+
},
|
95
|
+
|
96
|
+
/**
|
97
|
+
* add texture loaded event listener
|
98
|
+
* @param {Function} callback
|
99
|
+
* @param {Object} target
|
100
|
+
* @deprecated since 3.1, please use addEventListener instead
|
101
|
+
*/
|
102
|
+
addLoadedEventListener:function(callback, target){
|
103
|
+
this.addEventListener("load", callback, target);
|
104
|
+
},
|
105
|
+
|
106
|
+
_updateCapInset: function () {
|
107
|
+
var insets, locInsetLeft = this._insetLeft, locInsetTop = this._insetTop, locInsetRight = this._insetRight;
|
108
|
+
var locSpriteRect = this._spriteRect, locInsetBottom = this._insetBottom;
|
109
|
+
if (locInsetLeft === 0 && locInsetTop === 0 && locInsetRight === 0 && locInsetBottom === 0) {
|
110
|
+
insets = cc.rect(0, 0, 0, 0);
|
111
|
+
} else {
|
112
|
+
insets = this._spriteFrameRotated ? cc.rect(locInsetBottom, locInsetLeft,
|
113
|
+
locSpriteRect.width - locInsetRight - locInsetLeft,
|
114
|
+
locSpriteRect.height - locInsetTop - locInsetBottom) :
|
115
|
+
cc.rect(locInsetLeft, locInsetTop,
|
116
|
+
locSpriteRect.width - locInsetLeft - locInsetRight,
|
117
|
+
locSpriteRect.height - locInsetTop - locInsetBottom);
|
118
|
+
}
|
119
|
+
this.setCapInsets(insets);
|
120
|
+
},
|
121
|
+
|
122
|
+
_updatePositions: function () {
|
123
|
+
// Check that instances are non-NULL
|
124
|
+
if (!((this._topLeft) && (this._topRight) && (this._bottomRight) &&
|
125
|
+
(this._bottomLeft) && (this._centre))) {
|
126
|
+
// if any of the above sprites are NULL, return
|
127
|
+
return;
|
128
|
+
}
|
129
|
+
|
130
|
+
var size = this._contentSize;
|
131
|
+
var locTopLeft = this._topLeft, locTopRight = this._topRight, locBottomRight = this._bottomRight, locBottomLeft = this._bottomLeft;
|
132
|
+
var locCenter = this._centre, locCenterContentSize = this._centre.getContentSize();
|
133
|
+
var locTopLeftContentSize = locTopLeft.getContentSize();
|
134
|
+
var locBottomLeftContentSize = locBottomLeft.getContentSize();
|
135
|
+
|
136
|
+
var sizableWidth = size.width - locTopLeftContentSize.width - locTopRight.getContentSize().width;
|
137
|
+
var sizableHeight = size.height - locTopLeftContentSize.height - locBottomRight.getContentSize().height;
|
138
|
+
|
139
|
+
var horizontalScale = sizableWidth / locCenterContentSize.width;
|
140
|
+
var verticalScale = sizableHeight / locCenterContentSize.height;
|
141
|
+
|
142
|
+
var rescaledWidth = locCenterContentSize.width * horizontalScale;
|
143
|
+
var rescaledHeight = locCenterContentSize.height * verticalScale;
|
144
|
+
|
145
|
+
var leftWidth = locBottomLeftContentSize.width;
|
146
|
+
var bottomHeight = locBottomLeftContentSize.height;
|
147
|
+
|
148
|
+
if (cc._renderType == cc._RENDER_TYPE_WEBGL) {
|
149
|
+
//browser is in canvas mode, need to manually control rounding to prevent overlapping pixels
|
150
|
+
var roundedRescaledWidth = Math.round(rescaledWidth);
|
151
|
+
if (rescaledWidth != roundedRescaledWidth) {
|
152
|
+
rescaledWidth = roundedRescaledWidth;
|
153
|
+
horizontalScale = rescaledWidth / locCenterContentSize.width;
|
154
|
+
}
|
155
|
+
var roundedRescaledHeight = Math.round(rescaledHeight);
|
156
|
+
if (rescaledHeight != roundedRescaledHeight) {
|
157
|
+
rescaledHeight = roundedRescaledHeight;
|
158
|
+
verticalScale = rescaledHeight / locCenterContentSize.height;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
locCenter.setScaleX(horizontalScale);
|
163
|
+
locCenter.setScaleY(verticalScale);
|
164
|
+
|
165
|
+
var locLeft = this._left, locRight = this._right, locTop = this._top, locBottom = this._bottom;
|
166
|
+
var tempAP = cc.p(0, 0);
|
167
|
+
locBottomLeft.setAnchorPoint(tempAP);
|
168
|
+
locBottomRight.setAnchorPoint(tempAP);
|
169
|
+
locTopLeft.setAnchorPoint(tempAP);
|
170
|
+
locTopRight.setAnchorPoint(tempAP);
|
171
|
+
locLeft.setAnchorPoint(tempAP);
|
172
|
+
locRight.setAnchorPoint(tempAP);
|
173
|
+
locTop.setAnchorPoint(tempAP);
|
174
|
+
locBottom.setAnchorPoint(tempAP);
|
175
|
+
locCenter.setAnchorPoint(tempAP);
|
176
|
+
|
177
|
+
// Position corners
|
178
|
+
locBottomLeft.setPosition(0, 0);
|
179
|
+
locBottomRight.setPosition(leftWidth + rescaledWidth, 0);
|
180
|
+
locTopLeft.setPosition(0, bottomHeight + rescaledHeight);
|
181
|
+
locTopRight.setPosition(leftWidth + rescaledWidth, bottomHeight + rescaledHeight);
|
182
|
+
|
183
|
+
// Scale and position borders
|
184
|
+
locLeft.setPosition(0, bottomHeight);
|
185
|
+
locLeft.setScaleY(verticalScale);
|
186
|
+
locRight.setPosition(leftWidth + rescaledWidth, bottomHeight);
|
187
|
+
locRight.setScaleY(verticalScale);
|
188
|
+
locBottom.setPosition(leftWidth, 0);
|
189
|
+
locBottom.setScaleX(horizontalScale);
|
190
|
+
locTop.setPosition(leftWidth, bottomHeight + rescaledHeight);
|
191
|
+
locTop.setScaleX(horizontalScale);
|
192
|
+
|
193
|
+
// Position centre
|
194
|
+
locCenter.setPosition(leftWidth, bottomHeight);
|
195
|
+
},
|
196
|
+
|
197
|
+
/**
|
198
|
+
* Constructor function. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
|
199
|
+
* @function
|
200
|
+
* @param {string|cc.SpriteFrame} file file name of texture or a SpriteFrame
|
201
|
+
* @param {cc.Rect} rect
|
202
|
+
* @param {cc.Rect} capInsets
|
203
|
+
* @returns {Scale9Sprite}
|
204
|
+
*/
|
205
|
+
ctor: function (file, rect, capInsets) {
|
206
|
+
cc.Node.prototype.ctor.call(this);
|
207
|
+
this._spriteRect = cc.rect(0, 0, 0, 0);
|
208
|
+
this._capInsetsInternal = cc.rect(0, 0, 0, 0);
|
209
|
+
|
210
|
+
this._originalSize = cc.size(0, 0);
|
211
|
+
this._preferredSize = cc.size(0, 0);
|
212
|
+
this._capInsets = cc.rect(0, 0, 0, 0);
|
213
|
+
|
214
|
+
if(file != undefined){
|
215
|
+
if(file instanceof cc.SpriteFrame)
|
216
|
+
this.initWithSpriteFrame(file, rect);
|
217
|
+
else{
|
218
|
+
var frame = cc.spriteFrameCache.getSpriteFrame(file);
|
219
|
+
if(frame != null)
|
220
|
+
this.initWithSpriteFrame(frame, rect);
|
221
|
+
else
|
222
|
+
this.initWithFile(file, rect, capInsets);
|
223
|
+
}
|
224
|
+
}else{
|
225
|
+
this.init();
|
226
|
+
}
|
227
|
+
},
|
228
|
+
|
229
|
+
getSprite: function () {
|
230
|
+
return this._scale9Image;
|
231
|
+
},
|
232
|
+
|
233
|
+
/** Original sprite's size. */
|
234
|
+
getOriginalSize: function () {
|
235
|
+
return cc.size(this._originalSize);
|
236
|
+
},
|
237
|
+
|
238
|
+
//if the preferredSize component is given as -1, it is ignored
|
239
|
+
getPreferredSize: function () {
|
240
|
+
return cc.size(this._preferredSize);
|
241
|
+
},
|
242
|
+
_getPreferredWidth: function () {
|
243
|
+
return this._preferredSize.width;
|
244
|
+
},
|
245
|
+
_getPreferredHeight: function () {
|
246
|
+
return this._preferredSize.height;
|
247
|
+
},
|
248
|
+
setPreferredSize: function (preferredSize) {
|
249
|
+
this.setContentSize(preferredSize);
|
250
|
+
this._preferredSize = preferredSize;
|
251
|
+
|
252
|
+
if (this._positionsAreDirty) {
|
253
|
+
this._updatePositions();
|
254
|
+
this._positionsAreDirty = false;
|
255
|
+
this._scale9Dirty = true;
|
256
|
+
}
|
257
|
+
},
|
258
|
+
_setPreferredWidth: function (value) {
|
259
|
+
this._setWidth(value);
|
260
|
+
this._preferredSize.width = value;
|
261
|
+
},
|
262
|
+
_setPreferredHeight: function (value) {
|
263
|
+
this._setHeight(value);
|
264
|
+
this._preferredSize.height = value;
|
265
|
+
},
|
266
|
+
|
267
|
+
/** Opacity: conforms to CCRGBAProtocol protocol */
|
268
|
+
setOpacity: function (opacity) {
|
269
|
+
if(!this._scale9Image)
|
270
|
+
return;
|
271
|
+
cc.Node.prototype.setOpacity.call(this, opacity);
|
272
|
+
var scaleChildren = this._scale9Image.getChildren();
|
273
|
+
for (var i = 0; i < scaleChildren.length; i++) {
|
274
|
+
var selChild = scaleChildren[i];
|
275
|
+
if (selChild)
|
276
|
+
selChild.setOpacity(opacity);
|
277
|
+
}
|
278
|
+
this._scale9Dirty = true;
|
279
|
+
},
|
280
|
+
|
281
|
+
/** Color: conforms to CCRGBAProtocol protocol */
|
282
|
+
setColor: function (color) {
|
283
|
+
if(!this._scale9Image)
|
284
|
+
return;
|
285
|
+
|
286
|
+
cc.Node.prototype.setColor.call(this, color);
|
287
|
+
var scaleChildren = this._scale9Image.getChildren();
|
288
|
+
for (var i = 0; i < scaleChildren.length; i++) {
|
289
|
+
var selChild = scaleChildren[i];
|
290
|
+
if (selChild)
|
291
|
+
selChild.setColor(color);
|
292
|
+
}
|
293
|
+
this._scale9Dirty = true;
|
294
|
+
},
|
295
|
+
|
296
|
+
getCapInsets: function () {
|
297
|
+
return cc.rect(this._capInsets);
|
298
|
+
},
|
299
|
+
|
300
|
+
setCapInsets: function (capInsets) {
|
301
|
+
if(!this._scale9Image)
|
302
|
+
return;
|
303
|
+
//backup the contentSize
|
304
|
+
var contentSize = this._contentSize;
|
305
|
+
var tempWidth = contentSize.width, tempHeight = contentSize.height;
|
306
|
+
|
307
|
+
this.updateWithBatchNode(this._scale9Image, this._spriteRect, this._spriteFrameRotated, capInsets);
|
308
|
+
//restore the contentSize
|
309
|
+
this.setContentSize(tempWidth, tempHeight);
|
310
|
+
},
|
311
|
+
|
312
|
+
/**
|
313
|
+
* Gets the left side inset
|
314
|
+
* @returns {number}
|
315
|
+
*/
|
316
|
+
getInsetLeft: function () {
|
317
|
+
return this._insetLeft;
|
318
|
+
},
|
319
|
+
|
320
|
+
/**
|
321
|
+
* Sets the left side inset
|
322
|
+
* @param {Number} insetLeft
|
323
|
+
*/
|
324
|
+
setInsetLeft: function (insetLeft) {
|
325
|
+
this._insetLeft = insetLeft;
|
326
|
+
this._updateCapInset();
|
327
|
+
},
|
328
|
+
|
329
|
+
/**
|
330
|
+
* Gets the top side inset
|
331
|
+
* @returns {number}
|
332
|
+
*/
|
333
|
+
getInsetTop: function () {
|
334
|
+
return this._insetTop;
|
335
|
+
},
|
336
|
+
|
337
|
+
/**
|
338
|
+
* Sets the top side inset
|
339
|
+
* @param {Number} insetTop
|
340
|
+
*/
|
341
|
+
setInsetTop: function (insetTop) {
|
342
|
+
this._insetTop = insetTop;
|
343
|
+
this._updateCapInset();
|
344
|
+
},
|
345
|
+
|
346
|
+
/**
|
347
|
+
* Gets the right side inset
|
348
|
+
* @returns {number}
|
349
|
+
*/
|
350
|
+
getInsetRight: function () {
|
351
|
+
return this._insetRight;
|
352
|
+
},
|
353
|
+
/**
|
354
|
+
* Sets the right side inset
|
355
|
+
* @param {Number} insetRight
|
356
|
+
*/
|
357
|
+
setInsetRight: function (insetRight) {
|
358
|
+
this._insetRight = insetRight;
|
359
|
+
this._updateCapInset();
|
360
|
+
},
|
361
|
+
|
362
|
+
/**
|
363
|
+
* Gets the bottom side inset
|
364
|
+
* @returns {number}
|
365
|
+
*/
|
366
|
+
getInsetBottom: function () {
|
367
|
+
return this._insetBottom;
|
368
|
+
},
|
369
|
+
/**
|
370
|
+
* Sets the bottom side inset
|
371
|
+
* @param {number} insetBottom
|
372
|
+
*/
|
373
|
+
setInsetBottom: function (insetBottom) {
|
374
|
+
this._insetBottom = insetBottom;
|
375
|
+
this._updateCapInset();
|
376
|
+
},
|
377
|
+
|
378
|
+
/**
|
379
|
+
* Sets the untransformed size of the Scale9Sprite.
|
380
|
+
* @override
|
381
|
+
* @param {cc.Size|Number} size The untransformed size of the Scale9Sprite or The untransformed size's width of the Scale9Sprite.
|
382
|
+
* @param {Number} [height] The untransformed size's height of the Scale9Sprite.
|
383
|
+
*/
|
384
|
+
setContentSize: function (size, height) {
|
385
|
+
cc.Node.prototype.setContentSize.call(this, size, height);
|
386
|
+
this._positionsAreDirty = true;
|
387
|
+
},
|
388
|
+
|
389
|
+
_setWidth: function (value) {
|
390
|
+
cc.Node.prototype._setWidth.call(this, value);
|
391
|
+
this._positionsAreDirty = true;
|
392
|
+
},
|
393
|
+
|
394
|
+
_setHeight: function (value) {
|
395
|
+
cc.Node.prototype._setHeight.call(this, value);
|
396
|
+
this._positionsAreDirty = true;
|
397
|
+
},
|
398
|
+
|
399
|
+
/**
|
400
|
+
* Initializes a cc.Scale9Sprite. please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
|
401
|
+
* @returns {boolean}
|
402
|
+
*/
|
403
|
+
init: function () {
|
404
|
+
return this.initWithBatchNode(null, cc.rect(0, 0, 0, 0), false, cc.rect(0, 0, 0, 0));
|
405
|
+
},
|
406
|
+
|
407
|
+
/**
|
408
|
+
* Initializes a 9-slice sprite with a SpriteBatchNode.
|
409
|
+
* @param {cc.SpriteBatchNode} batchNode
|
410
|
+
* @param {cc.Rect} rect
|
411
|
+
* @param {boolean|cc.Rect} rotated
|
412
|
+
* @param {cc.Rect} [capInsets]
|
413
|
+
* @returns {boolean}
|
414
|
+
*/
|
415
|
+
initWithBatchNode: function (batchNode, rect, rotated, capInsets) {
|
416
|
+
if (capInsets === undefined) {
|
417
|
+
capInsets = rotated;
|
418
|
+
rotated = false;
|
419
|
+
}
|
420
|
+
|
421
|
+
if (batchNode)
|
422
|
+
this.updateWithBatchNode(batchNode, rect, rotated, capInsets);
|
423
|
+
this.setCascadeColorEnabled(true);
|
424
|
+
this.setCascadeOpacityEnabled(true);
|
425
|
+
this.setAnchorPoint(0.5, 0.5);
|
426
|
+
this._positionsAreDirty = true;
|
427
|
+
return true;
|
428
|
+
},
|
429
|
+
|
430
|
+
/**
|
431
|
+
* Initializes a 9-slice sprite with a texture file, a delimitation zone and
|
432
|
+
* with the specified cap insets.
|
433
|
+
* Once the sprite is created, you can then call its "setContentSize:" method
|
434
|
+
* to resize the sprite will all it's 9-slice goodness intact.
|
435
|
+
* It respects the anchorPoint too.
|
436
|
+
*
|
437
|
+
* @param {String} file The name of the texture file.
|
438
|
+
* @param {cc.Rect} rect The rectangle that describes the sub-part of the texture that
|
439
|
+
* is the whole image. If the shape is the whole texture, set this to the texture's full rect.
|
440
|
+
* @param {cc.Rect} capInsets The values to use for the cap insets.
|
441
|
+
*/
|
442
|
+
initWithFile: function (file, rect, capInsets) {
|
443
|
+
if (file instanceof cc.Rect) {
|
444
|
+
file = arguments[1];
|
445
|
+
capInsets = arguments[0];
|
446
|
+
rect = cc.rect(0, 0, 0, 0);
|
447
|
+
} else {
|
448
|
+
rect = rect || cc.rect(0, 0, 0, 0);
|
449
|
+
capInsets = capInsets || cc.rect(0, 0, 0, 0);
|
450
|
+
}
|
451
|
+
|
452
|
+
if(!file)
|
453
|
+
throw "cc.Scale9Sprite.initWithFile(): file should be non-null";
|
454
|
+
|
455
|
+
var texture = cc.textureCache.getTextureForKey(file);
|
456
|
+
if (!texture) {
|
457
|
+
texture = cc.textureCache.addImage(file);
|
458
|
+
}
|
459
|
+
|
460
|
+
var locLoaded = texture.isLoaded();
|
461
|
+
this._textureLoaded = locLoaded;
|
462
|
+
if(!locLoaded){
|
463
|
+
texture.addEventListener("load", function(sender){
|
464
|
+
// the texture is rotated on Canvas render mode, so isRotated always is false.
|
465
|
+
var preferredSize = this._preferredSize;
|
466
|
+
preferredSize = cc.size(preferredSize.width, preferredSize.height);
|
467
|
+
var size = sender.getContentSize();
|
468
|
+
this.updateWithBatchNode(this._scale9Image, cc.rect(0,0,size.width,size.height), false, this._capInsets);
|
469
|
+
this.setPreferredSize(preferredSize);
|
470
|
+
this._positionsAreDirty = true;
|
471
|
+
this.dispatchEvent("load");
|
472
|
+
}, this);
|
473
|
+
}
|
474
|
+
|
475
|
+
return this.initWithBatchNode(new cc.SpriteBatchNode(file, 9), rect, false, capInsets);
|
476
|
+
},
|
477
|
+
|
478
|
+
/**
|
479
|
+
* Initializes a 9-slice sprite with an sprite frame and with the specified
|
480
|
+
* cap insets.
|
481
|
+
* Once the sprite is created, you can then call its "setContentSize:" method
|
482
|
+
* to resize the sprite will all it's 9-slice goodness interact.
|
483
|
+
* It respects the anchorPoint too.
|
484
|
+
*
|
485
|
+
* @param spriteFrame The sprite frame object.
|
486
|
+
* @param capInsets The values to use for the cap insets.
|
487
|
+
*/
|
488
|
+
initWithSpriteFrame: function (spriteFrame, capInsets) {
|
489
|
+
if(!spriteFrame || !spriteFrame.getTexture())
|
490
|
+
throw "cc.Scale9Sprite.initWithSpriteFrame(): spriteFrame should be non-null and its texture should be non-null";
|
491
|
+
|
492
|
+
capInsets = capInsets || cc.rect(0, 0, 0, 0);
|
493
|
+
var locLoaded = spriteFrame.textureLoaded();
|
494
|
+
this._textureLoaded = locLoaded;
|
495
|
+
if(!locLoaded){
|
496
|
+
spriteFrame.addEventListener("load", function(sender){
|
497
|
+
// the texture is rotated on Canvas render mode, so isRotated always is false.
|
498
|
+
var preferredSize = this._preferredSize;
|
499
|
+
preferredSize = cc.size(preferredSize.width, preferredSize.height);
|
500
|
+
this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets);
|
501
|
+
this.setPreferredSize(preferredSize);
|
502
|
+
this._positionsAreDirty = true;
|
503
|
+
this.dispatchEvent("load");
|
504
|
+
},this);
|
505
|
+
}
|
506
|
+
var batchNode = new cc.SpriteBatchNode(spriteFrame.getTexture(), 9);
|
507
|
+
// the texture is rotated on Canvas render mode, so isRotated always is false.
|
508
|
+
return this.initWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), capInsets);
|
509
|
+
},
|
510
|
+
|
511
|
+
/**
|
512
|
+
* Initializes a 9-slice sprite with an sprite frame name and with the specified
|
513
|
+
* cap insets.
|
514
|
+
* Once the sprite is created, you can then call its "setContentSize:" method
|
515
|
+
* to resize the sprite will all it's 9-slice goodness interact.
|
516
|
+
* It respects the anchorPoint too.
|
517
|
+
*
|
518
|
+
* @param spriteFrameName The sprite frame name.
|
519
|
+
* @param capInsets The values to use for the cap insets.
|
520
|
+
*/
|
521
|
+
initWithSpriteFrameName: function (spriteFrameName, capInsets) {
|
522
|
+
if(!spriteFrameName)
|
523
|
+
throw "cc.Scale9Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null";
|
524
|
+
capInsets = capInsets || cc.rect(0, 0, 0, 0);
|
525
|
+
|
526
|
+
var frame = cc.spriteFrameCache.getSpriteFrame(spriteFrameName);
|
527
|
+
if (frame == null) {
|
528
|
+
cc.log("cc.Scale9Sprite.initWithSpriteFrameName(): can't find the sprite frame by spriteFrameName");
|
529
|
+
return false;
|
530
|
+
}
|
531
|
+
|
532
|
+
return this.initWithSpriteFrame(frame, capInsets);
|
533
|
+
},
|
534
|
+
|
535
|
+
/**
|
536
|
+
* Creates and returns a new sprite object with the specified cap insets.
|
537
|
+
* You use this method to add cap insets to a sprite or to change the existing
|
538
|
+
* cap insets of a sprite. In both cases, you get back a new image and the
|
539
|
+
* original sprite remains untouched.
|
540
|
+
*
|
541
|
+
* @param {cc.Rect} capInsets The values to use for the cap insets.
|
542
|
+
*/
|
543
|
+
resizableSpriteWithCapInsets: function (capInsets) {
|
544
|
+
var pReturn = new cc.Scale9Sprite();
|
545
|
+
if (pReturn && pReturn.initWithBatchNode(this._scale9Image, this._spriteRect, false, capInsets))
|
546
|
+
return pReturn;
|
547
|
+
return null;
|
548
|
+
},
|
549
|
+
|
550
|
+
/** sets the premultipliedAlphaOpacity property.
|
551
|
+
If set to NO then opacity will be applied as: glColor(R,G,B,opacity);
|
552
|
+
If set to YES then opacity will be applied as: glColor(opacity, opacity, opacity, opacity );
|
553
|
+
Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO
|
554
|
+
@since v0.8
|
555
|
+
*/
|
556
|
+
setOpacityModifyRGB: function (value) {
|
557
|
+
if(!this._scale9Image)
|
558
|
+
return;
|
559
|
+
this._opacityModifyRGB = value;
|
560
|
+
var scaleChildren = this._scale9Image.getChildren();
|
561
|
+
if (scaleChildren) {
|
562
|
+
for (var i = 0, len = scaleChildren.length; i < len; i++)
|
563
|
+
scaleChildren[i].setOpacityModifyRGB(value);
|
564
|
+
}
|
565
|
+
},
|
566
|
+
|
567
|
+
/** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity);
|
568
|
+
@since v0.8
|
569
|
+
*/
|
570
|
+
isOpacityModifyRGB: function () {
|
571
|
+
return this._opacityModifyRGB;
|
572
|
+
},
|
573
|
+
|
574
|
+
/**
|
575
|
+
* Update the scale9Sprite with a SpriteBatchNode.
|
576
|
+
* @param {cc.SpriteBatchNode} batchNode
|
577
|
+
* @param {cc.Rect} originalRect
|
578
|
+
* @param {boolean} rotated
|
579
|
+
* @param {cc.Rect} capInsets
|
580
|
+
* @returns {boolean}
|
581
|
+
*/
|
582
|
+
updateWithBatchNode: function (batchNode, originalRect, rotated, capInsets) {
|
583
|
+
var opacity = this.getOpacity();
|
584
|
+
var color = this.getColor();
|
585
|
+
var rect = cc.rect(originalRect.x, originalRect.y, originalRect.width, originalRect.height);
|
586
|
+
|
587
|
+
// Release old sprites
|
588
|
+
this.removeAllChildren(true);
|
589
|
+
|
590
|
+
if (this._scale9Image != batchNode)
|
591
|
+
this._scale9Image = batchNode;
|
592
|
+
|
593
|
+
if(!this._scale9Image)
|
594
|
+
return false;
|
595
|
+
|
596
|
+
var tmpTexture = batchNode.getTexture();
|
597
|
+
var locLoaded = tmpTexture.isLoaded();
|
598
|
+
this._textureLoaded = locLoaded;
|
599
|
+
if(!locLoaded){
|
600
|
+
tmpTexture.addEventListener("load", function(sender){
|
601
|
+
this._positionsAreDirty = true;
|
602
|
+
this.dispatchEvent("load");
|
603
|
+
},this);
|
604
|
+
return true;
|
605
|
+
}
|
606
|
+
var locScale9Image = this._scale9Image;
|
607
|
+
locScale9Image.removeAllChildren(true);
|
608
|
+
|
609
|
+
//this._capInsets = capInsets;
|
610
|
+
var locCapInsets = this._capInsets;
|
611
|
+
locCapInsets.x = capInsets.x;
|
612
|
+
locCapInsets.y = capInsets.y;
|
613
|
+
locCapInsets.width = capInsets.width;
|
614
|
+
locCapInsets.height = capInsets.height;
|
615
|
+
this._spriteFrameRotated = rotated;
|
616
|
+
|
617
|
+
var selTexture = locScale9Image.getTexture();
|
618
|
+
|
619
|
+
// If there is no given rect
|
620
|
+
if (cc._rectEqualToZero(rect)) {
|
621
|
+
// Get the texture size as original
|
622
|
+
var textureSize = selTexture.getContentSize();
|
623
|
+
rect = cc.rect(0, 0, textureSize.width, textureSize.height);
|
624
|
+
}
|
625
|
+
|
626
|
+
// Set the given rect's size as original size
|
627
|
+
this._spriteRect = rect;
|
628
|
+
var locSpriteRect = this._spriteRect;
|
629
|
+
locSpriteRect.x = rect.x;
|
630
|
+
locSpriteRect.y = rect.y;
|
631
|
+
locSpriteRect.width = rect.width;
|
632
|
+
locSpriteRect.height = rect.height;
|
633
|
+
|
634
|
+
this._originalSize.width = rect.width;
|
635
|
+
this._originalSize.height = rect.height;
|
636
|
+
|
637
|
+
var locPreferredSize = this._preferredSize;
|
638
|
+
if(locPreferredSize.width === 0 && locPreferredSize.height === 0){
|
639
|
+
locPreferredSize.width = rect.width;
|
640
|
+
locPreferredSize.height = rect.height;
|
641
|
+
}
|
642
|
+
|
643
|
+
var locCapInsetsInternal = this._capInsetsInternal;
|
644
|
+
if(capInsets){
|
645
|
+
locCapInsetsInternal.x = capInsets.x;
|
646
|
+
locCapInsetsInternal.y = capInsets.y;
|
647
|
+
locCapInsetsInternal.width = capInsets.width;
|
648
|
+
locCapInsetsInternal.height = capInsets.height;
|
649
|
+
}
|
650
|
+
var w = rect.width, h = rect.height;
|
651
|
+
|
652
|
+
// If there is no specified center region
|
653
|
+
if (cc._rectEqualToZero(locCapInsetsInternal)) {
|
654
|
+
// CCLog("... cap insets not specified : using default cap insets ...");
|
655
|
+
locCapInsetsInternal.x = w / 3;
|
656
|
+
locCapInsetsInternal.y = h / 3;
|
657
|
+
locCapInsetsInternal.width = w / 3;
|
658
|
+
locCapInsetsInternal.height = h / 3;
|
659
|
+
}
|
660
|
+
|
661
|
+
var left_w = locCapInsetsInternal.x, center_w = locCapInsetsInternal.width, right_w = w - (left_w + center_w);
|
662
|
+
|
663
|
+
var top_h = locCapInsetsInternal.y, center_h = locCapInsetsInternal.height, bottom_h = h - (top_h + center_h);
|
664
|
+
|
665
|
+
// calculate rects
|
666
|
+
// ... top row
|
667
|
+
var x = 0.0, y = 0.0;
|
668
|
+
|
669
|
+
// top left
|
670
|
+
var lefttopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, top_h + 0.5 | 0);
|
671
|
+
|
672
|
+
// top center
|
673
|
+
x += left_w;
|
674
|
+
var centertopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, top_h + 0.5 | 0);
|
675
|
+
|
676
|
+
// top right
|
677
|
+
x += center_w;
|
678
|
+
var righttopbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, top_h + 0.5 | 0);
|
679
|
+
|
680
|
+
// ... center row
|
681
|
+
x = 0.0;
|
682
|
+
y = 0.0;
|
683
|
+
|
684
|
+
y += top_h;
|
685
|
+
// center left
|
686
|
+
var leftcenterbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, center_h + 0.5 | 0);
|
687
|
+
|
688
|
+
// center center
|
689
|
+
x += left_w;
|
690
|
+
var centerbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, center_h + 0.5 | 0);
|
691
|
+
|
692
|
+
// center right
|
693
|
+
x += center_w;
|
694
|
+
var rightcenterbounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, center_h + 0.5 | 0);
|
695
|
+
|
696
|
+
// ... bottom row
|
697
|
+
x = 0.0;
|
698
|
+
y = 0.0;
|
699
|
+
y += top_h;
|
700
|
+
y += center_h;
|
701
|
+
|
702
|
+
// bottom left
|
703
|
+
var leftbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, left_w + 0.5 | 0, bottom_h + 0.5 | 0);
|
704
|
+
|
705
|
+
// bottom center
|
706
|
+
x += left_w;
|
707
|
+
var centerbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, center_w + 0.5 | 0, bottom_h + 0.5 | 0);
|
708
|
+
|
709
|
+
// bottom right
|
710
|
+
x += center_w;
|
711
|
+
var rightbottombounds = cc.rect(x + 0.5 | 0, y + 0.5 | 0, right_w + 0.5 | 0, bottom_h + 0.5 | 0);
|
712
|
+
|
713
|
+
var t = cc.affineTransformMakeIdentity();
|
714
|
+
if (!rotated) {
|
715
|
+
// CCLog("!rotated");
|
716
|
+
t = cc.affineTransformTranslate(t, rect.x, rect.y);
|
717
|
+
|
718
|
+
cc._rectApplyAffineTransformIn(centerbounds, t);
|
719
|
+
cc._rectApplyAffineTransformIn(rightbottombounds, t);
|
720
|
+
cc._rectApplyAffineTransformIn(leftbottombounds, t);
|
721
|
+
cc._rectApplyAffineTransformIn(righttopbounds, t);
|
722
|
+
cc._rectApplyAffineTransformIn(lefttopbounds, t);
|
723
|
+
cc._rectApplyAffineTransformIn(rightcenterbounds, t);
|
724
|
+
cc._rectApplyAffineTransformIn(leftcenterbounds, t);
|
725
|
+
cc._rectApplyAffineTransformIn(centerbottombounds, t);
|
726
|
+
cc._rectApplyAffineTransformIn(centertopbounds, t);
|
727
|
+
|
728
|
+
// Centre
|
729
|
+
this._centre = new cc.Sprite();
|
730
|
+
this._centre.initWithTexture(selTexture, centerbounds);
|
731
|
+
locScale9Image.addChild(this._centre, 0, cc.Scale9Sprite.POSITIONS_CENTRE);
|
732
|
+
|
733
|
+
// Top
|
734
|
+
this._top = new cc.Sprite();
|
735
|
+
this._top.initWithTexture(selTexture, centertopbounds);
|
736
|
+
locScale9Image.addChild(this._top, 1, cc.Scale9Sprite.POSITIONS_TOP);
|
737
|
+
|
738
|
+
// Bottom
|
739
|
+
this._bottom = new cc.Sprite();
|
740
|
+
this._bottom.initWithTexture(selTexture, centerbottombounds);
|
741
|
+
locScale9Image.addChild(this._bottom, 1, cc.Scale9Sprite.POSITIONS_BOTTOM);
|
742
|
+
|
743
|
+
// Left
|
744
|
+
this._left = new cc.Sprite();
|
745
|
+
this._left.initWithTexture(selTexture, leftcenterbounds);
|
746
|
+
locScale9Image.addChild(this._left, 1, cc.Scale9Sprite.POSITIONS_LEFT);
|
747
|
+
|
748
|
+
// Right
|
749
|
+
this._right = new cc.Sprite();
|
750
|
+
this._right.initWithTexture(selTexture, rightcenterbounds);
|
751
|
+
locScale9Image.addChild(this._right, 1, cc.Scale9Sprite.POSITIONS_RIGHT);
|
752
|
+
|
753
|
+
// Top left
|
754
|
+
this._topLeft = new cc.Sprite();
|
755
|
+
this._topLeft.initWithTexture(selTexture, lefttopbounds);
|
756
|
+
locScale9Image.addChild(this._topLeft, 2, cc.Scale9Sprite.POSITIONS_TOPLEFT);
|
757
|
+
|
758
|
+
// Top right
|
759
|
+
this._topRight = new cc.Sprite();
|
760
|
+
this._topRight.initWithTexture(selTexture, righttopbounds);
|
761
|
+
locScale9Image.addChild(this._topRight, 2, cc.Scale9Sprite.POSITIONS_TOPRIGHT);
|
762
|
+
|
763
|
+
// Bottom left
|
764
|
+
this._bottomLeft = new cc.Sprite();
|
765
|
+
this._bottomLeft.initWithTexture(selTexture, leftbottombounds);
|
766
|
+
locScale9Image.addChild(this._bottomLeft, 2, cc.Scale9Sprite.POSITIONS_BOTTOMLEFT);
|
767
|
+
|
768
|
+
// Bottom right
|
769
|
+
this._bottomRight = new cc.Sprite();
|
770
|
+
this._bottomRight.initWithTexture(selTexture, rightbottombounds);
|
771
|
+
locScale9Image.addChild(this._bottomRight, 2, cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT);
|
772
|
+
} else {
|
773
|
+
// set up transformation of coordinates
|
774
|
+
// to handle the case where the sprite is stored rotated
|
775
|
+
// in the spritesheet
|
776
|
+
// CCLog("rotated");
|
777
|
+
var rotatedcenterbounds = centerbounds;
|
778
|
+
var rotatedrightbottombounds = rightbottombounds;
|
779
|
+
var rotatedleftbottombounds = leftbottombounds;
|
780
|
+
var rotatedrighttopbounds = righttopbounds;
|
781
|
+
var rotatedlefttopbounds = lefttopbounds;
|
782
|
+
var rotatedrightcenterbounds = rightcenterbounds;
|
783
|
+
var rotatedleftcenterbounds = leftcenterbounds;
|
784
|
+
var rotatedcenterbottombounds = centerbottombounds;
|
785
|
+
var rotatedcentertopbounds = centertopbounds;
|
786
|
+
|
787
|
+
t = cc.affineTransformTranslate(t, rect.height + rect.x, rect.y);
|
788
|
+
t = cc.affineTransformRotate(t, 1.57079633);
|
789
|
+
|
790
|
+
centerbounds = cc.rectApplyAffineTransform(centerbounds, t);
|
791
|
+
rightbottombounds = cc.rectApplyAffineTransform(rightbottombounds, t);
|
792
|
+
leftbottombounds = cc.rectApplyAffineTransform(leftbottombounds, t);
|
793
|
+
righttopbounds = cc.rectApplyAffineTransform(righttopbounds, t);
|
794
|
+
lefttopbounds = cc.rectApplyAffineTransform(lefttopbounds, t);
|
795
|
+
rightcenterbounds = cc.rectApplyAffineTransform(rightcenterbounds, t);
|
796
|
+
leftcenterbounds = cc.rectApplyAffineTransform(leftcenterbounds, t);
|
797
|
+
centerbottombounds = cc.rectApplyAffineTransform(centerbottombounds, t);
|
798
|
+
centertopbounds = cc.rectApplyAffineTransform(centertopbounds, t);
|
799
|
+
|
800
|
+
rotatedcenterbounds.x = centerbounds.x;
|
801
|
+
rotatedcenterbounds.y = centerbounds.y;
|
802
|
+
|
803
|
+
rotatedrightbottombounds.x = rightbottombounds.x;
|
804
|
+
rotatedrightbottombounds.y = rightbottombounds.y;
|
805
|
+
|
806
|
+
rotatedleftbottombounds.x = leftbottombounds.x;
|
807
|
+
rotatedleftbottombounds.y = leftbottombounds.y;
|
808
|
+
|
809
|
+
rotatedrighttopbounds.x = righttopbounds.x;
|
810
|
+
rotatedrighttopbounds.y = righttopbounds.y;
|
811
|
+
|
812
|
+
rotatedlefttopbounds.x = lefttopbounds.x;
|
813
|
+
rotatedlefttopbounds.y = lefttopbounds.y;
|
814
|
+
|
815
|
+
rotatedrightcenterbounds.x = rightcenterbounds.x;
|
816
|
+
rotatedrightcenterbounds.y = rightcenterbounds.y;
|
817
|
+
|
818
|
+
rotatedleftcenterbounds.x = leftcenterbounds.x;
|
819
|
+
rotatedleftcenterbounds.y = leftcenterbounds.y;
|
820
|
+
|
821
|
+
rotatedcenterbottombounds.x = centerbottombounds.x;
|
822
|
+
rotatedcenterbottombounds.y = centerbottombounds.y;
|
823
|
+
|
824
|
+
rotatedcentertopbounds.x = centertopbounds.x;
|
825
|
+
rotatedcentertopbounds.y = centertopbounds.y;
|
826
|
+
|
827
|
+
// Centre
|
828
|
+
this._centre = new cc.Sprite();
|
829
|
+
this._centre.initWithTexture(selTexture, rotatedcenterbounds, true);
|
830
|
+
locScale9Image.addChild(this._centre, 0, cc.Scale9Sprite.POSITIONS_CENTRE);
|
831
|
+
|
832
|
+
// Top
|
833
|
+
this._top = new cc.Sprite();
|
834
|
+
this._top.initWithTexture(selTexture, rotatedcentertopbounds, true);
|
835
|
+
locScale9Image.addChild(this._top, 1, cc.Scale9Sprite.POSITIONS_TOP);
|
836
|
+
|
837
|
+
// Bottom
|
838
|
+
this._bottom = new cc.Sprite();
|
839
|
+
this._bottom.initWithTexture(selTexture, rotatedcenterbottombounds, true);
|
840
|
+
locScale9Image.addChild(this._bottom, 1, cc.Scale9Sprite.POSITIONS_BOTTOM);
|
841
|
+
|
842
|
+
// Left
|
843
|
+
this._left = new cc.Sprite();
|
844
|
+
this._left.initWithTexture(selTexture, rotatedleftcenterbounds, true);
|
845
|
+
locScale9Image.addChild(this._left, 1, cc.Scale9Sprite.POSITIONS_LEFT);
|
846
|
+
|
847
|
+
// Right
|
848
|
+
this._right = new cc.Sprite();
|
849
|
+
this._right.initWithTexture(selTexture, rotatedrightcenterbounds, true);
|
850
|
+
locScale9Image.addChild(this._right, 1, cc.Scale9Sprite.POSITIONS_RIGHT);
|
851
|
+
|
852
|
+
// Top left
|
853
|
+
this._topLeft = new cc.Sprite();
|
854
|
+
this._topLeft.initWithTexture(selTexture, rotatedlefttopbounds, true);
|
855
|
+
locScale9Image.addChild(this._topLeft, 2, cc.Scale9Sprite.POSITIONS_TOPLEFT);
|
856
|
+
|
857
|
+
// Top right
|
858
|
+
this._topRight = new cc.Sprite();
|
859
|
+
this._topRight.initWithTexture(selTexture, rotatedrighttopbounds, true);
|
860
|
+
locScale9Image.addChild(this._topRight, 2, cc.Scale9Sprite.POSITIONS_TOPRIGHT);
|
861
|
+
|
862
|
+
// Bottom left
|
863
|
+
this._bottomLeft = new cc.Sprite();
|
864
|
+
this._bottomLeft.initWithTexture(selTexture, rotatedleftbottombounds, true);
|
865
|
+
locScale9Image.addChild(this._bottomLeft, 2, cc.Scale9Sprite.POSITIONS_BOTTOMLEFT);
|
866
|
+
|
867
|
+
// Bottom right
|
868
|
+
this._bottomRight = new cc.Sprite();
|
869
|
+
this._bottomRight.initWithTexture(selTexture, rotatedrightbottombounds, true);
|
870
|
+
locScale9Image.addChild(this._bottomRight, 2, cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT);
|
871
|
+
}
|
872
|
+
|
873
|
+
this.setContentSize(rect.width, rect.height);
|
874
|
+
if(cc._renderType === cc._RENDER_TYPE_WEBGL)
|
875
|
+
this.addChild(locScale9Image);
|
876
|
+
|
877
|
+
if (this._spritesGenerated) {
|
878
|
+
// Restore color and opacity
|
879
|
+
this.setOpacity(opacity);
|
880
|
+
this.setColor(color);
|
881
|
+
}
|
882
|
+
this._spritesGenerated = true;
|
883
|
+
return true;
|
884
|
+
},
|
885
|
+
|
886
|
+
/**
|
887
|
+
* set the sprite frame of cc.Scale9Sprite
|
888
|
+
* @param {cc.SpriteFrame} spriteFrame
|
889
|
+
*/
|
890
|
+
setSpriteFrame: function (spriteFrame) {
|
891
|
+
var batchNode = new cc.SpriteBatchNode(spriteFrame.getTexture(), 9);
|
892
|
+
// the texture is rotated on Canvas render mode, so isRotated always is false.
|
893
|
+
var locLoaded = spriteFrame.textureLoaded();
|
894
|
+
this._textureLoaded = locLoaded;
|
895
|
+
if(!locLoaded){
|
896
|
+
spriteFrame.addEventListener("load", function(sender){
|
897
|
+
// the texture is rotated on Canvas render mode, so isRotated always is false.
|
898
|
+
var preferredSize = this._preferredSize;
|
899
|
+
preferredSize = cc.size(preferredSize.width, preferredSize.height);
|
900
|
+
this.updateWithBatchNode(this._scale9Image, sender.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && sender.isRotated(), this._capInsets);
|
901
|
+
this.setPreferredSize(preferredSize);
|
902
|
+
this._positionsAreDirty = true;
|
903
|
+
this.dispatchEvent("load");
|
904
|
+
},this);
|
905
|
+
}
|
906
|
+
this.updateWithBatchNode(batchNode, spriteFrame.getRect(), cc._renderType == cc._RENDER_TYPE_WEBGL && spriteFrame.isRotated(), cc.rect(0, 0, 0, 0));
|
907
|
+
|
908
|
+
// Reset insets
|
909
|
+
this._insetLeft = 0;
|
910
|
+
this._insetTop = 0;
|
911
|
+
this._insetRight = 0;
|
912
|
+
this._insetBottom = 0;
|
913
|
+
},
|
914
|
+
|
915
|
+
//v3.3
|
916
|
+
/**
|
917
|
+
* Sets cc.Scale9Sprite's state
|
918
|
+
* @since v3.3
|
919
|
+
* @param {Number} state
|
920
|
+
*/
|
921
|
+
setState: function(state){
|
922
|
+
this._renderCmd.setState(state);
|
923
|
+
},
|
924
|
+
|
925
|
+
//setScale9Enabled implement late
|
926
|
+
|
927
|
+
/**
|
928
|
+
* Sets whether the widget should be flipped horizontally or not.
|
929
|
+
* @since v3.3
|
930
|
+
* @param flippedX true if the widget should be flipped horizontally, false otherwise.
|
931
|
+
*/
|
932
|
+
setFlippedX: function(flippedX){
|
933
|
+
var realScale = this.getScaleX();
|
934
|
+
this._flippedX = flippedX;
|
935
|
+
this.setScaleX(realScale);
|
936
|
+
},
|
937
|
+
|
938
|
+
/**
|
939
|
+
* <p>
|
940
|
+
* Returns the flag which indicates whether the widget is flipped horizontally or not. <br/>
|
941
|
+
* <br/>
|
942
|
+
* It only flips the texture of the widget, and not the texture of the widget's children. <br/>
|
943
|
+
* Also, flipping the texture doesn't alter the anchorPoint. <br/>
|
944
|
+
* If you want to flip the anchorPoint too, and/or to flip the children too use: <br/>
|
945
|
+
* widget->setScaleX(sprite->getScaleX() * -1); <br/>
|
946
|
+
* </p>
|
947
|
+
* @since v3.3
|
948
|
+
* @return {Boolean} true if the widget is flipped horizontally, false otherwise.
|
949
|
+
*/
|
950
|
+
isFlippedX: function(){
|
951
|
+
return this._flippedX;
|
952
|
+
},
|
953
|
+
|
954
|
+
/**
|
955
|
+
* Sets whether the widget should be flipped vertically or not.
|
956
|
+
* @since v3.3
|
957
|
+
* @param flippedY true if the widget should be flipped vertically, false otherwise.
|
958
|
+
*/
|
959
|
+
setFlippedY:function(flippedY){
|
960
|
+
var realScale = this.getScaleY();
|
961
|
+
this._flippedY = flippedY;
|
962
|
+
this.setScaleY(realScale);
|
963
|
+
},
|
964
|
+
|
965
|
+
/**
|
966
|
+
* <p>
|
967
|
+
* Return the flag which indicates whether the widget is flipped vertically or not. <br/>
|
968
|
+
* <br/>
|
969
|
+
* It only flips the texture of the widget, and not the texture of the widget's children. <br/>
|
970
|
+
* Also, flipping the texture doesn't alter the anchorPoint. <br/>
|
971
|
+
* If you want to flip the anchorPoint too, and/or to flip the children too use: <br/>
|
972
|
+
* widget->setScaleY(widget->getScaleY() * -1); <br/>
|
973
|
+
* </p>
|
974
|
+
* @since v3.3
|
975
|
+
* @return {Boolean} true if the widget is flipped vertically, false otherwise.
|
976
|
+
*/
|
977
|
+
isFlippedY:function(){
|
978
|
+
return this._flippedY;
|
979
|
+
},
|
980
|
+
|
981
|
+
setScaleX: function (scaleX) {
|
982
|
+
if (this._flippedX)
|
983
|
+
scaleX = scaleX * -1;
|
984
|
+
cc.Node.prototype.setScaleX.call(this, scaleX);
|
985
|
+
},
|
986
|
+
|
987
|
+
setScaleY: function (scaleY) {
|
988
|
+
if (this._flippedY)
|
989
|
+
scaleY = scaleY * -1;
|
990
|
+
cc.Node.prototype.setScaleY.call(this, scaleY);
|
991
|
+
},
|
992
|
+
|
993
|
+
setScale: function (scaleX, scaleY) {
|
994
|
+
if(scaleY === undefined)
|
995
|
+
scaleY = scaleX;
|
996
|
+
this.setScaleX(scaleX);
|
997
|
+
this.setScaleY(scaleY);
|
998
|
+
},
|
999
|
+
|
1000
|
+
getScaleX: function () {
|
1001
|
+
var originalScale = cc.Node.prototype.getScaleX.call(this);
|
1002
|
+
if (this._flippedX)
|
1003
|
+
originalScale = originalScale * -1.0;
|
1004
|
+
return originalScale;
|
1005
|
+
},
|
1006
|
+
|
1007
|
+
getScaleY: function () {
|
1008
|
+
var originalScale = cc.Node.prototype.getScaleY.call(this);
|
1009
|
+
if (this._flippedY)
|
1010
|
+
originalScale = originalScale * -1.0;
|
1011
|
+
return originalScale;
|
1012
|
+
},
|
1013
|
+
|
1014
|
+
getScale: function () {
|
1015
|
+
if(this.getScaleX() !== this.getScaleY())
|
1016
|
+
cc.log("Scale9Sprite#scale. ScaleX != ScaleY. Don't know which one to return");
|
1017
|
+
return this.getScaleX();
|
1018
|
+
},
|
1019
|
+
|
1020
|
+
_createRenderCmd: function(){
|
1021
|
+
if(cc._renderType === cc._RENDER_TYPE_CANVAS)
|
1022
|
+
return new cc.Scale9Sprite.CanvasRenderCmd(this);
|
1023
|
+
else
|
1024
|
+
return new cc.Scale9Sprite.WebGLRenderCmd(this);
|
1025
|
+
}
|
1026
|
+
});
|
1027
|
+
|
1028
|
+
var _p = cc.Scale9Sprite.prototype;
|
1029
|
+
cc.EventHelper.prototype.apply(_p);
|
1030
|
+
|
1031
|
+
// Extended properties
|
1032
|
+
/** @expose */
|
1033
|
+
_p.preferredSize;
|
1034
|
+
cc.defineGetterSetter(_p, "preferredSize", _p.getPreferredSize, _p.setPreferredSize);
|
1035
|
+
/** @expose */
|
1036
|
+
_p.capInsets;
|
1037
|
+
cc.defineGetterSetter(_p, "capInsets", _p.getCapInsets, _p.setCapInsets);
|
1038
|
+
/** @expose */
|
1039
|
+
_p.insetLeft;
|
1040
|
+
cc.defineGetterSetter(_p, "insetLeft", _p.getInsetLeft, _p.setInsetLeft);
|
1041
|
+
/** @expose */
|
1042
|
+
_p.insetTop;
|
1043
|
+
cc.defineGetterSetter(_p, "insetTop", _p.getInsetTop, _p.setInsetTop);
|
1044
|
+
/** @expose */
|
1045
|
+
_p.insetRight;
|
1046
|
+
cc.defineGetterSetter(_p, "insetRight", _p.getInsetRight, _p.setInsetRight);
|
1047
|
+
/** @expose */
|
1048
|
+
_p.insetBottom;
|
1049
|
+
cc.defineGetterSetter(_p, "insetBottom", _p.getInsetBottom, _p.setInsetBottom);
|
1050
|
+
|
1051
|
+
_p = null;
|
1052
|
+
|
1053
|
+
/**
|
1054
|
+
* Creates a 9-slice sprite with a texture file, a delimitation zone and
|
1055
|
+
* with the specified cap insets.
|
1056
|
+
* @deprecated
|
1057
|
+
* @param {String|cc.SpriteFrame} file file name of texture or a cc.Sprite object
|
1058
|
+
* @param {cc.Rect} rect the rect of the texture
|
1059
|
+
* @param {cc.Rect} capInsets the cap insets of cc.Scale9Sprite
|
1060
|
+
* @returns {cc.Scale9Sprite}
|
1061
|
+
*/
|
1062
|
+
cc.Scale9Sprite.create = function (file, rect, capInsets) {
|
1063
|
+
return new cc.Scale9Sprite(file, rect, capInsets);
|
1064
|
+
};
|
1065
|
+
|
1066
|
+
/**
|
1067
|
+
* @deprecated
|
1068
|
+
* @param spriteFrame
|
1069
|
+
* @param capInsets
|
1070
|
+
* @returns {cc.Scale9Sprite}
|
1071
|
+
*/
|
1072
|
+
cc.Scale9Sprite.createWithSpriteFrame = function (spriteFrame, capInsets) {
|
1073
|
+
return new cc.Scale9Sprite(spriteFrame, capInsets);
|
1074
|
+
};
|
1075
|
+
|
1076
|
+
/**
|
1077
|
+
* @deprecated
|
1078
|
+
* @param spriteFrameName
|
1079
|
+
* @param capInsets
|
1080
|
+
* @returns {cc.Scale9Sprite}
|
1081
|
+
*/
|
1082
|
+
cc.Scale9Sprite.createWithSpriteFrameName = function (spriteFrameName, capInsets) {
|
1083
|
+
return new cc.Scale9Sprite(spriteFrameName, capInsets);
|
1084
|
+
};
|
1085
|
+
|
1086
|
+
/**
|
1087
|
+
* @ignore
|
1088
|
+
*/
|
1089
|
+
cc.Scale9Sprite.POSITIONS_CENTRE = 0;
|
1090
|
+
cc.Scale9Sprite.POSITIONS_TOP = 1;
|
1091
|
+
cc.Scale9Sprite.POSITIONS_LEFT = 2;
|
1092
|
+
cc.Scale9Sprite.POSITIONS_RIGHT = 3;
|
1093
|
+
cc.Scale9Sprite.POSITIONS_BOTTOM = 4;
|
1094
|
+
cc.Scale9Sprite.POSITIONS_TOPRIGHT = 5;
|
1095
|
+
cc.Scale9Sprite.POSITIONS_TOPLEFT = 6;
|
1096
|
+
cc.Scale9Sprite.POSITIONS_BOTTOMRIGHT = 7;
|
1097
|
+
|
1098
|
+
cc.Scale9Sprite.state = {NORMAL: 0, GRAY: 1};
|
1099
|
+
|