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,1884 @@
|
|
1
|
+
/****************************************************************************
|
2
|
+
Copyright (c) 2011-2012 cocos2d-x.org
|
3
|
+
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
4
|
+
|
5
|
+
http://www.cocos2d-x.org
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
9
|
+
in the Software without restriction, including without limitation the rights
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
12
|
+
furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
15
|
+
all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
THE SOFTWARE.
|
24
|
+
****************************************************************************/
|
25
|
+
|
26
|
+
/**
|
27
|
+
* The ScrollView control of Cocos UI
|
28
|
+
* @class
|
29
|
+
* @extends ccui.Layout
|
30
|
+
*
|
31
|
+
* @property {Number} innerWidth - Inner container width of the scroll view
|
32
|
+
* @property {Number} innerHeight - Inner container height of the scroll view
|
33
|
+
* @property {ccui.ScrollView.DIR_NONE | ccui.ScrollView.DIR_VERTICAL | ccui.ScrollView.DIR_HORIZONTAL | ccui.ScrollView.DIR_BOTH} direction - Scroll direction of the scroll view
|
34
|
+
* @property {Boolean} bounceEnabled - Indicate whether bounce is enabled
|
35
|
+
* @property {Boolean} inertiaScrollEnabled - Indicate whether inertiaScroll is enabled
|
36
|
+
*/
|
37
|
+
ccui.ScrollView = ccui.Layout.extend(/** @lends ccui.ScrollView# */{
|
38
|
+
_innerContainer: null,
|
39
|
+
direction: null,
|
40
|
+
_autoScrollDir: null,
|
41
|
+
|
42
|
+
_topBoundary: 0,
|
43
|
+
_bottomBoundary: 0,
|
44
|
+
_leftBoundary: 0,
|
45
|
+
_rightBoundary: 0,
|
46
|
+
|
47
|
+
_bounceTopBoundary: 0,
|
48
|
+
_bounceBottomBoundary: 0,
|
49
|
+
_bounceLeftBoundary: 0,
|
50
|
+
_bounceRightBoundary: 0,
|
51
|
+
|
52
|
+
_autoScroll: false,
|
53
|
+
_autoScrollAddUpTime: 0,
|
54
|
+
|
55
|
+
_autoScrollOriginalSpeed: 0,
|
56
|
+
_autoScrollAcceleration: 0,
|
57
|
+
_isAutoScrollSpeedAttenuated: false,
|
58
|
+
_needCheckAutoScrollDestination: false,
|
59
|
+
_autoScrollDestination: null,
|
60
|
+
|
61
|
+
_bePressed: false,
|
62
|
+
_slidTime: 0,
|
63
|
+
_moveChildPoint: null,
|
64
|
+
_childFocusCancelOffset: 0,
|
65
|
+
|
66
|
+
_leftBounceNeeded: false,
|
67
|
+
_topBounceNeeded: false,
|
68
|
+
_rightBounceNeeded: false,
|
69
|
+
_bottomBounceNeeded: false,
|
70
|
+
|
71
|
+
bounceEnabled: false,
|
72
|
+
_bouncing: false,
|
73
|
+
_bounceDir: null,
|
74
|
+
_bounceOriginalSpeed: 0,
|
75
|
+
inertiaScrollEnabled: false,
|
76
|
+
|
77
|
+
_scrollViewEventListener: null,
|
78
|
+
_scrollViewEventSelector: null,
|
79
|
+
_className: "ScrollView",
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Allocates and initializes a UIScrollView.
|
83
|
+
* Constructor of ccui.ScrollView. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
|
84
|
+
* @example
|
85
|
+
* // example
|
86
|
+
* var uiScrollView = new ccui.ScrollView();
|
87
|
+
*/
|
88
|
+
ctor: function () {
|
89
|
+
ccui.Layout.prototype.ctor.call(this);
|
90
|
+
this.direction = ccui.ScrollView.DIR_NONE;
|
91
|
+
this._autoScrollDir = cc.p(0, 0);
|
92
|
+
|
93
|
+
this._autoScrollAcceleration = -1000;
|
94
|
+
this._autoScrollDestination = cc.p(0, 0);
|
95
|
+
this._slidTime = 0;
|
96
|
+
this._moveChildPoint = cc.p(0, 0);
|
97
|
+
this._childFocusCancelOffset = 5;
|
98
|
+
this._bounceDir = cc.p(0, 0);
|
99
|
+
this._bounceOriginalSpeed = 0;
|
100
|
+
this.inertiaScrollEnabled = true;
|
101
|
+
this.setTouchEnabled(true);
|
102
|
+
},
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Initializes a ccui.ScrollView. Please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
|
106
|
+
* @returns {boolean}
|
107
|
+
*/
|
108
|
+
init: function () {
|
109
|
+
if (ccui.Layout.prototype.init.call(this)) {
|
110
|
+
this.setClippingEnabled(true);
|
111
|
+
this._innerContainer.setTouchEnabled(false);
|
112
|
+
return true;
|
113
|
+
}
|
114
|
+
return false;
|
115
|
+
},
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Calls the parent class' onEnter and schedules update function.
|
119
|
+
* @override
|
120
|
+
*/
|
121
|
+
onEnter: function () {
|
122
|
+
ccui.Layout.prototype.onEnter.call(this);
|
123
|
+
this.scheduleUpdate(true);
|
124
|
+
},
|
125
|
+
|
126
|
+
/**
|
127
|
+
* When a widget is in a layout, you could call this method to get the next focused widget within a specified direction. <br/>
|
128
|
+
* If the widget is not in a layout, it will return itself
|
129
|
+
*
|
130
|
+
* @param {Number} direction the direction to look for the next focused widget in a layout
|
131
|
+
* @param {ccui.Widget} current the current focused widget
|
132
|
+
* @returns {ccui.Widget}
|
133
|
+
*/
|
134
|
+
findNextFocusedWidget: function(direction, current){
|
135
|
+
if (this.getLayoutType() == ccui.Layout.LINEAR_VERTICAL
|
136
|
+
|| this.getLayoutType() == ccui.Layout.LINEAR_HORIZONTAL) {
|
137
|
+
return this._innerContainer.findNextFocusedWidget(direction, current);
|
138
|
+
} else
|
139
|
+
return ccui.Widget.prototype.findNextFocusedWidget.call(this, direction, current);
|
140
|
+
},
|
141
|
+
|
142
|
+
_initRenderer: function () {
|
143
|
+
ccui.Layout.prototype._initRenderer.call(this);
|
144
|
+
|
145
|
+
this._innerContainer = new ccui.Layout();
|
146
|
+
this._innerContainer.setColor(cc.color(255,255,255));
|
147
|
+
this._innerContainer.setOpacity(255);
|
148
|
+
this._innerContainer.setCascadeColorEnabled(true);
|
149
|
+
this._innerContainer.setCascadeOpacityEnabled(true);
|
150
|
+
|
151
|
+
this.addProtectedChild(this._innerContainer, 1, 1);
|
152
|
+
},
|
153
|
+
|
154
|
+
_onSizeChanged: function () {
|
155
|
+
ccui.Layout.prototype._onSizeChanged.call(this);
|
156
|
+
var locSize = this._contentSize;
|
157
|
+
this._topBoundary = locSize.height;
|
158
|
+
this._rightBoundary = locSize.width;
|
159
|
+
var bounceBoundaryParameterX = locSize.width / 3;
|
160
|
+
var bounceBoundaryParameterY = locSize.height / 3;
|
161
|
+
this._bounceTopBoundary = locSize.height - bounceBoundaryParameterY;
|
162
|
+
this._bounceBottomBoundary = bounceBoundaryParameterY;
|
163
|
+
this._bounceLeftBoundary = bounceBoundaryParameterX;
|
164
|
+
this._bounceRightBoundary = locSize.width - bounceBoundaryParameterX;
|
165
|
+
var innerSize = this._innerContainer.getContentSize();
|
166
|
+
this._innerContainer.setContentSize(cc.size(Math.max(innerSize.width, locSize.width), Math.max(innerSize.height, locSize.height)));
|
167
|
+
this._innerContainer.setPosition(0, locSize.height - this._innerContainer.getContentSize().height);
|
168
|
+
},
|
169
|
+
|
170
|
+
/**
|
171
|
+
* Changes inner container size of ScrollView. <br/>
|
172
|
+
* Inner container size must be larger than or equal the size of ScrollView.
|
173
|
+
* @param {cc.Size} size inner container size.
|
174
|
+
*/
|
175
|
+
setInnerContainerSize: function (size) {
|
176
|
+
var innerContainer = this._innerContainer;
|
177
|
+
var locSize = this._contentSize;
|
178
|
+
var innerSizeWidth = locSize.width, innerSizeHeight = locSize.height;
|
179
|
+
var originalInnerSize = innerContainer.getContentSize();
|
180
|
+
if (size.width < locSize.width)
|
181
|
+
cc.log("Inner width <= ScrollView width, it will be force sized!");
|
182
|
+
else
|
183
|
+
innerSizeWidth = size.width;
|
184
|
+
|
185
|
+
if (size.height < locSize.height)
|
186
|
+
cc.log("Inner height <= ScrollView height, it will be force sized!");
|
187
|
+
else
|
188
|
+
innerSizeHeight = size.height;
|
189
|
+
|
190
|
+
innerContainer.setContentSize(cc.size(innerSizeWidth, innerSizeHeight));
|
191
|
+
var newInnerSize, offset;
|
192
|
+
switch (this.direction) {
|
193
|
+
case ccui.ScrollView.DIR_VERTICAL:
|
194
|
+
newInnerSize = innerContainer.getContentSize();
|
195
|
+
offset = originalInnerSize.height - newInnerSize.height;
|
196
|
+
this._scrollChildren(0, offset);
|
197
|
+
break;
|
198
|
+
case ccui.ScrollView.DIR_HORIZONTAL:
|
199
|
+
if (innerContainer.getRightBoundary() <= locSize.width) {
|
200
|
+
newInnerSize = innerContainer.getContentSize();
|
201
|
+
offset = originalInnerSize.width - newInnerSize.width;
|
202
|
+
this._scrollChildren(offset, 0);
|
203
|
+
}
|
204
|
+
break;
|
205
|
+
case ccui.ScrollView.DIR_BOTH:
|
206
|
+
newInnerSize = innerContainer.getContentSize();
|
207
|
+
var offsetY = originalInnerSize.height - newInnerSize.height;
|
208
|
+
var offsetX = (innerContainer.getRightBoundary() <= locSize.width) ? originalInnerSize.width - newInnerSize.width : 0;
|
209
|
+
this._scrollChildren(offsetX, offsetY);
|
210
|
+
break;
|
211
|
+
default:
|
212
|
+
break;
|
213
|
+
}
|
214
|
+
|
215
|
+
var innerSize = innerContainer.getContentSize();
|
216
|
+
var innerPos = innerContainer.getPosition();
|
217
|
+
var innerAP = innerContainer.getAnchorPoint();
|
218
|
+
if (innerContainer.getLeftBoundary() > 0.0)
|
219
|
+
innerContainer.setPosition(innerAP.x * innerSize.width, innerPos.y);
|
220
|
+
if (innerContainer.getRightBoundary() < locSize.width)
|
221
|
+
innerContainer.setPosition(locSize.width - ((1.0 - innerAP.x) * innerSize.width), innerPos.y);
|
222
|
+
if (innerPos.y > 0.0)
|
223
|
+
innerContainer.setPosition(innerPos.x, innerAP.y * innerSize.height);
|
224
|
+
if (innerContainer.getTopBoundary() < locSize.height)
|
225
|
+
innerContainer.setPosition(innerPos.x, locSize.height - (1.0 - innerAP.y) * innerSize.height);
|
226
|
+
},
|
227
|
+
|
228
|
+
_setInnerWidth: function (width) {
|
229
|
+
var locW = this._contentSize.width,
|
230
|
+
innerWidth = locW,
|
231
|
+
container = this._innerContainer,
|
232
|
+
oldInnerWidth = container.width;
|
233
|
+
if (width < locW)
|
234
|
+
cc.log("Inner width <= scrollview width, it will be force sized!");
|
235
|
+
else
|
236
|
+
innerWidth = width;
|
237
|
+
container.width = innerWidth;
|
238
|
+
|
239
|
+
switch (this.direction) {
|
240
|
+
case ccui.ScrollView.DIR_HORIZONTAL:
|
241
|
+
case ccui.ScrollView.DIR_BOTH:
|
242
|
+
if (container.getRightBoundary() <= locW) {
|
243
|
+
var newInnerWidth = container.width;
|
244
|
+
var offset = oldInnerWidth - newInnerWidth;
|
245
|
+
this._scrollChildren(offset, 0);
|
246
|
+
}
|
247
|
+
break;
|
248
|
+
}
|
249
|
+
var innerAX = container.anchorX;
|
250
|
+
if (container.getLeftBoundary() > 0.0)
|
251
|
+
container.x = innerAX * innerWidth;
|
252
|
+
if (container.getRightBoundary() < locW)
|
253
|
+
container.x = locW - ((1.0 - innerAX) * innerWidth);
|
254
|
+
},
|
255
|
+
|
256
|
+
_setInnerHeight: function (height) {
|
257
|
+
var locH = this._contentSize.height,
|
258
|
+
innerHeight = locH,
|
259
|
+
container = this._innerContainer,
|
260
|
+
oldInnerHeight = container.height;
|
261
|
+
if (height < locH)
|
262
|
+
cc.log("Inner height <= scrollview height, it will be force sized!");
|
263
|
+
else
|
264
|
+
innerHeight = height;
|
265
|
+
container.height = innerHeight;
|
266
|
+
|
267
|
+
switch (this.direction) {
|
268
|
+
case ccui.ScrollView.DIR_VERTICAL:
|
269
|
+
case ccui.ScrollView.DIR_BOTH:
|
270
|
+
var newInnerHeight = innerHeight;
|
271
|
+
var offset = oldInnerHeight - newInnerHeight;
|
272
|
+
this._scrollChildren(0, offset);
|
273
|
+
break;
|
274
|
+
}
|
275
|
+
var innerAY = container.anchorY;
|
276
|
+
if (container.getLeftBoundary() > 0.0)
|
277
|
+
container.y = innerAY * innerHeight;
|
278
|
+
if (container.getRightBoundary() < locH)
|
279
|
+
container.y = locH - ((1.0 - innerAY) * innerHeight);
|
280
|
+
},
|
281
|
+
|
282
|
+
/**
|
283
|
+
* Returns inner container size of ScrollView. <br/>
|
284
|
+
* Inner container size must be larger than or equal ScrollView's size.
|
285
|
+
*
|
286
|
+
* @return {cc.Size} inner container size.
|
287
|
+
*/
|
288
|
+
getInnerContainerSize: function () {
|
289
|
+
return this._innerContainer.getContentSize();
|
290
|
+
},
|
291
|
+
_getInnerWidth: function () {
|
292
|
+
return this._innerContainer.width;
|
293
|
+
},
|
294
|
+
_getInnerHeight: function () {
|
295
|
+
return this._innerContainer.height;
|
296
|
+
},
|
297
|
+
|
298
|
+
/**
|
299
|
+
* Add child to ccui.ScrollView.
|
300
|
+
* @param {cc.Node} widget
|
301
|
+
* @param {Number} [zOrder]
|
302
|
+
* @param {Number|string} [tag] tag or name
|
303
|
+
* @returns {boolean}
|
304
|
+
*/
|
305
|
+
addChild: function (widget, zOrder, tag) {
|
306
|
+
if(!widget)
|
307
|
+
return false;
|
308
|
+
zOrder = zOrder || widget.getLocalZOrder();
|
309
|
+
tag = tag || widget.getTag();
|
310
|
+
return this._innerContainer.addChild(widget, zOrder, tag);
|
311
|
+
},
|
312
|
+
|
313
|
+
/**
|
314
|
+
* Removes all children.
|
315
|
+
*/
|
316
|
+
removeAllChildren: function () {
|
317
|
+
this.removeAllChildrenWithCleanup(true);
|
318
|
+
},
|
319
|
+
|
320
|
+
/**
|
321
|
+
* Removes all children.
|
322
|
+
* @param {Boolean} cleanup
|
323
|
+
*/
|
324
|
+
removeAllChildrenWithCleanup: function(cleanup){
|
325
|
+
this._innerContainer.removeAllChildrenWithCleanup(cleanup);
|
326
|
+
},
|
327
|
+
|
328
|
+
/**
|
329
|
+
* Removes widget child
|
330
|
+
* @override
|
331
|
+
* @param {ccui.Widget} child
|
332
|
+
* @param {Boolean} cleanup
|
333
|
+
* @returns {boolean}
|
334
|
+
*/
|
335
|
+
removeChild: function (child, cleanup) {
|
336
|
+
return this._innerContainer.removeChild(child, cleanup);
|
337
|
+
},
|
338
|
+
|
339
|
+
/**
|
340
|
+
* Returns inner container's children
|
341
|
+
* @returns {Array}
|
342
|
+
*/
|
343
|
+
getChildren: function () {
|
344
|
+
return this._innerContainer.getChildren();
|
345
|
+
},
|
346
|
+
|
347
|
+
/**
|
348
|
+
* Gets the count of inner container's children
|
349
|
+
* @returns {Number}
|
350
|
+
*/
|
351
|
+
getChildrenCount: function () {
|
352
|
+
return this._innerContainer.getChildrenCount();
|
353
|
+
},
|
354
|
+
|
355
|
+
/**
|
356
|
+
* Gets a child from the container given its tag
|
357
|
+
* @param {Number} tag
|
358
|
+
* @returns {ccui.Widget}
|
359
|
+
*/
|
360
|
+
getChildByTag: function (tag) {
|
361
|
+
return this._innerContainer.getChildByTag(tag);
|
362
|
+
},
|
363
|
+
|
364
|
+
/**
|
365
|
+
* Gets a child from the container given its name
|
366
|
+
* @param {String} name
|
367
|
+
* @returns {ccui.Widget}
|
368
|
+
*/
|
369
|
+
getChildByName: function (name) {
|
370
|
+
return this._innerContainer.getChildByName(name);
|
371
|
+
},
|
372
|
+
|
373
|
+
_moveChildren: function (offsetX, offsetY) {
|
374
|
+
var locContainer = this._innerContainer;
|
375
|
+
//var pos = this._innerContainer.getPosition();
|
376
|
+
this._moveChildPoint.x = locContainer.x + offsetX;
|
377
|
+
this._moveChildPoint.y = locContainer.y + offsetY;
|
378
|
+
this._innerContainer.setPosition(this._moveChildPoint);
|
379
|
+
},
|
380
|
+
|
381
|
+
_autoScrollChildren: function (dt) {
|
382
|
+
var lastTime = this._autoScrollAddUpTime;
|
383
|
+
this._autoScrollAddUpTime += dt;
|
384
|
+
if (this._isAutoScrollSpeedAttenuated) {
|
385
|
+
var nowSpeed = this._autoScrollOriginalSpeed + this._autoScrollAcceleration * this._autoScrollAddUpTime;
|
386
|
+
if (nowSpeed <= 0) {
|
387
|
+
this._stopAutoScrollChildren();
|
388
|
+
this._checkNeedBounce();
|
389
|
+
} else {
|
390
|
+
var timeParam = lastTime * 2 + dt;
|
391
|
+
var offset = (this._autoScrollOriginalSpeed + this._autoScrollAcceleration * timeParam * 0.5) * dt;
|
392
|
+
var offsetX = offset * this._autoScrollDir.x;
|
393
|
+
var offsetY = offset * this._autoScrollDir.y;
|
394
|
+
if (!this._scrollChildren(offsetX, offsetY)) {
|
395
|
+
this._stopAutoScrollChildren();
|
396
|
+
this._checkNeedBounce();
|
397
|
+
}
|
398
|
+
}
|
399
|
+
} else {
|
400
|
+
if (this._needCheckAutoScrollDestination) {
|
401
|
+
var xOffset = this._autoScrollDir.x * dt * this._autoScrollOriginalSpeed;
|
402
|
+
var yOffset = this._autoScrollDir.y * dt * this._autoScrollOriginalSpeed;
|
403
|
+
var notDone = this._checkCustomScrollDestination(xOffset, yOffset);
|
404
|
+
var scrollCheck = this._scrollChildren(xOffset, yOffset);
|
405
|
+
if (!notDone || !scrollCheck) {
|
406
|
+
this._stopAutoScrollChildren();
|
407
|
+
this._checkNeedBounce();
|
408
|
+
}
|
409
|
+
} else {
|
410
|
+
if (!this._scrollChildren(this._autoScrollDir.x * dt * this._autoScrollOriginalSpeed,
|
411
|
+
this._autoScrollDir.y * dt * this._autoScrollOriginalSpeed)) {
|
412
|
+
this._stopAutoScrollChildren();
|
413
|
+
this._checkNeedBounce();
|
414
|
+
}
|
415
|
+
}
|
416
|
+
}
|
417
|
+
},
|
418
|
+
|
419
|
+
_bounceChildren: function (dt) {
|
420
|
+
var locSpeed = this._bounceOriginalSpeed;
|
421
|
+
var locBounceDir = this._bounceDir;
|
422
|
+
if (locSpeed <= 0.0)
|
423
|
+
this._stopBounceChildren();
|
424
|
+
if (!this._bounceScrollChildren(locBounceDir.x * dt * locSpeed, locBounceDir.y * dt * locSpeed))
|
425
|
+
this._stopBounceChildren();
|
426
|
+
},
|
427
|
+
|
428
|
+
_checkNeedBounce: function () {
|
429
|
+
if (!this.bounceEnabled)
|
430
|
+
return false;
|
431
|
+
this._checkBounceBoundary();
|
432
|
+
var locTopBounceNeeded = this._topBounceNeeded, locBottomBounceNeeded = this._bottomBounceNeeded,
|
433
|
+
locLeftBounceNeeded = this._leftBounceNeeded, locRightBounceNeeded = this._rightBounceNeeded;
|
434
|
+
|
435
|
+
if (locTopBounceNeeded || locBottomBounceNeeded || locLeftBounceNeeded || locRightBounceNeeded) {
|
436
|
+
var scrollVector, orSpeed;
|
437
|
+
var locContentSize = this._contentSize, locInnerContainer = this._innerContainer;
|
438
|
+
if (locTopBounceNeeded && locLeftBounceNeeded) {
|
439
|
+
scrollVector = cc.pSub(cc.p(0.0, locContentSize.height), cc.p(locInnerContainer.getLeftBoundary(), locInnerContainer.getTopBoundary()));
|
440
|
+
orSpeed = cc.pLength(scrollVector) / 0.2;
|
441
|
+
this._bounceDir = cc.pNormalize(scrollVector);
|
442
|
+
this._startBounceChildren(orSpeed);
|
443
|
+
} else if (locTopBounceNeeded && locRightBounceNeeded) {
|
444
|
+
scrollVector = cc.pSub(cc.p(locContentSize.width, locContentSize.height), cc.p(locInnerContainer.getRightBoundary(), locInnerContainer.getTopBoundary()));
|
445
|
+
orSpeed = cc.pLength(scrollVector) / 0.2;
|
446
|
+
this._bounceDir = cc.pNormalize(scrollVector);
|
447
|
+
this._startBounceChildren(orSpeed);
|
448
|
+
} else if (locBottomBounceNeeded && locLeftBounceNeeded) {
|
449
|
+
scrollVector = cc.pSub(cc.p(0, 0), cc.p(locInnerContainer.getLeftBoundary(), locInnerContainer.getBottomBoundary()));
|
450
|
+
orSpeed = cc.pLength(scrollVector) / 0.2;
|
451
|
+
this._bounceDir = cc.pNormalize(scrollVector);
|
452
|
+
this._startBounceChildren(orSpeed);
|
453
|
+
} else if (locBottomBounceNeeded && locRightBounceNeeded) {
|
454
|
+
scrollVector = cc.pSub(cc.p(locContentSize.width, 0.0), cc.p(locInnerContainer.getRightBoundary(), locInnerContainer.getBottomBoundary()));
|
455
|
+
orSpeed = cc.pLength(scrollVector) / 0.2;
|
456
|
+
this._bounceDir = cc.pNormalize(scrollVector);
|
457
|
+
this._startBounceChildren(orSpeed);
|
458
|
+
} else if (locTopBounceNeeded) {
|
459
|
+
scrollVector = cc.pSub(cc.p(0, locContentSize.height), cc.p(0.0, locInnerContainer.getTopBoundary()));
|
460
|
+
orSpeed = cc.pLength(scrollVector) / 0.2;
|
461
|
+
this._bounceDir = cc.pNormalize(scrollVector);
|
462
|
+
this._startBounceChildren(orSpeed);
|
463
|
+
} else if (locBottomBounceNeeded) {
|
464
|
+
scrollVector = cc.pSub(cc.p(0, 0), cc.p(0.0, locInnerContainer.getBottomBoundary()));
|
465
|
+
orSpeed = cc.pLength(scrollVector) / 0.2;
|
466
|
+
this._bounceDir = cc.pNormalize(scrollVector);
|
467
|
+
this._startBounceChildren(orSpeed);
|
468
|
+
} else if (locLeftBounceNeeded) {
|
469
|
+
scrollVector = cc.pSub(cc.p(0, 0), cc.p(locInnerContainer.getLeftBoundary(), 0.0));
|
470
|
+
orSpeed = cc.pLength(scrollVector) / 0.2;
|
471
|
+
this._bounceDir = cc.pNormalize(scrollVector);
|
472
|
+
this._startBounceChildren(orSpeed);
|
473
|
+
} else if (locRightBounceNeeded) {
|
474
|
+
scrollVector = cc.pSub(cc.p(locContentSize.width, 0), cc.p(locInnerContainer.getRightBoundary(), 0.0));
|
475
|
+
orSpeed = cc.pLength(scrollVector) / 0.2;
|
476
|
+
this._bounceDir = cc.pNormalize(scrollVector);
|
477
|
+
this._startBounceChildren(orSpeed);
|
478
|
+
}
|
479
|
+
return true;
|
480
|
+
}
|
481
|
+
return false;
|
482
|
+
},
|
483
|
+
|
484
|
+
_checkBounceBoundary: function () {
|
485
|
+
var locContainer = this._innerContainer;
|
486
|
+
var icBottomPos = locContainer.getBottomBoundary();
|
487
|
+
if (icBottomPos > this._bottomBoundary) {
|
488
|
+
this._scrollToBottomEvent();
|
489
|
+
this._bottomBounceNeeded = true;
|
490
|
+
} else
|
491
|
+
this._bottomBounceNeeded = false;
|
492
|
+
|
493
|
+
var icTopPos = locContainer.getTopBoundary();
|
494
|
+
if (icTopPos < this._topBoundary) {
|
495
|
+
this._scrollToTopEvent();
|
496
|
+
this._topBounceNeeded = true;
|
497
|
+
} else
|
498
|
+
this._topBounceNeeded = false;
|
499
|
+
|
500
|
+
var icRightPos = locContainer.getRightBoundary();
|
501
|
+
if (icRightPos < this._rightBoundary) {
|
502
|
+
this._scrollToRightEvent();
|
503
|
+
this._rightBounceNeeded = true;
|
504
|
+
} else
|
505
|
+
this._rightBounceNeeded = false;
|
506
|
+
|
507
|
+
var icLeftPos = locContainer.getLeftBoundary();
|
508
|
+
if (icLeftPos > this._leftBoundary) {
|
509
|
+
this._scrollToLeftEvent();
|
510
|
+
this._leftBounceNeeded = true;
|
511
|
+
} else
|
512
|
+
this._leftBounceNeeded = false;
|
513
|
+
},
|
514
|
+
|
515
|
+
_startBounceChildren: function (v) {
|
516
|
+
this._bounceOriginalSpeed = v;
|
517
|
+
this._bouncing = true;
|
518
|
+
},
|
519
|
+
|
520
|
+
_stopBounceChildren: function () {
|
521
|
+
this._bouncing = false;
|
522
|
+
this._bounceOriginalSpeed = 0.0;
|
523
|
+
this._leftBounceNeeded = false;
|
524
|
+
this._rightBounceNeeded = false;
|
525
|
+
this._topBounceNeeded = false;
|
526
|
+
this._bottomBounceNeeded = false;
|
527
|
+
},
|
528
|
+
|
529
|
+
_startAutoScrollChildrenWithOriginalSpeed: function (dir, v, attenuated, acceleration) {
|
530
|
+
this._stopAutoScrollChildren();
|
531
|
+
this._autoScrollDir.x = dir.x;
|
532
|
+
this._autoScrollDir.y = dir.y;
|
533
|
+
this._isAutoScrollSpeedAttenuated = attenuated;
|
534
|
+
this._autoScrollOriginalSpeed = v;
|
535
|
+
this._autoScroll = true;
|
536
|
+
this._autoScrollAcceleration = acceleration;
|
537
|
+
},
|
538
|
+
|
539
|
+
_startAutoScrollChildrenWithDestination: function (des, time, attenuated) {
|
540
|
+
this._needCheckAutoScrollDestination = false;
|
541
|
+
this._autoScrollDestination = des;
|
542
|
+
var dis = cc.pSub(des, this._innerContainer.getPosition());
|
543
|
+
var dir = cc.pNormalize(dis);
|
544
|
+
var orSpeed = 0.0;
|
545
|
+
var acceleration = -1000.0;
|
546
|
+
var disLength = cc.pLength(dis);
|
547
|
+
if (attenuated) {
|
548
|
+
acceleration = -(2 * disLength) / (time * time);
|
549
|
+
orSpeed = 2 * disLength / time;
|
550
|
+
} else {
|
551
|
+
this._needCheckAutoScrollDestination = true;
|
552
|
+
orSpeed = disLength / time;
|
553
|
+
}
|
554
|
+
this._startAutoScrollChildrenWithOriginalSpeed(dir, orSpeed, attenuated, acceleration);
|
555
|
+
},
|
556
|
+
|
557
|
+
_jumpToDestination: function (dstX, dstY) {
|
558
|
+
if (dstX.x !== undefined) {
|
559
|
+
dstY = dstX.y;
|
560
|
+
dstX = dstX.x;
|
561
|
+
}
|
562
|
+
var finalOffsetX = dstX;
|
563
|
+
var finalOffsetY = dstY;
|
564
|
+
switch (this.direction) {
|
565
|
+
case ccui.ScrollView.DIR_VERTICAL:
|
566
|
+
if (dstY <= 0)
|
567
|
+
finalOffsetY = Math.max(dstY, this._contentSize.height - this._innerContainer.getContentSize().height);
|
568
|
+
break;
|
569
|
+
case ccui.ScrollView.DIR_HORIZONTAL:
|
570
|
+
if (dstX <= 0)
|
571
|
+
finalOffsetX = Math.max(dstX, this._contentSize.width - this._innerContainer.getContentSize().width);
|
572
|
+
break;
|
573
|
+
case ccui.ScrollView.DIR_BOTH:
|
574
|
+
if (dstY <= 0)
|
575
|
+
finalOffsetY = Math.max(dstY, this._contentSize.height - this._innerContainer.getContentSize().height);
|
576
|
+
if (dstX <= 0)
|
577
|
+
finalOffsetX = Math.max(dstX, this._contentSize.width - this._innerContainer.getContentSize().width);
|
578
|
+
break;
|
579
|
+
default:
|
580
|
+
break;
|
581
|
+
}
|
582
|
+
this._innerContainer.setPosition(finalOffsetX, finalOffsetY);
|
583
|
+
},
|
584
|
+
|
585
|
+
_stopAutoScrollChildren: function () {
|
586
|
+
this._autoScroll = false;
|
587
|
+
this._autoScrollOriginalSpeed = 0;
|
588
|
+
this._autoScrollAddUpTime = 0;
|
589
|
+
},
|
590
|
+
|
591
|
+
_bounceScrollChildren: function (touchOffsetX, touchOffsetY) {
|
592
|
+
var scrollEnabled = true;
|
593
|
+
var realOffsetX, realOffsetY, icRightPos, icTopPos, icBottomPos;
|
594
|
+
var locContainer = this._innerContainer;
|
595
|
+
if (touchOffsetX > 0.0 && touchOffsetY > 0.0){ //first quadrant //bounce to top-right
|
596
|
+
realOffsetX = touchOffsetX;
|
597
|
+
realOffsetY = touchOffsetY;
|
598
|
+
icRightPos = locContainer.getRightBoundary();
|
599
|
+
if (icRightPos + realOffsetX >= this._rightBoundary) {
|
600
|
+
realOffsetX = this._rightBoundary - icRightPos;
|
601
|
+
this._bounceRightEvent();
|
602
|
+
scrollEnabled = false;
|
603
|
+
}
|
604
|
+
icTopPos = locContainer.getTopBoundary();
|
605
|
+
if (icTopPos + touchOffsetY >= this._topBoundary) {
|
606
|
+
realOffsetY = this._topBoundary - icTopPos;
|
607
|
+
this._bounceTopEvent();
|
608
|
+
scrollEnabled = false;
|
609
|
+
}
|
610
|
+
this._moveChildren(realOffsetX, realOffsetY);
|
611
|
+
} else if (touchOffsetX < 0.0 && touchOffsetY > 0.0){ //second quadrant //bounce to top-left
|
612
|
+
realOffsetX = touchOffsetX;
|
613
|
+
realOffsetY = touchOffsetY;
|
614
|
+
icLefrPos = locContainer.getLeftBoundary();
|
615
|
+
if (icLefrPos + realOffsetX <= this._leftBoundary) {
|
616
|
+
realOffsetX = this._leftBoundary - icLefrPos;
|
617
|
+
this._bounceLeftEvent();
|
618
|
+
scrollEnabled = false;
|
619
|
+
}
|
620
|
+
icTopPos = locContainer.getTopBoundary();
|
621
|
+
if (icTopPos + touchOffsetY >= this._topBoundary) {
|
622
|
+
realOffsetY = this._topBoundary - icTopPos;
|
623
|
+
this._bounceTopEvent();
|
624
|
+
scrollEnabled = false;
|
625
|
+
}
|
626
|
+
this._moveChildren(realOffsetX, realOffsetY);
|
627
|
+
}else if (touchOffsetX < 0.0 && touchOffsetY < 0.0){ //third quadrant //bounce to bottom-left
|
628
|
+
realOffsetX = touchOffsetX;
|
629
|
+
realOffsetY = touchOffsetY;
|
630
|
+
var icLefrPos = locContainer.getLeftBoundary();
|
631
|
+
if (icLefrPos + realOffsetX <= this._leftBoundary) {
|
632
|
+
realOffsetX = this._leftBoundary - icLefrPos;
|
633
|
+
this._bounceLeftEvent();
|
634
|
+
scrollEnabled = false;
|
635
|
+
}
|
636
|
+
icBottomPos = locContainer.getBottomBoundary();
|
637
|
+
if (icBottomPos + touchOffsetY <= this._bottomBoundary) {
|
638
|
+
realOffsetY = this._bottomBoundary - icBottomPos;
|
639
|
+
this._bounceBottomEvent();
|
640
|
+
scrollEnabled = false;
|
641
|
+
}
|
642
|
+
this._moveChildren(realOffsetX, realOffsetY);
|
643
|
+
} else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ //forth quadrant //bounce to bottom-right
|
644
|
+
realOffsetX = touchOffsetX;
|
645
|
+
realOffsetY = touchOffsetY;
|
646
|
+
icRightPos = locContainer.getRightBoundary();
|
647
|
+
if (icRightPos + realOffsetX >= this._rightBoundary) {
|
648
|
+
realOffsetX = this._rightBoundary - icRightPos;
|
649
|
+
this._bounceRightEvent();
|
650
|
+
scrollEnabled = false;
|
651
|
+
}
|
652
|
+
icBottomPos = locContainer.getBottomBoundary();
|
653
|
+
if (icBottomPos + touchOffsetY <= this._bottomBoundary) {
|
654
|
+
realOffsetY = this._bottomBoundary - icBottomPos;
|
655
|
+
this._bounceBottomEvent();
|
656
|
+
scrollEnabled = false;
|
657
|
+
}
|
658
|
+
this._moveChildren(realOffsetX, realOffsetY);
|
659
|
+
} else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // bounce to top
|
660
|
+
realOffsetY = touchOffsetY;
|
661
|
+
icTopPos = locContainer.getTopBoundary();
|
662
|
+
if (icTopPos + touchOffsetY >= this._topBoundary) {
|
663
|
+
realOffsetY = this._topBoundary - icTopPos;
|
664
|
+
this._bounceTopEvent();
|
665
|
+
scrollEnabled = false;
|
666
|
+
}
|
667
|
+
this._moveChildren(0.0, realOffsetY);
|
668
|
+
} else if (touchOffsetX == 0.0 && touchOffsetY < 0.0) {//bounce to bottom
|
669
|
+
realOffsetY = touchOffsetY;
|
670
|
+
icBottomPos = locContainer.getBottomBoundary();
|
671
|
+
if (icBottomPos + touchOffsetY <= this._bottomBoundary) {
|
672
|
+
realOffsetY = this._bottomBoundary - icBottomPos;
|
673
|
+
this._bounceBottomEvent();
|
674
|
+
scrollEnabled = false;
|
675
|
+
}
|
676
|
+
this._moveChildren(0.0, realOffsetY);
|
677
|
+
} else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ //bounce to right
|
678
|
+
realOffsetX = touchOffsetX;
|
679
|
+
icRightPos = locContainer.getRightBoundary();
|
680
|
+
if (icRightPos + realOffsetX >= this._rightBoundary) {
|
681
|
+
realOffsetX = this._rightBoundary - icRightPos;
|
682
|
+
this._bounceRightEvent();
|
683
|
+
scrollEnabled = false;
|
684
|
+
}
|
685
|
+
this._moveChildren(realOffsetX, 0.0);
|
686
|
+
}else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ //bounce to left
|
687
|
+
realOffsetX = touchOffsetX;
|
688
|
+
var icLeftPos = locContainer.getLeftBoundary();
|
689
|
+
if (icLeftPos + realOffsetX <= this._leftBoundary) {
|
690
|
+
realOffsetX = this._leftBoundary - icLeftPos;
|
691
|
+
this._bounceLeftEvent();
|
692
|
+
scrollEnabled = false;
|
693
|
+
}
|
694
|
+
this._moveChildren(realOffsetX, 0.0);
|
695
|
+
}
|
696
|
+
return scrollEnabled;
|
697
|
+
},
|
698
|
+
|
699
|
+
_checkCustomScrollDestination: function (touchOffsetX, touchOffsetY) {
|
700
|
+
var scrollEnabled = true;
|
701
|
+
var icBottomPos, icLeftPos, icRightPos, icTopPos;
|
702
|
+
var locContainer = this._innerContainer, locDestination = this._autoScrollDestination;
|
703
|
+
switch (this.direction) {
|
704
|
+
case ccui.ScrollView.DIR_VERTICAL:
|
705
|
+
if (this._autoScrollDir.y > 0) {
|
706
|
+
icBottomPos = locContainer.getBottomBoundary();
|
707
|
+
if (icBottomPos + touchOffsetY >= locDestination.y) {
|
708
|
+
touchOffsetY = locDestination.y - icBottomPos;
|
709
|
+
scrollEnabled = false;
|
710
|
+
}
|
711
|
+
} else {
|
712
|
+
icBottomPos = locContainer.getBottomBoundary();
|
713
|
+
if (icBottomPos + touchOffsetY <= locDestination.y) {
|
714
|
+
touchOffsetY = locDestination.y - icBottomPos;
|
715
|
+
scrollEnabled = false;
|
716
|
+
}
|
717
|
+
}
|
718
|
+
break;
|
719
|
+
case ccui.ScrollView.DIR_HORIZONTAL:
|
720
|
+
if (this._autoScrollDir.x > 0) {
|
721
|
+
icLeftPos = locContainer.getLeftBoundary();
|
722
|
+
if (icLeftPos + touchOffsetX >= locDestination.x) {
|
723
|
+
touchOffsetX = locDestination.x - icLeftPos;
|
724
|
+
scrollEnabled = false;
|
725
|
+
}
|
726
|
+
} else {
|
727
|
+
icLeftPos = locContainer.getLeftBoundary();
|
728
|
+
if (icLeftPos + touchOffsetX <= locDestination.x) {
|
729
|
+
touchOffsetX = locDestination.x - icLeftPos;
|
730
|
+
scrollEnabled = false;
|
731
|
+
}
|
732
|
+
}
|
733
|
+
break;
|
734
|
+
case ccui.ScrollView.DIR_BOTH:
|
735
|
+
if (touchOffsetX > 0.0 && touchOffsetY > 0.0){ // up right
|
736
|
+
icLeftPos = locContainer.getLeftBoundary();
|
737
|
+
if (icLeftPos + touchOffsetX >= locDestination.x) {
|
738
|
+
touchOffsetX = locDestination.x - icLeftPos;
|
739
|
+
scrollEnabled = false;
|
740
|
+
}
|
741
|
+
icBottomPos = locContainer.getBottomBoundary();
|
742
|
+
if (icBottomPos + touchOffsetY >= locDestination.y) {
|
743
|
+
touchOffsetY = locDestination.y - icBottomPos;
|
744
|
+
scrollEnabled = false;
|
745
|
+
}
|
746
|
+
} else if (touchOffsetX < 0.0 && touchOffsetY > 0.0){ // up left
|
747
|
+
icRightPos = locContainer.getRightBoundary();
|
748
|
+
if (icRightPos + touchOffsetX <= locDestination.x) {
|
749
|
+
touchOffsetX = locDestination.x - icRightPos;
|
750
|
+
scrollEnabled = false;
|
751
|
+
}
|
752
|
+
icBottomPos = locContainer.getBottomBoundary();
|
753
|
+
if (icBottomPos + touchOffsetY >= locDestination.y) {
|
754
|
+
touchOffsetY = locDestination.y - icBottomPos;
|
755
|
+
scrollEnabled = false;
|
756
|
+
}
|
757
|
+
} else if (touchOffsetX < 0.0 && touchOffsetY < 0.0){ // down left
|
758
|
+
icRightPos = locContainer.getRightBoundary();
|
759
|
+
if (icRightPos + touchOffsetX <= locDestination.x) {
|
760
|
+
touchOffsetX = locDestination.x - icRightPos;
|
761
|
+
scrollEnabled = false;
|
762
|
+
}
|
763
|
+
icTopPos = locContainer.getTopBoundary();
|
764
|
+
if (icTopPos + touchOffsetY <= locDestination.y) {
|
765
|
+
touchOffsetY = locDestination.y - icTopPos;
|
766
|
+
scrollEnabled = false;
|
767
|
+
}
|
768
|
+
} else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ // down right
|
769
|
+
icLeftPos = locContainer.getLeftBoundary();
|
770
|
+
if (icLeftPos + touchOffsetX >= locDestination.x) {
|
771
|
+
touchOffsetX = locDestination.x - icLeftPos;
|
772
|
+
scrollEnabled = false;
|
773
|
+
}
|
774
|
+
icTopPos = locContainer.getTopBoundary();
|
775
|
+
if (icTopPos + touchOffsetY <= locDestination.y) {
|
776
|
+
touchOffsetY = locDestination.y - icTopPos;
|
777
|
+
scrollEnabled = false;
|
778
|
+
}
|
779
|
+
} else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // up
|
780
|
+
icBottomPos = locContainer.getBottomBoundary();
|
781
|
+
if (icBottomPos + touchOffsetY >= locDestination.y) {
|
782
|
+
touchOffsetY = locDestination.y - icBottomPos;
|
783
|
+
scrollEnabled = false;
|
784
|
+
}
|
785
|
+
} else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left
|
786
|
+
icRightPos = locContainer.getRightBoundary();
|
787
|
+
if (icRightPos + touchOffsetX <= locDestination.x) {
|
788
|
+
touchOffsetX = locDestination.x - icRightPos;
|
789
|
+
scrollEnabled = false;
|
790
|
+
}
|
791
|
+
} else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down
|
792
|
+
icTopPos = locContainer.getTopBoundary();
|
793
|
+
if (icTopPos + touchOffsetY <= locDestination.y) {
|
794
|
+
touchOffsetY = locDestination.y - icTopPos;
|
795
|
+
scrollEnabled = false;
|
796
|
+
}
|
797
|
+
} else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right
|
798
|
+
icLeftPos = locContainer.getLeftBoundary();
|
799
|
+
if (icLeftPos + touchOffsetX >= locDestination.x) {
|
800
|
+
touchOffsetX = locDestination.x - icLeftPos;
|
801
|
+
scrollEnabled = false;
|
802
|
+
}
|
803
|
+
}
|
804
|
+
break;
|
805
|
+
default:
|
806
|
+
break;
|
807
|
+
}
|
808
|
+
return scrollEnabled;
|
809
|
+
},
|
810
|
+
|
811
|
+
_scrollChildren: function (touchOffsetX, touchOffsetY) {
|
812
|
+
var scrollEnabled = true;
|
813
|
+
this._scrollingEvent();
|
814
|
+
switch (this.direction) {
|
815
|
+
case ccui.ScrollView.DIR_VERTICAL: // vertical
|
816
|
+
scrollEnabled = this._scrollChildrenVertical(touchOffsetX, touchOffsetY);
|
817
|
+
break;
|
818
|
+
case ccui.ScrollView.DIR_HORIZONTAL: // horizontal
|
819
|
+
scrollEnabled = this._scrollChildrenHorizontal(touchOffsetX, touchOffsetY);
|
820
|
+
break;
|
821
|
+
case ccui.ScrollView.DIR_BOTH:
|
822
|
+
scrollEnabled = this._scrollChildrenBoth(touchOffsetX, touchOffsetY);
|
823
|
+
break;
|
824
|
+
default:
|
825
|
+
break;
|
826
|
+
}
|
827
|
+
return scrollEnabled;
|
828
|
+
},
|
829
|
+
|
830
|
+
_scrollChildrenVertical: function(touchOffsetX, touchOffsetY){
|
831
|
+
var realOffset = touchOffsetY;
|
832
|
+
var scrollEnabled = true;
|
833
|
+
var icBottomPos, icTopPos, locContainer = this._innerContainer;
|
834
|
+
if (this.bounceEnabled) {
|
835
|
+
icBottomPos = locContainer.getBottomBoundary();
|
836
|
+
if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) {
|
837
|
+
realOffset = this._bounceBottomBoundary - icBottomPos;
|
838
|
+
this._scrollToBottomEvent();
|
839
|
+
scrollEnabled = false;
|
840
|
+
}
|
841
|
+
icTopPos = locContainer.getTopBoundary();
|
842
|
+
if (icTopPos + touchOffsetY <= this._bounceTopBoundary) {
|
843
|
+
realOffset = this._bounceTopBoundary - icTopPos;
|
844
|
+
this._scrollToTopEvent();
|
845
|
+
scrollEnabled = false;
|
846
|
+
|
847
|
+
}
|
848
|
+
} else {
|
849
|
+
icBottomPos = locContainer.getBottomBoundary();
|
850
|
+
if (icBottomPos + touchOffsetY >= this._bottomBoundary){
|
851
|
+
realOffset = this._bottomBoundary - icBottomPos;
|
852
|
+
this._scrollToBottomEvent();
|
853
|
+
scrollEnabled = false;
|
854
|
+
}
|
855
|
+
icTopPos = locContainer.getTopBoundary();
|
856
|
+
if (icTopPos + touchOffsetY <= this._topBoundary) {
|
857
|
+
realOffset = this._topBoundary - icTopPos;
|
858
|
+
this._scrollToTopEvent();
|
859
|
+
scrollEnabled = false;
|
860
|
+
}
|
861
|
+
}
|
862
|
+
this._moveChildren(0.0, realOffset);
|
863
|
+
return scrollEnabled;
|
864
|
+
},
|
865
|
+
|
866
|
+
_scrollChildrenHorizontal: function(touchOffsetX, touchOffestY){
|
867
|
+
var scrollEnabled = true;
|
868
|
+
var realOffset = touchOffsetX;
|
869
|
+
var icRightPos, icLeftPos, locContainer = this._innerContainer;
|
870
|
+
if (this.bounceEnabled){
|
871
|
+
icRightPos = locContainer.getRightBoundary();
|
872
|
+
if (icRightPos + touchOffsetX <= this._bounceRightBoundary) {
|
873
|
+
realOffset = this._bounceRightBoundary - icRightPos;
|
874
|
+
this._scrollToRightEvent();
|
875
|
+
scrollEnabled = false;
|
876
|
+
}
|
877
|
+
icLeftPos = locContainer.getLeftBoundary();
|
878
|
+
if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) {
|
879
|
+
realOffset = this._bounceLeftBoundary - icLeftPos;
|
880
|
+
this._scrollToLeftEvent();
|
881
|
+
scrollEnabled = false;
|
882
|
+
}
|
883
|
+
} else {
|
884
|
+
icRightPos = locContainer.getRightBoundary();
|
885
|
+
if (icRightPos + touchOffsetX <= this._rightBoundary) {
|
886
|
+
realOffset = this._rightBoundary - icRightPos;
|
887
|
+
this._scrollToRightEvent();
|
888
|
+
scrollEnabled = false;
|
889
|
+
}
|
890
|
+
icLeftPos = locContainer.getLeftBoundary();
|
891
|
+
if (icLeftPos + touchOffsetX >= this._leftBoundary) {
|
892
|
+
realOffset = this._leftBoundary - icLeftPos;
|
893
|
+
this._scrollToLeftEvent();
|
894
|
+
scrollEnabled = false;
|
895
|
+
}
|
896
|
+
}
|
897
|
+
this._moveChildren(realOffset, 0.0);
|
898
|
+
return scrollEnabled;
|
899
|
+
},
|
900
|
+
|
901
|
+
_scrollChildrenBoth: function (touchOffsetX, touchOffsetY) {
|
902
|
+
var scrollEnabled = true;
|
903
|
+
var realOffsetX = touchOffsetX;
|
904
|
+
var realOffsetY = touchOffsetY;
|
905
|
+
var icLeftPos, icBottomPos, icRightPos, icTopPos;
|
906
|
+
var locContainer = this._innerContainer;
|
907
|
+
if (this.bounceEnabled) {
|
908
|
+
if (touchOffsetX > 0.0 && touchOffsetY > 0.0) { // up right
|
909
|
+
icLeftPos = locContainer.getLeftBoundary();
|
910
|
+
if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) {
|
911
|
+
realOffsetX = this._bounceLeftBoundary - icLeftPos;
|
912
|
+
this._scrollToLeftEvent();
|
913
|
+
scrollEnabled = false;
|
914
|
+
}
|
915
|
+
icBottomPos = locContainer.getBottomBoundary();
|
916
|
+
if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) {
|
917
|
+
realOffsetY = this._bounceBottomBoundary - icBottomPos;
|
918
|
+
this._scrollToBottomEvent();
|
919
|
+
scrollEnabled = false;
|
920
|
+
}
|
921
|
+
} else if (touchOffsetX < 0.0 && touchOffsetY > 0.0) { // up left
|
922
|
+
icRightPos = locContainer.getRightBoundary();
|
923
|
+
if (icRightPos + touchOffsetX <= this._bounceRightBoundary) {
|
924
|
+
realOffsetX = this._bounceRightBoundary - icRightPos;
|
925
|
+
this._scrollToRightEvent();
|
926
|
+
scrollEnabled = false;
|
927
|
+
}
|
928
|
+
icBottomPos = locContainer.getBottomBoundary();
|
929
|
+
if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) {
|
930
|
+
realOffsetY = this._bounceBottomBoundary - icBottomPos;
|
931
|
+
this._scrollToBottomEvent();
|
932
|
+
scrollEnabled = false;
|
933
|
+
}
|
934
|
+
} else if (touchOffsetX < 0.0 && touchOffsetY < 0.0) { // down left
|
935
|
+
icRightPos = locContainer.getRightBoundary();
|
936
|
+
if (icRightPos + touchOffsetX <= this._bounceRightBoundary) {
|
937
|
+
realOffsetX = this._bounceRightBoundary - icRightPos;
|
938
|
+
this._scrollToRightEvent();
|
939
|
+
scrollEnabled = false;
|
940
|
+
}
|
941
|
+
icTopPos = locContainer.getTopBoundary();
|
942
|
+
if (icTopPos + touchOffsetY <= this._bounceTopBoundary) {
|
943
|
+
realOffsetY = this._bounceTopBoundary - icTopPos;
|
944
|
+
this._scrollToTopEvent();
|
945
|
+
scrollEnabled = false;
|
946
|
+
}
|
947
|
+
} else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ // down right
|
948
|
+
icLeftPos = locContainer.getLeftBoundary();
|
949
|
+
if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) {
|
950
|
+
realOffsetX = this._bounceLeftBoundary - icLeftPos;
|
951
|
+
this._scrollToLeftEvent();
|
952
|
+
scrollEnabled = false;
|
953
|
+
}
|
954
|
+
icTopPos = locContainer.getTopBoundary();
|
955
|
+
if (icTopPos + touchOffsetY <= this._bounceTopBoundary) {
|
956
|
+
realOffsetY = this._bounceTopBoundary - icTopPos;
|
957
|
+
this._scrollToTopEvent();
|
958
|
+
scrollEnabled = false;
|
959
|
+
}
|
960
|
+
} else if (touchOffsetX == 0.0 && touchOffsetY > 0.0){ // up
|
961
|
+
icBottomPos = locContainer.getBottomBoundary();
|
962
|
+
if (icBottomPos + touchOffsetY >= this._bounceBottomBoundary) {
|
963
|
+
realOffsetY = this._bounceBottomBoundary - icBottomPos;
|
964
|
+
this._scrollToBottomEvent();
|
965
|
+
scrollEnabled = false;
|
966
|
+
}
|
967
|
+
} else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left
|
968
|
+
icRightPos = locContainer.getRightBoundary();
|
969
|
+
if (icRightPos + touchOffsetX <= this._bounceRightBoundary) {
|
970
|
+
realOffsetX = this._bounceRightBoundary - icRightPos;
|
971
|
+
this._scrollToRightEvent();
|
972
|
+
scrollEnabled = false;
|
973
|
+
}
|
974
|
+
} else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down
|
975
|
+
icTopPos = locContainer.getTopBoundary();
|
976
|
+
if (icTopPos + touchOffsetY <= this._bounceTopBoundary) {
|
977
|
+
realOffsetY = this._bounceTopBoundary - icTopPos;
|
978
|
+
this._scrollToTopEvent();
|
979
|
+
scrollEnabled = false;
|
980
|
+
}
|
981
|
+
} else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right
|
982
|
+
icLeftPos = locContainer.getLeftBoundary();
|
983
|
+
if (icLeftPos + touchOffsetX >= this._bounceLeftBoundary) {
|
984
|
+
realOffsetX = this._bounceLeftBoundary - icLeftPos;
|
985
|
+
this._scrollToLeftEvent();
|
986
|
+
scrollEnabled = false;
|
987
|
+
}
|
988
|
+
}
|
989
|
+
} else {
|
990
|
+
if (touchOffsetX > 0.0 && touchOffsetY > 0.0){ // up right
|
991
|
+
icLeftPos = locContainer.getLeftBoundary();
|
992
|
+
if (icLeftPos + touchOffsetX >= this._leftBoundary) {
|
993
|
+
realOffsetX = this._leftBoundary - icLeftPos;
|
994
|
+
this._scrollToLeftEvent();
|
995
|
+
scrollEnabled = false;
|
996
|
+
}
|
997
|
+
icBottomPos = locContainer.getBottomBoundary();
|
998
|
+
if (icBottomPos + touchOffsetY >= this._bottomBoundary) {
|
999
|
+
realOffsetY = this._bottomBoundary - icBottomPos;
|
1000
|
+
this._scrollToBottomEvent();
|
1001
|
+
scrollEnabled = false;
|
1002
|
+
}
|
1003
|
+
} else if (touchOffsetX < 0.0 && touchOffsetY > 0.0){ // up left
|
1004
|
+
icRightPos = locContainer.getRightBoundary();
|
1005
|
+
if (icRightPos + touchOffsetX <= this._rightBoundary) {
|
1006
|
+
realOffsetX = this._rightBoundary - icRightPos;
|
1007
|
+
this._scrollToRightEvent();
|
1008
|
+
scrollEnabled = false;
|
1009
|
+
}
|
1010
|
+
icBottomPos = locContainer.getBottomBoundary();
|
1011
|
+
if (icBottomPos + touchOffsetY >= this._bottomBoundary) {
|
1012
|
+
realOffsetY = this._bottomBoundary - icBottomPos;
|
1013
|
+
this._scrollToBottomEvent();
|
1014
|
+
scrollEnabled = false;
|
1015
|
+
}
|
1016
|
+
} else if (touchOffsetX < 0.0 && touchOffsetY < 0.0){ // down left
|
1017
|
+
icRightPos = locContainer.getRightBoundary();
|
1018
|
+
if (icRightPos + touchOffsetX <= this._rightBoundary) {
|
1019
|
+
realOffsetX = this._rightBoundary - icRightPos;
|
1020
|
+
this._scrollToRightEvent();
|
1021
|
+
scrollEnabled = false;
|
1022
|
+
}
|
1023
|
+
icTopPos = locContainer.getTopBoundary();
|
1024
|
+
if (icTopPos + touchOffsetY <= this._topBoundary) {
|
1025
|
+
realOffsetY = this._topBoundary - icTopPos;
|
1026
|
+
this._scrollToTopEvent();
|
1027
|
+
scrollEnabled = false;
|
1028
|
+
}
|
1029
|
+
} else if (touchOffsetX > 0.0 && touchOffsetY < 0.0){ // down right
|
1030
|
+
icLeftPos = locContainer.getLeftBoundary();
|
1031
|
+
if (icLeftPos + touchOffsetX >= this._leftBoundary) {
|
1032
|
+
realOffsetX = this._leftBoundary - icLeftPos;
|
1033
|
+
this._scrollToLeftEvent();
|
1034
|
+
scrollEnabled = false;
|
1035
|
+
}
|
1036
|
+
icTopPos = this._innerContainer.getTopBoundary();
|
1037
|
+
if (icTopPos + touchOffsetY <= this._topBoundary) {
|
1038
|
+
realOffsetY = this._topBoundary - icTopPos;
|
1039
|
+
this._scrollToTopEvent();
|
1040
|
+
scrollEnabled = false;
|
1041
|
+
}
|
1042
|
+
} else if (touchOffsetX == 0.0 && touchOffsetY > 0.0) { // up
|
1043
|
+
icBottomPos = this._innerContainer.getBottomBoundary();
|
1044
|
+
if (icBottomPos + touchOffsetY >= this._bottomBoundary) {
|
1045
|
+
realOffsetY = this._bottomBoundary - icBottomPos;
|
1046
|
+
this._scrollToBottomEvent();
|
1047
|
+
scrollEnabled = false;
|
1048
|
+
}
|
1049
|
+
} else if (touchOffsetX < 0.0 && touchOffsetY == 0.0){ // left
|
1050
|
+
icRightPos = this._innerContainer.getRightBoundary();
|
1051
|
+
if (icRightPos + touchOffsetX <= this._rightBoundary) {
|
1052
|
+
realOffsetX = this._rightBoundary - icRightPos;
|
1053
|
+
this._scrollToRightEvent();
|
1054
|
+
scrollEnabled = false;
|
1055
|
+
}
|
1056
|
+
} else if (touchOffsetX == 0.0 && touchOffsetY < 0.0){ // down
|
1057
|
+
icTopPos = this._innerContainer.getTopBoundary();
|
1058
|
+
if (icTopPos + touchOffsetY <= this._topBoundary) {
|
1059
|
+
realOffsetY = this._topBoundary - icTopPos;
|
1060
|
+
this._scrollToTopEvent();
|
1061
|
+
scrollEnabled = false;
|
1062
|
+
}
|
1063
|
+
} else if (touchOffsetX > 0.0 && touchOffsetY == 0.0){ // right
|
1064
|
+
icLeftPos = this._innerContainer.getLeftBoundary();
|
1065
|
+
if (icLeftPos + touchOffsetX >= this._leftBoundary) {
|
1066
|
+
realOffsetX = this._leftBoundary - icLeftPos;
|
1067
|
+
this._scrollToLeftEvent();
|
1068
|
+
scrollEnabled = false;
|
1069
|
+
}
|
1070
|
+
}
|
1071
|
+
}
|
1072
|
+
this._moveChildren(realOffsetX, realOffsetY);
|
1073
|
+
return scrollEnabled;
|
1074
|
+
},
|
1075
|
+
|
1076
|
+
/**
|
1077
|
+
* Scroll inner container to bottom boundary of ScrollView.
|
1078
|
+
* @param {Number} time
|
1079
|
+
* @param {Boolean} attenuated
|
1080
|
+
*/
|
1081
|
+
scrollToBottom: function (time, attenuated) {
|
1082
|
+
this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), 0), time, attenuated);
|
1083
|
+
},
|
1084
|
+
|
1085
|
+
/**
|
1086
|
+
* Scroll inner container to top boundary of ScrollView.
|
1087
|
+
* @param {Number} time
|
1088
|
+
* @param {Boolean} attenuated
|
1089
|
+
*/
|
1090
|
+
scrollToTop: function (time, attenuated) {
|
1091
|
+
this._startAutoScrollChildrenWithDestination(
|
1092
|
+
cc.p(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height), time, attenuated);
|
1093
|
+
},
|
1094
|
+
|
1095
|
+
/**
|
1096
|
+
* Scroll inner container to left boundary of ScrollView.
|
1097
|
+
* @param {Number} time
|
1098
|
+
* @param {Boolean} attenuated
|
1099
|
+
*/
|
1100
|
+
scrollToLeft: function (time, attenuated) {
|
1101
|
+
this._startAutoScrollChildrenWithDestination(cc.p(0, this._innerContainer.getPositionY()), time, attenuated);
|
1102
|
+
},
|
1103
|
+
|
1104
|
+
/**
|
1105
|
+
* Scroll inner container to right boundary of ScrollView.
|
1106
|
+
* @param {Number} time
|
1107
|
+
* @param {Boolean} attenuated
|
1108
|
+
*/
|
1109
|
+
scrollToRight: function (time, attenuated) {
|
1110
|
+
this._startAutoScrollChildrenWithDestination(
|
1111
|
+
cc.p(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY()), time, attenuated);
|
1112
|
+
},
|
1113
|
+
|
1114
|
+
/**
|
1115
|
+
* Scroll inner container to top and left boundary of ScrollView.
|
1116
|
+
* @param {Number} time
|
1117
|
+
* @param {Boolean} attenuated
|
1118
|
+
*/
|
1119
|
+
scrollToTopLeft: function (time, attenuated) {
|
1120
|
+
if (this.direction != ccui.ScrollView.DIR_BOTH) {
|
1121
|
+
cc.log("Scroll direction is not both!");
|
1122
|
+
return;
|
1123
|
+
}
|
1124
|
+
this._startAutoScrollChildrenWithDestination(cc.p(0, this._contentSize.height - this._innerContainer.getContentSize().height), time, attenuated);
|
1125
|
+
},
|
1126
|
+
|
1127
|
+
/**
|
1128
|
+
* Scroll inner container to top and right boundary of ScrollView.
|
1129
|
+
* @param {Number} time
|
1130
|
+
* @param {Boolean} attenuated
|
1131
|
+
*/
|
1132
|
+
scrollToTopRight: function (time, attenuated) {
|
1133
|
+
if (this.direction != ccui.ScrollView.DIR_BOTH) {
|
1134
|
+
cc.log("Scroll direction is not both!");
|
1135
|
+
return;
|
1136
|
+
}
|
1137
|
+
var inSize = this._innerContainer.getContentSize();
|
1138
|
+
this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - inSize.width,
|
1139
|
+
this._contentSize.height - inSize.height), time, attenuated);
|
1140
|
+
},
|
1141
|
+
|
1142
|
+
/**
|
1143
|
+
* Scroll inner container to bottom and left boundary of ScrollView.
|
1144
|
+
* @param {Number} time
|
1145
|
+
* @param {Boolean} attenuated
|
1146
|
+
*/
|
1147
|
+
scrollToBottomLeft: function (time, attenuated) {
|
1148
|
+
if (this.direction != ccui.ScrollView.DIR_BOTH) {
|
1149
|
+
cc.log("Scroll direction is not both!");
|
1150
|
+
return;
|
1151
|
+
}
|
1152
|
+
this._startAutoScrollChildrenWithDestination(cc.p(0, 0), time, attenuated);
|
1153
|
+
},
|
1154
|
+
|
1155
|
+
/**
|
1156
|
+
* Scroll inner container to bottom and right boundary of ScrollView.
|
1157
|
+
* @param {Number} time
|
1158
|
+
* @param {Boolean} attenuated
|
1159
|
+
*/
|
1160
|
+
scrollToBottomRight: function (time, attenuated) {
|
1161
|
+
if (this.direction != ccui.ScrollView.DIR_BOTH) {
|
1162
|
+
cc.log("Scroll direction is not both!");
|
1163
|
+
return;
|
1164
|
+
}
|
1165
|
+
this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width - this._innerContainer.getContentSize().width, 0), time, attenuated);
|
1166
|
+
},
|
1167
|
+
|
1168
|
+
/**
|
1169
|
+
* Scroll inner container to vertical percent position of ScrollView.
|
1170
|
+
* @param {Number} percent
|
1171
|
+
* @param {Number} time
|
1172
|
+
* @param {Boolean} attenuated
|
1173
|
+
*/
|
1174
|
+
scrollToPercentVertical: function (percent, time, attenuated) {
|
1175
|
+
var minY = this._contentSize.height - this._innerContainer.getContentSize().height;
|
1176
|
+
var h = -minY;
|
1177
|
+
this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(), minY + percent * h / 100), time, attenuated);
|
1178
|
+
},
|
1179
|
+
|
1180
|
+
/**
|
1181
|
+
* Scroll inner container to horizontal percent position of ScrollView.
|
1182
|
+
* @param {Number} percent
|
1183
|
+
* @param {Number} time
|
1184
|
+
* @param {Boolean} attenuated
|
1185
|
+
*/
|
1186
|
+
scrollToPercentHorizontal: function (percent, time, attenuated) {
|
1187
|
+
var w = this._innerContainer.getContentSize().width - this._contentSize.width;
|
1188
|
+
this._startAutoScrollChildrenWithDestination(cc.p(-(percent * w / 100), this._innerContainer.getPositionY()), time, attenuated);
|
1189
|
+
},
|
1190
|
+
|
1191
|
+
/**
|
1192
|
+
* Scroll inner container to both direction percent position of ScrollView.
|
1193
|
+
* @param {cc.Point} percent
|
1194
|
+
* @param {Number} time
|
1195
|
+
* @param {Boolean} attenuated
|
1196
|
+
*/
|
1197
|
+
scrollToPercentBothDirection: function (percent, time, attenuated) {
|
1198
|
+
if (this.direction != ccui.ScrollView.DIR_BOTH)
|
1199
|
+
return;
|
1200
|
+
var minY = this._contentSize.height - this._innerContainer.getContentSize().height;
|
1201
|
+
var h = -minY;
|
1202
|
+
var w = this._innerContainer.getContentSize().width - this._contentSize.width;
|
1203
|
+
this._startAutoScrollChildrenWithDestination(cc.p(-(percent.x * w / 100), minY + percent.y * h / 100), time, attenuated);
|
1204
|
+
},
|
1205
|
+
|
1206
|
+
/**
|
1207
|
+
* Move inner container to bottom boundary of ScrollView.
|
1208
|
+
*/
|
1209
|
+
jumpToBottom: function () {
|
1210
|
+
this._jumpToDestination(this._innerContainer.getPositionX(), 0);
|
1211
|
+
},
|
1212
|
+
|
1213
|
+
/**
|
1214
|
+
* Move inner container to top boundary of ScrollView.
|
1215
|
+
*/
|
1216
|
+
jumpToTop: function () {
|
1217
|
+
this._jumpToDestination(this._innerContainer.getPositionX(), this._contentSize.height - this._innerContainer.getContentSize().height);
|
1218
|
+
},
|
1219
|
+
|
1220
|
+
/**
|
1221
|
+
* Move inner container to left boundary of ScrollView.
|
1222
|
+
*/
|
1223
|
+
jumpToLeft: function () {
|
1224
|
+
this._jumpToDestination(0, this._innerContainer.getPositionY());
|
1225
|
+
},
|
1226
|
+
|
1227
|
+
/**
|
1228
|
+
* Move inner container to right boundary of ScrollView.
|
1229
|
+
*/
|
1230
|
+
jumpToRight: function () {
|
1231
|
+
this._jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, this._innerContainer.getPositionY());
|
1232
|
+
},
|
1233
|
+
|
1234
|
+
/**
|
1235
|
+
* Move inner container to top and left boundary of ScrollView.
|
1236
|
+
*/
|
1237
|
+
jumpToTopLeft: function () {
|
1238
|
+
if (this.direction != ccui.ScrollView.DIR_BOTH) {
|
1239
|
+
cc.log("Scroll direction is not both!");
|
1240
|
+
return;
|
1241
|
+
}
|
1242
|
+
this._jumpToDestination(0, this._contentSize.height - this._innerContainer.getContentSize().height);
|
1243
|
+
},
|
1244
|
+
|
1245
|
+
/**
|
1246
|
+
* Move inner container to top and right boundary of ScrollView.
|
1247
|
+
*/
|
1248
|
+
jumpToTopRight: function () {
|
1249
|
+
if (this.direction != ccui.ScrollView.DIR_BOTH) {
|
1250
|
+
cc.log("Scroll direction is not both!");
|
1251
|
+
return;
|
1252
|
+
}
|
1253
|
+
var inSize = this._innerContainer.getContentSize();
|
1254
|
+
this._jumpToDestination(this._contentSize.width - inSize.width, this._contentSize.height - inSize.height);
|
1255
|
+
},
|
1256
|
+
|
1257
|
+
/**
|
1258
|
+
* Move inner container to bottom and left boundary of ScrollView.
|
1259
|
+
*/
|
1260
|
+
jumpToBottomLeft: function () {
|
1261
|
+
if (this.direction != ccui.ScrollView.DIR_BOTH) {
|
1262
|
+
cc.log("Scroll direction is not both!");
|
1263
|
+
return;
|
1264
|
+
}
|
1265
|
+
this._jumpToDestination(0, 0);
|
1266
|
+
},
|
1267
|
+
|
1268
|
+
/**
|
1269
|
+
* Move inner container to bottom and right boundary of ScrollView.
|
1270
|
+
*/
|
1271
|
+
jumpToBottomRight: function () {
|
1272
|
+
if (this.direction != ccui.ScrollView.DIR_BOTH) {
|
1273
|
+
cc.log("Scroll direction is not both!");
|
1274
|
+
return;
|
1275
|
+
}
|
1276
|
+
this._jumpToDestination(this._contentSize.width - this._innerContainer.getContentSize().width, 0);
|
1277
|
+
},
|
1278
|
+
|
1279
|
+
/**
|
1280
|
+
* Move inner container to vertical percent position of ScrollView.
|
1281
|
+
* @param {Number} percent The destination vertical percent, accept value between 0 - 100
|
1282
|
+
*/
|
1283
|
+
jumpToPercentVertical: function (percent) {
|
1284
|
+
var minY = this._contentSize.height - this._innerContainer.getContentSize().height;
|
1285
|
+
var h = -minY;
|
1286
|
+
this._jumpToDestination(this._innerContainer.getPositionX(), minY + percent * h / 100);
|
1287
|
+
},
|
1288
|
+
|
1289
|
+
/**
|
1290
|
+
* Move inner container to horizontal percent position of ScrollView.
|
1291
|
+
* @param {Number} percent The destination vertical percent, accept value between 0 - 100
|
1292
|
+
*/
|
1293
|
+
jumpToPercentHorizontal: function (percent) {
|
1294
|
+
var w = this._innerContainer.getContentSize().width - this._contentSize.width;
|
1295
|
+
this._jumpToDestination(-(percent * w / 100), this._innerContainer.getPositionY());
|
1296
|
+
},
|
1297
|
+
|
1298
|
+
/**
|
1299
|
+
* Move inner container to both direction percent position of ScrollView.
|
1300
|
+
* @param {cc.Point} percent The destination vertical percent, accept value between 0 - 100
|
1301
|
+
*/
|
1302
|
+
jumpToPercentBothDirection: function (percent) {
|
1303
|
+
if (this.direction != ccui.ScrollView.DIR_BOTH)
|
1304
|
+
return;
|
1305
|
+
var inSize = this._innerContainer.getContentSize();
|
1306
|
+
var minY = this._contentSize.height - inSize.height;
|
1307
|
+
var h = -minY;
|
1308
|
+
var w = inSize.width - this._contentSize.width;
|
1309
|
+
this._jumpToDestination(-(percent.x * w / 100), minY + percent.y * h / 100);
|
1310
|
+
},
|
1311
|
+
|
1312
|
+
_startRecordSlidAction: function () {
|
1313
|
+
if (this._autoScroll)
|
1314
|
+
this._stopAutoScrollChildren();
|
1315
|
+
if (this._bouncing)
|
1316
|
+
this._stopBounceChildren();
|
1317
|
+
this._slidTime = 0.0;
|
1318
|
+
},
|
1319
|
+
|
1320
|
+
_endRecordSlidAction: function () {
|
1321
|
+
if (!this._checkNeedBounce() && this.inertiaScrollEnabled) {
|
1322
|
+
if (this._slidTime <= 0.016)
|
1323
|
+
return;
|
1324
|
+
var totalDis = 0, dir;
|
1325
|
+
var touchEndPositionInNodeSpace = this.convertToNodeSpace(this._touchEndPosition);
|
1326
|
+
var touchBeganPositionInNodeSpace = this.convertToNodeSpace(this._touchBeganPosition);
|
1327
|
+
switch (this.direction) {
|
1328
|
+
case ccui.ScrollView.DIR_VERTICAL :
|
1329
|
+
totalDis = touchEndPositionInNodeSpace.y - touchBeganPositionInNodeSpace.y;
|
1330
|
+
dir = (totalDis < 0) ? ccui.ScrollView.SCROLLDIR_DOWN : ccui.ScrollView.SCROLLDIR_UP;
|
1331
|
+
break;
|
1332
|
+
case ccui.ScrollView.DIR_HORIZONTAL:
|
1333
|
+
totalDis = touchEndPositionInNodeSpace.x - touchBeganPositionInNodeSpace.x;
|
1334
|
+
dir = totalDis < 0 ? ccui.ScrollView.SCROLLDIR_LEFT : ccui.ScrollView.SCROLLDIR_RIGHT;
|
1335
|
+
break;
|
1336
|
+
case ccui.ScrollView.DIR_BOTH :
|
1337
|
+
var subVector = cc.pSub(touchEndPositionInNodeSpace, touchBeganPositionInNodeSpace);
|
1338
|
+
totalDis = cc.pLength(subVector);
|
1339
|
+
dir = cc.pNormalize(subVector);
|
1340
|
+
break;
|
1341
|
+
default:
|
1342
|
+
dir = cc.p(0,0);
|
1343
|
+
break;
|
1344
|
+
}
|
1345
|
+
var orSpeed = Math.min(Math.abs(totalDis) / (this._slidTime), ccui.ScrollView.AUTO_SCROLL_MAX_SPEED);
|
1346
|
+
this._startAutoScrollChildrenWithOriginalSpeed(dir, orSpeed, true, -1000);
|
1347
|
+
this._slidTime = 0;
|
1348
|
+
}
|
1349
|
+
},
|
1350
|
+
|
1351
|
+
_handlePressLogic: function (touch) {
|
1352
|
+
this._startRecordSlidAction();
|
1353
|
+
this._bePressed = true;
|
1354
|
+
},
|
1355
|
+
|
1356
|
+
_handleMoveLogic: function (touch) {
|
1357
|
+
var touchPositionInNodeSpace = this.convertToNodeSpace(touch.getLocation()),
|
1358
|
+
previousTouchPositionInNodeSpace = this.convertToNodeSpace(touch.getPreviousLocation());
|
1359
|
+
var delta = cc.pSub(touchPositionInNodeSpace, previousTouchPositionInNodeSpace);
|
1360
|
+
switch (this.direction) {
|
1361
|
+
case ccui.ScrollView.DIR_VERTICAL: // vertical
|
1362
|
+
this._scrollChildren(0.0, delta.y);
|
1363
|
+
break;
|
1364
|
+
case ccui.ScrollView.DIR_HORIZONTAL: // horizontal
|
1365
|
+
this._scrollChildren(delta.x, 0);
|
1366
|
+
break;
|
1367
|
+
case ccui.ScrollView.DIR_BOTH: // both
|
1368
|
+
this._scrollChildren(delta.x, delta.y);
|
1369
|
+
break;
|
1370
|
+
default:
|
1371
|
+
break;
|
1372
|
+
}
|
1373
|
+
},
|
1374
|
+
|
1375
|
+
_handleReleaseLogic: function (touch) {
|
1376
|
+
this._endRecordSlidAction();
|
1377
|
+
this._bePressed = false;
|
1378
|
+
},
|
1379
|
+
|
1380
|
+
/**
|
1381
|
+
* The touch began event callback handler of ccui.ScrollView.
|
1382
|
+
* @param {cc.Touch} touch
|
1383
|
+
* @param {cc.Event} event
|
1384
|
+
* @returns {boolean}
|
1385
|
+
*/
|
1386
|
+
onTouchBegan: function (touch, event) {
|
1387
|
+
var pass = ccui.Layout.prototype.onTouchBegan.call(this, touch, event);
|
1388
|
+
if(!this._isInterceptTouch){
|
1389
|
+
if (this._hit)
|
1390
|
+
this._handlePressLogic(touch);
|
1391
|
+
}
|
1392
|
+
return pass;
|
1393
|
+
},
|
1394
|
+
|
1395
|
+
/**
|
1396
|
+
* The touch moved event callback handler of ccui.ScrollView.
|
1397
|
+
* @param {cc.Touch} touch
|
1398
|
+
* @param {cc.Event} event
|
1399
|
+
*/
|
1400
|
+
onTouchMoved: function (touch, event) {
|
1401
|
+
ccui.Layout.prototype.onTouchMoved.call(this, touch, event);
|
1402
|
+
if(!this._isInterceptTouch)
|
1403
|
+
this._handleMoveLogic(touch);
|
1404
|
+
},
|
1405
|
+
|
1406
|
+
/**
|
1407
|
+
* The touch ended event callback handler of ccui.ScrollView.
|
1408
|
+
* @param {cc.Touch} touch
|
1409
|
+
* @param {cc.Event} event
|
1410
|
+
*/
|
1411
|
+
onTouchEnded: function (touch, event) {
|
1412
|
+
ccui.Layout.prototype.onTouchEnded.call(this, touch, event);
|
1413
|
+
if(!this._isInterceptTouch)
|
1414
|
+
this._handleReleaseLogic(touch);
|
1415
|
+
this._isInterceptTouch = false;
|
1416
|
+
},
|
1417
|
+
|
1418
|
+
/**
|
1419
|
+
* The touch canceled event callback of ccui.ScrollView.
|
1420
|
+
* @param {cc.Touch} touch
|
1421
|
+
* @param {cc.Event} event
|
1422
|
+
*/
|
1423
|
+
onTouchCancelled: function (touch, event) {
|
1424
|
+
ccui.Layout.prototype.onTouchCancelled.call(this, touch, event);
|
1425
|
+
if (!this._isInterceptTouch)
|
1426
|
+
this.handleReleaseLogic(touch);
|
1427
|
+
this._isInterceptTouch = false;
|
1428
|
+
},
|
1429
|
+
|
1430
|
+
/**
|
1431
|
+
* The update callback handler.
|
1432
|
+
* @param {Number} dt
|
1433
|
+
*/
|
1434
|
+
update: function (dt) {
|
1435
|
+
if (this._autoScroll)
|
1436
|
+
this._autoScrollChildren(dt);
|
1437
|
+
if (this._bouncing)
|
1438
|
+
this._bounceChildren(dt);
|
1439
|
+
this._recordSlidTime(dt);
|
1440
|
+
},
|
1441
|
+
|
1442
|
+
_recordSlidTime: function (dt) {
|
1443
|
+
if (this._bePressed)
|
1444
|
+
this._slidTime += dt;
|
1445
|
+
},
|
1446
|
+
|
1447
|
+
/**
|
1448
|
+
* Intercept touch event, handle its child's touch event.
|
1449
|
+
* @override
|
1450
|
+
* @param {number} event event type
|
1451
|
+
* @param {ccui.Widget} sender
|
1452
|
+
* @param {cc.Touch} touch
|
1453
|
+
*/
|
1454
|
+
interceptTouchEvent: function (event, sender, touch) {
|
1455
|
+
var touchPoint = touch.getLocation();
|
1456
|
+
switch (event) {
|
1457
|
+
case ccui.Widget.TOUCH_BEGAN:
|
1458
|
+
this._isInterceptTouch = true;
|
1459
|
+
this._touchBeganPosition.x = touchPoint.x;
|
1460
|
+
this._touchBeganPosition.y = touchPoint.y;
|
1461
|
+
this._handlePressLogic(touch);
|
1462
|
+
break;
|
1463
|
+
case ccui.Widget.TOUCH_MOVED:
|
1464
|
+
var offset = cc.pLength(cc.pSub(sender.getTouchBeganPosition(), touchPoint));
|
1465
|
+
this._touchMovePosition.x = touchPoint.x;
|
1466
|
+
this._touchMovePosition.y = touchPoint.y;
|
1467
|
+
if (offset > this._childFocusCancelOffset) {
|
1468
|
+
sender.setHighlighted(false);
|
1469
|
+
this._handleMoveLogic(touch);
|
1470
|
+
}
|
1471
|
+
break;
|
1472
|
+
case ccui.Widget.TOUCH_CANCELED:
|
1473
|
+
case ccui.Widget.TOUCH_ENDED:
|
1474
|
+
this._touchEndPosition.x = touchPoint.x;
|
1475
|
+
this._touchEndPosition.y = touchPoint.y;
|
1476
|
+
this._handleReleaseLogic(touch);
|
1477
|
+
if (sender.isSwallowTouches())
|
1478
|
+
this._isInterceptTouch = false;
|
1479
|
+
break;
|
1480
|
+
}
|
1481
|
+
},
|
1482
|
+
|
1483
|
+
_scrollToTopEvent: function () {
|
1484
|
+
if(this._scrollViewEventSelector){
|
1485
|
+
if (this._scrollViewEventListener)
|
1486
|
+
this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_TOP);
|
1487
|
+
else
|
1488
|
+
this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_TOP);
|
1489
|
+
}
|
1490
|
+
if(this._ccEventCallback)
|
1491
|
+
this._ccEventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_TOP);
|
1492
|
+
},
|
1493
|
+
|
1494
|
+
_scrollToBottomEvent: function () {
|
1495
|
+
if(this._scrollViewEventSelector){
|
1496
|
+
if (this._scrollViewEventListener)
|
1497
|
+
this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM);
|
1498
|
+
else
|
1499
|
+
this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM);
|
1500
|
+
}
|
1501
|
+
if(this._ccEventCallback)
|
1502
|
+
this._ccEventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM);
|
1503
|
+
},
|
1504
|
+
|
1505
|
+
_scrollToLeftEvent: function () {
|
1506
|
+
if(this._scrollViewEventSelector){
|
1507
|
+
if (this._scrollViewEventListener)
|
1508
|
+
this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT);
|
1509
|
+
else
|
1510
|
+
this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT);
|
1511
|
+
}
|
1512
|
+
if(this._ccEventCallback)
|
1513
|
+
this._ccEventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_LEFT);
|
1514
|
+
},
|
1515
|
+
|
1516
|
+
_scrollToRightEvent: function () {
|
1517
|
+
if(this._scrollViewEventSelector){
|
1518
|
+
if (this._scrollViewEventListener)
|
1519
|
+
this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT);
|
1520
|
+
else
|
1521
|
+
this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT);
|
1522
|
+
}
|
1523
|
+
if(this._ccEventCallback)
|
1524
|
+
this._ccEventCallback(this, ccui.ScrollView.EVENT_SCROLL_TO_RIGHT);
|
1525
|
+
},
|
1526
|
+
|
1527
|
+
_scrollingEvent: function () {
|
1528
|
+
if(this._scrollViewEventSelector){
|
1529
|
+
if (this._scrollViewEventListener)
|
1530
|
+
this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_SCROLLING);
|
1531
|
+
else
|
1532
|
+
this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_SCROLLING);
|
1533
|
+
}
|
1534
|
+
if(this._ccEventCallback)
|
1535
|
+
this._ccEventCallback(this, ccui.ScrollView.EVENT_SCROLLING);
|
1536
|
+
},
|
1537
|
+
|
1538
|
+
_bounceTopEvent: function () {
|
1539
|
+
if(this._scrollViewEventSelector){
|
1540
|
+
if (this._scrollViewEventListener)
|
1541
|
+
this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_TOP);
|
1542
|
+
else
|
1543
|
+
this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_TOP);
|
1544
|
+
}
|
1545
|
+
if(this._ccEventCallback)
|
1546
|
+
this._ccEventCallback(this, ccui.ScrollView.EVENT_BOUNCE_TOP);
|
1547
|
+
},
|
1548
|
+
|
1549
|
+
_bounceBottomEvent: function () {
|
1550
|
+
if(this._scrollViewEventSelector){
|
1551
|
+
if (this._scrollViewEventListener)
|
1552
|
+
this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM);
|
1553
|
+
else
|
1554
|
+
this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM);
|
1555
|
+
}
|
1556
|
+
if(this._ccEventCallback)
|
1557
|
+
this._ccEventCallback(this, ccui.ScrollView.EVENT_BOUNCE_BOTTOM);
|
1558
|
+
},
|
1559
|
+
|
1560
|
+
_bounceLeftEvent: function () {
|
1561
|
+
if(this._scrollViewEventSelector){
|
1562
|
+
if (this._scrollViewEventListener)
|
1563
|
+
this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_LEFT);
|
1564
|
+
else
|
1565
|
+
this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_LEFT);
|
1566
|
+
}
|
1567
|
+
if(this._ccEventCallback)
|
1568
|
+
this._ccEventCallback(this, ccui.ScrollView.EVENT_BOUNCE_LEFT);
|
1569
|
+
},
|
1570
|
+
|
1571
|
+
_bounceRightEvent: function () {
|
1572
|
+
if(this._scrollViewEventSelector){
|
1573
|
+
if (this._scrollViewEventListener)
|
1574
|
+
this._scrollViewEventSelector.call(this._scrollViewEventListener, this, ccui.ScrollView.EVENT_BOUNCE_RIGHT);
|
1575
|
+
else
|
1576
|
+
this._scrollViewEventSelector(this, ccui.ScrollView.EVENT_BOUNCE_RIGHT);
|
1577
|
+
}
|
1578
|
+
if(this._ccEventCallback)
|
1579
|
+
this._ccEventCallback(this, ccui.ScrollView.EVENT_BOUNCE_RIGHT);
|
1580
|
+
},
|
1581
|
+
|
1582
|
+
/**
|
1583
|
+
* Adds callback function called ScrollView event triggered
|
1584
|
+
* @param {Function} selector
|
1585
|
+
* @param {Object} [target=]
|
1586
|
+
* @deprecated since v3.0, please use addEventListener instead.
|
1587
|
+
*/
|
1588
|
+
addEventListenerScrollView: function (selector, target) {
|
1589
|
+
this.addEventListener(selector, target);
|
1590
|
+
},
|
1591
|
+
|
1592
|
+
/**
|
1593
|
+
* Adds callback function called ScrollView event triggered
|
1594
|
+
* @param {Function} selector
|
1595
|
+
* @param {Object} [target=]
|
1596
|
+
*/
|
1597
|
+
addEventListener: function(selector, target){
|
1598
|
+
this._scrollViewEventSelector = selector;
|
1599
|
+
this._scrollViewEventListener = target;
|
1600
|
+
},
|
1601
|
+
|
1602
|
+
/**
|
1603
|
+
* Changes scroll direction of ScrollView.
|
1604
|
+
* @param {ccui.ScrollView.DIR_NONE | ccui.ScrollView.DIR_VERTICAL | ccui.ScrollView.DIR_HORIZONTAL | ccui.ScrollView.DIR_BOTH} dir
|
1605
|
+
* Direction::VERTICAL means vertical scroll, Direction::HORIZONTAL means horizontal scroll
|
1606
|
+
*/
|
1607
|
+
setDirection: function (dir) {
|
1608
|
+
this.direction = dir;
|
1609
|
+
},
|
1610
|
+
|
1611
|
+
/**
|
1612
|
+
* Returns scroll direction of ScrollView.
|
1613
|
+
* @returns {ccui.ScrollView.DIR_NONE | ccui.ScrollView.DIR_VERTICAL | ccui.ScrollView.DIR_HORIZONTAL | ccui.ScrollView.DIR_BOTH}
|
1614
|
+
*/
|
1615
|
+
getDirection: function () {
|
1616
|
+
return this.direction;
|
1617
|
+
},
|
1618
|
+
|
1619
|
+
/**
|
1620
|
+
* Sets bounce enabled
|
1621
|
+
* @param {Boolean} enabled
|
1622
|
+
*/
|
1623
|
+
setBounceEnabled: function (enabled) {
|
1624
|
+
this.bounceEnabled = enabled;
|
1625
|
+
},
|
1626
|
+
|
1627
|
+
/**
|
1628
|
+
* Returns whether bounce is enabled
|
1629
|
+
* @returns {boolean}
|
1630
|
+
*/
|
1631
|
+
isBounceEnabled: function () {
|
1632
|
+
return this.bounceEnabled;
|
1633
|
+
},
|
1634
|
+
|
1635
|
+
/**
|
1636
|
+
* Sets inertiaScroll enabled
|
1637
|
+
* @param {boolean} enabled
|
1638
|
+
*/
|
1639
|
+
setInertiaScrollEnabled: function (enabled) {
|
1640
|
+
this.inertiaScrollEnabled = enabled;
|
1641
|
+
},
|
1642
|
+
|
1643
|
+
/**
|
1644
|
+
* Returns whether inertiaScroll is enabled
|
1645
|
+
* @returns {boolean}
|
1646
|
+
*/
|
1647
|
+
isInertiaScrollEnabled: function () {
|
1648
|
+
return this.inertiaScrollEnabled;
|
1649
|
+
},
|
1650
|
+
|
1651
|
+
/**
|
1652
|
+
* Gets inner container of ScrollView. Inner container is the container of ScrollView's children.
|
1653
|
+
* @returns {ccui.Layout}
|
1654
|
+
*/
|
1655
|
+
getInnerContainer: function () {
|
1656
|
+
return this._innerContainer;
|
1657
|
+
},
|
1658
|
+
|
1659
|
+
/**
|
1660
|
+
* Sets LayoutType of ccui.ScrollView.
|
1661
|
+
* @param {ccui.Layout.ABSOLUTE|ccui.Layout.LINEAR_VERTICAL|ccui.Layout.LINEAR_HORIZONTAL|ccui.Layout.RELATIVE} type
|
1662
|
+
*/
|
1663
|
+
setLayoutType: function (type) {
|
1664
|
+
this._innerContainer.setLayoutType(type);
|
1665
|
+
},
|
1666
|
+
|
1667
|
+
/**
|
1668
|
+
* Returns the layout type of ccui.ScrollView.
|
1669
|
+
* @returns {ccui.Layout.ABSOLUTE|ccui.Layout.LINEAR_VERTICAL|ccui.Layout.LINEAR_HORIZONTAL|ccui.Layout.RELATIVE}
|
1670
|
+
*/
|
1671
|
+
getLayoutType: function () {
|
1672
|
+
return this._innerContainer.getLayoutType();
|
1673
|
+
},
|
1674
|
+
|
1675
|
+
_doLayout: function () {
|
1676
|
+
if (!this._doLayoutDirty)
|
1677
|
+
return;
|
1678
|
+
this._doLayoutDirty = false;
|
1679
|
+
},
|
1680
|
+
|
1681
|
+
/**
|
1682
|
+
* Returns the "class name" of ccui.ScrollView.
|
1683
|
+
* @returns {string}
|
1684
|
+
*/
|
1685
|
+
getDescription: function () {
|
1686
|
+
return "ScrollView";
|
1687
|
+
},
|
1688
|
+
|
1689
|
+
_createCloneInstance: function(){
|
1690
|
+
return new ccui.ScrollView();
|
1691
|
+
},
|
1692
|
+
|
1693
|
+
_copyClonedWidgetChildren: function (model) {
|
1694
|
+
ccui.Layout.prototype._copyClonedWidgetChildren.call(this, model);
|
1695
|
+
},
|
1696
|
+
|
1697
|
+
_copySpecialProperties: function (scrollView) {
|
1698
|
+
if(scrollView instanceof ccui.ScrollView) {
|
1699
|
+
ccui.Layout.prototype._copySpecialProperties.call(this, scrollView);
|
1700
|
+
this.setInnerContainerSize(scrollView.getInnerContainerSize());
|
1701
|
+
this.setDirection(scrollView.direction);
|
1702
|
+
this.setBounceEnabled(scrollView.bounceEnabled);
|
1703
|
+
this.setInertiaScrollEnabled(scrollView.inertiaScrollEnabled);
|
1704
|
+
this._scrollViewEventListener = scrollView._scrollViewEventListener;
|
1705
|
+
this._scrollViewEventSelector = scrollView._scrollViewEventSelector;
|
1706
|
+
this._ccEventCallback = scrollView._ccEventCallback;
|
1707
|
+
}
|
1708
|
+
},
|
1709
|
+
|
1710
|
+
/**
|
1711
|
+
* Returns a node by tag
|
1712
|
+
* @param {Number} tag
|
1713
|
+
* @returns {cc.Node}
|
1714
|
+
* @deprecated since v3.0, please use getChildByTag instead.
|
1715
|
+
*/
|
1716
|
+
getNodeByTag: function (tag) {
|
1717
|
+
return this._innerContainer.getNodeByTag(tag);
|
1718
|
+
},
|
1719
|
+
|
1720
|
+
/**
|
1721
|
+
* Returns all nodes of inner container
|
1722
|
+
* @returns {Array}
|
1723
|
+
* @deprecated since v3.0, please use getChildren instead.
|
1724
|
+
*/
|
1725
|
+
getNodes: function () {
|
1726
|
+
return this._innerContainer.getNodes();
|
1727
|
+
},
|
1728
|
+
|
1729
|
+
/**
|
1730
|
+
* Removes a node from ccui.ScrollView.
|
1731
|
+
* @param {cc.Node} node
|
1732
|
+
* @deprecated since v3.0, please use removeChild instead.
|
1733
|
+
*/
|
1734
|
+
removeNode: function (node) {
|
1735
|
+
this._innerContainer.removeNode(node);
|
1736
|
+
},
|
1737
|
+
|
1738
|
+
/**
|
1739
|
+
* Removes a node by tag
|
1740
|
+
* @param {Number} tag
|
1741
|
+
* @deprecated since v3.0, please use removeChildByTag instead.
|
1742
|
+
*/
|
1743
|
+
removeNodeByTag: function (tag) {
|
1744
|
+
this._innerContainer.removeNodeByTag(tag);
|
1745
|
+
},
|
1746
|
+
|
1747
|
+
/**
|
1748
|
+
* Remove all node from ccui.ScrollView.
|
1749
|
+
* @deprecated since v3.0, please use removeAllChildren instead.
|
1750
|
+
*/
|
1751
|
+
removeAllNodes: function () {
|
1752
|
+
this._innerContainer.removeAllNodes();
|
1753
|
+
},
|
1754
|
+
|
1755
|
+
/**
|
1756
|
+
* Add node for scrollView
|
1757
|
+
* @param {cc.Node} node
|
1758
|
+
* @param {Number} zOrder
|
1759
|
+
* @param {Number} tag
|
1760
|
+
* @deprecated since v3.0, please use addChild instead.
|
1761
|
+
*/
|
1762
|
+
addNode: function (node, zOrder, tag) {
|
1763
|
+
this._innerContainer.addNode(node, zOrder, tag);
|
1764
|
+
}
|
1765
|
+
});
|
1766
|
+
|
1767
|
+
var _p = ccui.ScrollView.prototype;
|
1768
|
+
|
1769
|
+
// Extended properties
|
1770
|
+
/** @expose */
|
1771
|
+
_p.innerWidth;
|
1772
|
+
cc.defineGetterSetter(_p, "innerWidth", _p._getInnerWidth, _p._setInnerWidth);
|
1773
|
+
/** @expose */
|
1774
|
+
_p.innerHeight;
|
1775
|
+
cc.defineGetterSetter(_p, "innerHeight", _p._getInnerHeight, _p._setInnerHeight);
|
1776
|
+
|
1777
|
+
_p = null;
|
1778
|
+
|
1779
|
+
/**
|
1780
|
+
* allocates and initializes a UIScrollView.
|
1781
|
+
* @deprecated since v3.0, please use new ccui.ScrollView() instead.
|
1782
|
+
* @return {ccui.ScrollView}
|
1783
|
+
*/
|
1784
|
+
ccui.ScrollView.create = function () {
|
1785
|
+
return new ccui.ScrollView();
|
1786
|
+
};
|
1787
|
+
|
1788
|
+
// Constants
|
1789
|
+
//ScrollView direction
|
1790
|
+
/**
|
1791
|
+
* The none flag of ccui.ScrollView's direction.
|
1792
|
+
* @constant
|
1793
|
+
* @type {number}
|
1794
|
+
*/
|
1795
|
+
ccui.ScrollView.DIR_NONE = 0;
|
1796
|
+
/**
|
1797
|
+
* The vertical flag of ccui.ScrollView's direction.
|
1798
|
+
* @constant
|
1799
|
+
* @type {number}
|
1800
|
+
*/
|
1801
|
+
ccui.ScrollView.DIR_VERTICAL = 1;
|
1802
|
+
/**
|
1803
|
+
* The horizontal flag of ccui.ScrollView's direction.
|
1804
|
+
* @constant
|
1805
|
+
* @type {number}
|
1806
|
+
*/
|
1807
|
+
ccui.ScrollView.DIR_HORIZONTAL = 2;
|
1808
|
+
/**
|
1809
|
+
* The both flag of ccui.ScrollView's direction.
|
1810
|
+
* @constant
|
1811
|
+
* @type {number}
|
1812
|
+
*/
|
1813
|
+
ccui.ScrollView.DIR_BOTH = 3;
|
1814
|
+
|
1815
|
+
//ScrollView event
|
1816
|
+
/**
|
1817
|
+
* The flag scroll to top of ccui.ScrollView's event.
|
1818
|
+
* @constant
|
1819
|
+
* @type {number}
|
1820
|
+
*/
|
1821
|
+
ccui.ScrollView.EVENT_SCROLL_TO_TOP = 0;
|
1822
|
+
/**
|
1823
|
+
* The flag scroll to bottom of ccui.ScrollView's event.
|
1824
|
+
* @constant
|
1825
|
+
* @type {number}
|
1826
|
+
*/
|
1827
|
+
ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM = 1;
|
1828
|
+
/**
|
1829
|
+
* The flag scroll to left of ccui.ScrollView's event.
|
1830
|
+
* @constant
|
1831
|
+
* @type {number}
|
1832
|
+
*/
|
1833
|
+
ccui.ScrollView.EVENT_SCROLL_TO_LEFT = 2;
|
1834
|
+
/**
|
1835
|
+
* The flag scroll to right of ccui.ScrollView's event.
|
1836
|
+
* @constant
|
1837
|
+
* @type {number}
|
1838
|
+
*/
|
1839
|
+
ccui.ScrollView.EVENT_SCROLL_TO_RIGHT = 3;
|
1840
|
+
/**
|
1841
|
+
* The scrolling flag of ccui.ScrollView's event.
|
1842
|
+
* @constant
|
1843
|
+
* @type {number}
|
1844
|
+
*/
|
1845
|
+
ccui.ScrollView.EVENT_SCROLLING = 4;
|
1846
|
+
/**
|
1847
|
+
* The flag bounce top of ccui.ScrollView's event.
|
1848
|
+
* @constant
|
1849
|
+
* @type {number}
|
1850
|
+
*/
|
1851
|
+
ccui.ScrollView.EVENT_BOUNCE_TOP = 5;
|
1852
|
+
/**
|
1853
|
+
* The flag bounce bottom of ccui.ScrollView's event.
|
1854
|
+
* @constant
|
1855
|
+
* @type {number}
|
1856
|
+
*/
|
1857
|
+
ccui.ScrollView.EVENT_BOUNCE_BOTTOM = 6;
|
1858
|
+
/**
|
1859
|
+
* The flag bounce left of ccui.ScrollView's event.
|
1860
|
+
* @constant
|
1861
|
+
* @type {number}
|
1862
|
+
*/
|
1863
|
+
ccui.ScrollView.EVENT_BOUNCE_LEFT = 7;
|
1864
|
+
/**
|
1865
|
+
* The flag bounce right of ccui.ScrollView's event.
|
1866
|
+
* @constant
|
1867
|
+
* @type {number}
|
1868
|
+
*/
|
1869
|
+
ccui.ScrollView.EVENT_BOUNCE_RIGHT = 8;
|
1870
|
+
|
1871
|
+
/**
|
1872
|
+
* The auto scroll max speed of ccui.ScrollView.
|
1873
|
+
* @constant
|
1874
|
+
* @type {number}
|
1875
|
+
*/
|
1876
|
+
ccui.ScrollView.AUTO_SCROLL_MAX_SPEED = 1000;
|
1877
|
+
|
1878
|
+
/**
|
1879
|
+
* @ignore
|
1880
|
+
*/
|
1881
|
+
ccui.ScrollView.SCROLLDIR_UP = cc.p(0, 1);
|
1882
|
+
ccui.ScrollView.SCROLLDIR_DOWN = cc.p(0, -1);
|
1883
|
+
ccui.ScrollView.SCROLLDIR_LEFT = cc.p(-1, 0);
|
1884
|
+
ccui.ScrollView.SCROLLDIR_RIGHT = cc.p(1, 0);
|