ccb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +31 -0
- data/bin/ccb +4 -0
- data/lib/ccb/builder/project_builder.rb +14 -0
- data/lib/ccb/builder/scene_builder.rb +9 -0
- data/lib/ccb/builder/templates/project/GameConfig.js.tt +21 -0
- data/lib/ccb/builder/templates/project/_cocos-project.json +4 -0
- data/lib/ccb/builder/templates/project/folder/CMakeLists.txt +295 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/Base64Images.js +32 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/CCBoot.js +2271 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/CCDebugger.js +336 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCAction.js +694 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionCamera.js +293 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionCatmullRom.js +605 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionEase.js +3681 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionInstant.js +757 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionInterval.js +3554 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions/CCActionTween.js +166 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionGrid.js +372 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionGrid3D.js +1257 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionPageTurn3D.js +113 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/actions3d/CCActionTiledGrid.js +1289 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/audio/CCAudio.js +1024 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/clipping-nodes/CCClippingNode.js +224 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js +227 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js +226 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/ZipUtils.js +82 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/base64.js +95 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/gzip.js +731 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/compression/zlib.min.js +55 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCActionManager.js +378 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCCamera.js +290 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCConfiguration.js +294 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDirector.js +1019 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDirectorWebGL.js +329 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDrawingPrimitivesCanvas.js +438 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCDrawingPrimitivesWebGL.js +464 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/CCScheduler.js +744 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js +127 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCAtlasNode.js +294 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js +138 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js +145 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCNode.js +2386 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCNodeCanvasRenderCmd.js +504 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/base-nodes/CCNodeWebGLRenderCmd.js +254 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/cocoa/CCAffineTransform.js +259 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/cocoa/CCGeometry.js +327 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEvent.js +449 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEventExtension.js +126 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEventListener.js +519 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCEventManager.js +1025 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/event-manager/CCTouch.js +175 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/CCLabelTTF.js +829 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js +420 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js +101 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/labelttf/LabelTTFPropertyDefine.js +88 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/layers/CCLayer.js +642 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/layers/CCLayerCanvasRenderCmd.js +434 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/layers/CCLayerWebGLRenderCmd.js +248 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCClass.js +333 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCCommon.js +303 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCConfig.js +303 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCEGLView.js +1245 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCInputExtension.js +135 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCInputManager.js +616 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCLoaders.js +142 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCMacro.js +830 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCSAXParser.js +160 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCScreen.js +155 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCTypes.js +374 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCTypesPropertyDefine.js +165 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCTypesWebGL.js +689 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/CCVisibleRect.js +100 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/platform/miniFramework.js +264 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/renderer/RendererCanvas.js +274 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/renderer/RendererWebGL.js +137 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/scenes/CCLoaderScene.js +149 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/scenes/CCScene.js +62 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCAnimation.js +477 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCAnimationCache.js +213 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCBakeSprite.js +71 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSprite.js +1014 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteBatchNode.js +676 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js +101 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js +243 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteCanvasRenderCmd.js +518 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteFrame.js +420 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteFrameCache.js +341 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/CCSpriteWebGLRenderCmd.js +493 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/sprites/SpritesPropertyDefine.js +67 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/support/CCPointExtension.js +515 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/support/CCVertex.js +170 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/support/TransformUtils.js +62 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/CCTexture2D.js +455 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/CCTextureAtlas.js +653 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/CCTextureCache.js +371 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/TexturesPropertyDefine.js +221 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/textures/TexturesWebGL.js +899 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/core/utils/BinaryLoader.js +151 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/effects/CCGrabber.js +110 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/effects/CCGrid.js +737 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/aabb.js +68 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/gl/mat4stack.js +59 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/gl/matrix.js +169 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/mat3.js +329 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/mat4.js +810 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/plane.js +184 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/quaternion.js +497 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/ray2.js +163 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/utility.js +76 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/vec2.js +107 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/vec3.js +205 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/kazmath/vec4.js +158 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelAtlas.js +239 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js +95 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js +132 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelBMFont.js +958 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js +142 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js +87 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/menus/CCMenu.js +600 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/menus/CCMenuItem.js +1422 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/motion-streak/CCMotionStreak.js +517 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/motion-streak/CCMotionStreakWebGLRenderCmd.js +66 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/node-grid/CCNodeGrid.js +129 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/node-grid/CCNodeGridWebGLRenderCmd.js +98 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/parallax/CCParallaxNode.js +252 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/parallax/CCParallaxNodeRenderCmd.js +69 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCPNGReader.js +330 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleBatchNode.js +527 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleBatchNodeCanvasRenderCmd.js +38 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js +74 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleExamples.js +1006 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleSystem.js +2294 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleSystemCanvasRenderCmd.js +217 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCParticleSystemWebGLRenderCmd.js +402 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/particle/CCTIFFReader.js +692 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsDebugNode.js +212 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsDebugNodeCanvasRenderCmd.js +52 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js +53 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsSprite.js +447 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsSpriteCanvasRenderCmd.js +93 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/physics/CCPhysicsSpriteWebGLRenderCmd.js +87 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCActionProgressTimer.js +227 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCProgressTimer.js +345 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js +270 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js +486 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/render-texture/CCRenderTexture.js +395 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js +105 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js +367 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCGLProgram.js +767 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCGLStateCache.js +340 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCShaderCache.js +301 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shaders/CCShaders.js +280 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shape-nodes/CCDrawNode.js +940 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js +129 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/shape-nodes/CCDrawNodeWebGLRenderCmd.js +41 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/text-input/CCIMEDispatcher.js +526 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/text-input/CCTextFieldTTF.js +472 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTGAlib.js +437 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXLayer.js +914 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js +232 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js +67 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXObjectGroup.js +146 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXTiledMap.js +479 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/tilemap/CCTMXXMLParser.js +950 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/transitions/CCTransition.js +1971 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/transitions/CCTransitionPageTurn.js +152 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/cocos2d/transitions/CCTransitionProgress.js +458 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBAnimationManager.js +770 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBKeyframe.js +60 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBReader.js +1129 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBReaderUtil.js +61 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBRelativePositioning.js +90 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBSequence.js +114 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCBValue.js +81 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCControlLoader.js +318 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCNodeLoader.js +905 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCNodeLoaderLibrary.js +101 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccb-reader/CCSpriteLoader.js +544 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccpool/CCPool.js +146 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/CCProtectedNode.js +305 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js +246 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js +159 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIScale9Sprite.js +1105 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js +142 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js +129 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIWidget.js +2059 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/base-classes/UIWidgetRenderCmd.js +100 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UIHBox.js +80 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayout.js +1558 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutCanvasRenderCmd.js +179 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutComponent.js +585 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutManager.js +457 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutParameter.js +576 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UILayoutWebGLRenderCmd.js +240 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UIRelativeBox.js +79 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/layouts/UIVBox.js +79 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/system/CocosGUI.js +62 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/system/UIHelper.js +164 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIButton.js +987 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UICheckBox.js +737 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIImageView.js +337 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UILoadingBar.js +432 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIRichText.js +579 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UISlider.js +762 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UIText.js +512 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UITextAtlas.js +229 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UITextBMFont.js +216 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/UITextField.js +915 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/scroll-widget/UIListView.js +602 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/scroll-widget/UIPageView.js +657 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js +1884 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/CocoStudio.js +68 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionFrame.js +528 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionManager.js +112 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionNode.js +417 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/action/CCActionObject.js +263 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCArmature.js +579 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js +190 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCArmatureWebGLRenderCmd.js +167 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/CCBone.js +711 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/animation/CCArmatureAnimation.js +669 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/animation/CCProcessBase.js +365 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/animation/CCTween.js +448 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/datas/CCDatas.js +807 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCDecorativeDisplay.js +118 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCDisplayFactory.js +220 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCDisplayManager.js +465 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCSkin.js +215 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCSkinCanvasRenderCmd.js +58 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/display/CCSkinWebGLRenderCmd.js +146 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/physics/CCColliderDetector.js +397 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCArmatureDataManager.js +325 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCArmatureDefine.js +45 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCDataReaderHelper.js +1223 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCSpriteFrameCacheHelper.js +68 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCTransformHelp.js +183 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCTweenFunction.js +501 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/armature/utils/CCUtilMath.js +69 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComAttribute.js +210 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComAudio.js +285 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComController.js +76 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComRender.js +91 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComponent.js +136 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/components/CCComponentContainer.js +159 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/load.js +221 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/action-1.x.js +238 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/action-2.x.js +266 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/compatible.js +251 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/scene-1.x.js +262 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/timelineParser-1.x.js +292 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/timelineParser-2.x.js +1288 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/loader/parsers/uiParser-1.x.js +680 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/timeline/ActionTimeline.js +448 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/timeline/Frame.js +1268 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/timeline/Timeline.js +321 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/ObjectFactory.js +99 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/TriggerBase.js +49 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/TriggerMng.js +301 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/cocostudio/trigger/TriggerObj.js +263 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/editbox/CCEditBox.js +716 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/editbox/CCdomNode.js +657 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControl.js +381 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlButton.js +688 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlColourPicker.js +187 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlHuePicker.js +218 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlPotentiometer.js +300 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlSaturationBrightnessPicker.js +257 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlSlider.js +308 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlStepper.js +390 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlSwitch.js +425 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCControlUtils.js +177 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCInvocation.js +65 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCMenuPassive.js +415 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCScale9Sprite.js +1099 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCScale9SpriteCanvasRenderCmd.js +142 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/control-extension/CCScale9SpriteWebGLRenderCmd.js +129 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCScrollView.js +827 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCScrollViewCanvasRenderCmd.js +79 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCScrollViewWebGLRenderCmd.js +108 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCSorting.js +239 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/gui/scrollview/CCTableView.js +718 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeleton.js +357 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeletonAnimation.js +340 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeletonCanvasRenderCmd.js +165 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/CCSkeletonWebGLRenderCmd.js +165 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/extensions/spine/Spine.js +2239 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/box2d/box2d.js +10882 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/chipmunk/chipmunk.js +6196 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/pluginx/Plugin.js +254 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/pluginx/platform/facebook.js +557 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/pluginx/platform/facebook_sdk.js +151 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/external/socketio/socket.io.min.js +2 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/jsb_apis.js +618 -0
- data/lib/ccb/builder/templates/project/folder/frameworks/cocos2d-html5/moduleConfig.json +453 -0
- data/lib/ccb/builder/templates/project/folder/project.json +42 -0
- data/lib/ccb/builder/templates/project/folder/res/CloseNormal.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/CloseSelected.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/HelloWorld.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/favicon.ico +0 -0
- data/lib/ccb/builder/templates/project/folder/res/gameOver/cocos2d-html5.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/gameOver/gameOver.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/mainMenu/bg.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/mainMenu/menu.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/setting/menuTitle.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/shared/arial-14.fnt +182 -0
- data/lib/ccb/builder/templates/project/folder/res/shared/arial-14.png +0 -0
- data/lib/ccb/builder/templates/project/folder/res/sound/music/bgMusic.mp3 +0 -0
- data/lib/ccb/builder/templates/project/folder/src/about/layer/ABBackgroundLayer.js +23 -0
- data/lib/ccb/builder/templates/project/folder/src/about/layer/ABTouchLayer.js +51 -0
- data/lib/ccb/builder/templates/project/folder/src/about/scene/About.js +36 -0
- data/lib/ccb/builder/templates/project/folder/src/config/Level.js +7 -0
- data/lib/ccb/builder/templates/project/folder/src/gameOver/layer/GOBackgroundLayer.js +50 -0
- data/lib/ccb/builder/templates/project/folder/src/gameOver/layer/GOTouchLayer.js +51 -0
- data/lib/ccb/builder/templates/project/folder/src/gameOver/scene/GameOver.js +38 -0
- data/lib/ccb/builder/templates/project/folder/src/gamePlay/classes/LevelManager.js +21 -0
- data/lib/ccb/builder/templates/project/folder/src/gamePlay/layer/GPBackgroundLayer.js +25 -0
- data/lib/ccb/builder/templates/project/folder/src/gamePlay/layer/GPTouchLayer.js +51 -0
- data/lib/ccb/builder/templates/project/folder/src/gamePlay/scene/GamePlay.js +44 -0
- data/lib/ccb/builder/templates/project/folder/src/mainMenu/layer/MMBackgroundLayer.js +43 -0
- data/lib/ccb/builder/templates/project/folder/src/mainMenu/layer/MMMainMenuLayer.js +38 -0
- data/lib/ccb/builder/templates/project/folder/src/mainMenu/layer/MMTouchLayer.js +96 -0
- data/lib/ccb/builder/templates/project/folder/src/mainMenu/scene/MainMenu.js +45 -0
- data/lib/ccb/builder/templates/project/folder/src/resource.js +29 -0
- data/lib/ccb/builder/templates/project/folder/src/setting/layer/STBackgroundLayer.js +25 -0
- data/lib/ccb/builder/templates/project/folder/src/setting/layer/STTouchLayer.js +89 -0
- data/lib/ccb/builder/templates/project/folder/src/setting/scene/Setting.js +40 -0
- data/lib/ccb/builder/templates/project/index.html.tt +27 -0
- data/lib/ccb/builder/templates/project/main.js.tt +62 -0
- data/lib/ccb/cli.rb +32 -0
- data/lib/ccb/ext/method_hooker.rb +68 -0
- data/lib/ccb/ext/string_extention.rb +7 -0
- data/lib/ccb.rb +1 -0
- metadata +449 -0
|
@@ -0,0 +1,1245 @@
|
|
|
1
|
+
/****************************************************************************
|
|
2
|
+
Copyright (c) 2008-2010 Ricardo Quesada
|
|
3
|
+
Copyright (c) 2011-2012 cocos2d-x.org
|
|
4
|
+
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
5
|
+
|
|
6
|
+
http://www.cocos2d-x.org
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
****************************************************************************/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @ignore
|
|
29
|
+
*/
|
|
30
|
+
cc.Touches = [];
|
|
31
|
+
cc.TouchesIntergerDict = {};
|
|
32
|
+
|
|
33
|
+
cc.DENSITYDPI_DEVICE = "device-dpi";
|
|
34
|
+
cc.DENSITYDPI_HIGH = "high-dpi";
|
|
35
|
+
cc.DENSITYDPI_MEDIUM = "medium-dpi";
|
|
36
|
+
cc.DENSITYDPI_LOW = "low-dpi";
|
|
37
|
+
|
|
38
|
+
cc.__BrowserGetter = {
|
|
39
|
+
init: function(){
|
|
40
|
+
this.html = document.getElementsByTagName("html")[0];
|
|
41
|
+
},
|
|
42
|
+
availWidth: function(frame){
|
|
43
|
+
if(!frame || frame === this.html)
|
|
44
|
+
return window.innerWidth;
|
|
45
|
+
else
|
|
46
|
+
return frame.clientWidth;
|
|
47
|
+
},
|
|
48
|
+
availHeight: function(frame){
|
|
49
|
+
if(!frame || frame === this.html)
|
|
50
|
+
return window.innerHeight;
|
|
51
|
+
else
|
|
52
|
+
return frame.clientHeight;
|
|
53
|
+
},
|
|
54
|
+
meta: {
|
|
55
|
+
"width": "device-width",
|
|
56
|
+
"user-scalable": "no"
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
switch(cc.sys.browserType){
|
|
61
|
+
case cc.sys.BROWSER_TYPE_SAFARI:
|
|
62
|
+
cc.__BrowserGetter.meta["minimal-ui"] = "true";
|
|
63
|
+
cc.__BrowserGetter.availWidth = function(frame){
|
|
64
|
+
return frame.clientWidth;
|
|
65
|
+
};
|
|
66
|
+
cc.__BrowserGetter.availHeight = function(frame){
|
|
67
|
+
return frame.clientHeight;
|
|
68
|
+
};
|
|
69
|
+
break;
|
|
70
|
+
case cc.sys.BROWSER_TYPE_CHROME:
|
|
71
|
+
cc.__BrowserGetter.__defineGetter__("target-densitydpi", function(){
|
|
72
|
+
return cc.view._targetDensityDPI;
|
|
73
|
+
});
|
|
74
|
+
case cc.sys.BROWSER_TYPE_UC:
|
|
75
|
+
cc.__BrowserGetter.availWidth = function(frame){
|
|
76
|
+
return frame.clientWidth;
|
|
77
|
+
};
|
|
78
|
+
cc.__BrowserGetter.availHeight = function(frame){
|
|
79
|
+
return frame.clientHeight;
|
|
80
|
+
};
|
|
81
|
+
break;
|
|
82
|
+
case cc.sys.BROWSER_TYPE_MIUI:
|
|
83
|
+
cc.__BrowserGetter.init = function(view){
|
|
84
|
+
if(view.__resizeWithBrowserSize) return;
|
|
85
|
+
var resize = function(){
|
|
86
|
+
view.setDesignResolutionSize(
|
|
87
|
+
view._designResolutionSize.width,
|
|
88
|
+
view._designResolutionSize.height,
|
|
89
|
+
view._resolutionPolicy
|
|
90
|
+
);
|
|
91
|
+
window.removeEventListener("resize", resize, false);
|
|
92
|
+
};
|
|
93
|
+
window.addEventListener("resize", resize, false);
|
|
94
|
+
};
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* cc.view is the singleton object which represents the game window.<br/>
|
|
100
|
+
* It's main task include: <br/>
|
|
101
|
+
* - Apply the design resolution policy<br/>
|
|
102
|
+
* - Provide interaction with the window, like resize event on web, retina display support, etc...<br/>
|
|
103
|
+
* - Manage the game view port which can be different with the window<br/>
|
|
104
|
+
* - Manage the content scale and translation<br/>
|
|
105
|
+
* <br/>
|
|
106
|
+
* Since the cc.view is a singleton, you don't need to call any constructor or create functions,<br/>
|
|
107
|
+
* the standard way to use it is by calling:<br/>
|
|
108
|
+
* - cc.view.methodName(); <br/>
|
|
109
|
+
* @class
|
|
110
|
+
* @name cc.view
|
|
111
|
+
* @extend cc.Class
|
|
112
|
+
*/
|
|
113
|
+
cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
|
|
114
|
+
_delegate: null,
|
|
115
|
+
// Size of parent node that contains cc.container and cc._canvas
|
|
116
|
+
_frameSize: null,
|
|
117
|
+
// resolution size, it is the size appropriate for the app resources.
|
|
118
|
+
_designResolutionSize: null,
|
|
119
|
+
_originalDesignResolutionSize: null,
|
|
120
|
+
// Viewport is the container's rect related to content's coordinates in pixel
|
|
121
|
+
_viewPortRect: null,
|
|
122
|
+
// The visible rect in content's coordinate in point
|
|
123
|
+
_visibleRect: null,
|
|
124
|
+
_retinaEnabled: false,
|
|
125
|
+
_autoFullScreen: true,
|
|
126
|
+
// The device's pixel ratio (for retina displays)
|
|
127
|
+
_devicePixelRatio: 1,
|
|
128
|
+
// the view name
|
|
129
|
+
_viewName: "",
|
|
130
|
+
// Custom callback for resize event
|
|
131
|
+
_resizeCallback: null,
|
|
132
|
+
_scaleX: 1,
|
|
133
|
+
_originalScaleX: 1,
|
|
134
|
+
_scaleY: 1,
|
|
135
|
+
_originalScaleY: 1,
|
|
136
|
+
_indexBitsUsed: 0,
|
|
137
|
+
_maxTouches: 5,
|
|
138
|
+
_resolutionPolicy: null,
|
|
139
|
+
_rpExactFit: null,
|
|
140
|
+
_rpShowAll: null,
|
|
141
|
+
_rpNoBorder: null,
|
|
142
|
+
_rpFixedHeight: null,
|
|
143
|
+
_rpFixedWidth: null,
|
|
144
|
+
_initialized: false,
|
|
145
|
+
|
|
146
|
+
_captured: false,
|
|
147
|
+
_wnd: null,
|
|
148
|
+
_hDC: null,
|
|
149
|
+
_hRC: null,
|
|
150
|
+
_supportTouch: false,
|
|
151
|
+
_contentTranslateLeftTop: null,
|
|
152
|
+
|
|
153
|
+
// Parent node that contains cc.container and cc._canvas
|
|
154
|
+
_frame: null,
|
|
155
|
+
_frameZoomFactor: 1.0,
|
|
156
|
+
__resizeWithBrowserSize: false,
|
|
157
|
+
_isAdjustViewPort: true,
|
|
158
|
+
_targetDensityDPI: null,
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Constructor of cc.EGLView
|
|
162
|
+
*/
|
|
163
|
+
ctor: function () {
|
|
164
|
+
var _t = this, d = document, _strategyer = cc.ContainerStrategy, _strategy = cc.ContentStrategy;
|
|
165
|
+
|
|
166
|
+
cc.__BrowserGetter.init(this);
|
|
167
|
+
|
|
168
|
+
_t._frame = (cc.container.parentNode === d.body) ? d.documentElement : cc.container.parentNode;
|
|
169
|
+
_t._frameSize = cc.size(0, 0);
|
|
170
|
+
_t._initFrameSize();
|
|
171
|
+
|
|
172
|
+
var w = cc._canvas.width, h = cc._canvas.height;
|
|
173
|
+
_t._designResolutionSize = cc.size(w, h);
|
|
174
|
+
_t._originalDesignResolutionSize = cc.size(w, h);
|
|
175
|
+
_t._viewPortRect = cc.rect(0, 0, w, h);
|
|
176
|
+
_t._visibleRect = cc.rect(0, 0, w, h);
|
|
177
|
+
_t._contentTranslateLeftTop = {left: 0, top: 0};
|
|
178
|
+
_t._viewName = "Cocos2dHTML5";
|
|
179
|
+
|
|
180
|
+
var sys = cc.sys;
|
|
181
|
+
_t.enableRetina(sys.os == sys.OS_IOS || sys.os == sys.OS_OSX);
|
|
182
|
+
cc.visibleRect && cc.visibleRect.init(_t._visibleRect);
|
|
183
|
+
|
|
184
|
+
// Setup system default resolution policies
|
|
185
|
+
_t._rpExactFit = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.EXACT_FIT);
|
|
186
|
+
_t._rpShowAll = new cc.ResolutionPolicy(_strategyer.PROPORTION_TO_FRAME, _strategy.SHOW_ALL);
|
|
187
|
+
_t._rpNoBorder = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.NO_BORDER);
|
|
188
|
+
_t._rpFixedHeight = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.FIXED_HEIGHT);
|
|
189
|
+
_t._rpFixedWidth = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.FIXED_WIDTH);
|
|
190
|
+
|
|
191
|
+
_t._hDC = cc._canvas;
|
|
192
|
+
_t._hRC = cc._renderContext;
|
|
193
|
+
_t._targetDensityDPI = cc.DENSITYDPI_HIGH;
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
// Resize helper functions
|
|
197
|
+
_resizeEvent: function () {
|
|
198
|
+
var view;
|
|
199
|
+
if(this.setDesignResolutionSize){
|
|
200
|
+
view = this;
|
|
201
|
+
}else{
|
|
202
|
+
view = cc.view;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Check frame size changed or not
|
|
206
|
+
var prevFrameW = view._frameSize.width, prevFrameH = view._frameSize.height;
|
|
207
|
+
view._initFrameSize();
|
|
208
|
+
if (view._frameSize.width == prevFrameW && view._frameSize.height == prevFrameH)
|
|
209
|
+
return;
|
|
210
|
+
|
|
211
|
+
// Frame size changed, do resize works
|
|
212
|
+
if (view._resizeCallback) {
|
|
213
|
+
view._resizeCallback.call();
|
|
214
|
+
}
|
|
215
|
+
var width = view._originalDesignResolutionSize.width;
|
|
216
|
+
var height = view._originalDesignResolutionSize.height;
|
|
217
|
+
if (width > 0)
|
|
218
|
+
view.setDesignResolutionSize(width, height, view._resolutionPolicy);
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* <p>
|
|
223
|
+
* Sets view's target-densitydpi for android mobile browser. it can be set to: <br/>
|
|
224
|
+
* 1. cc.DENSITYDPI_DEVICE, value is "device-dpi" <br/>
|
|
225
|
+
* 2. cc.DENSITYDPI_HIGH, value is "high-dpi" (default value) <br/>
|
|
226
|
+
* 3. cc.DENSITYDPI_MEDIUM, value is "medium-dpi" (browser's default value) <br/>
|
|
227
|
+
* 4. cc.DENSITYDPI_LOW, value is "low-dpi" <br/>
|
|
228
|
+
* 5. Custom value, e.g: "480" <br/>
|
|
229
|
+
* </p>
|
|
230
|
+
* @param {String} densityDPI
|
|
231
|
+
*/
|
|
232
|
+
setTargetDensityDPI: function(densityDPI){
|
|
233
|
+
this._targetDensityDPI = densityDPI;
|
|
234
|
+
this._setViewPortMeta();
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Returns the current target-densitydpi value of cc.view.
|
|
239
|
+
* @returns {String}
|
|
240
|
+
*/
|
|
241
|
+
getTargetDensityDPI: function(){
|
|
242
|
+
return this._targetDensityDPI;
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Sets whether resize canvas automatically when browser's size changed.<br/>
|
|
247
|
+
* Useful only on web.
|
|
248
|
+
* @param {Boolean} enabled Whether enable automatic resize with browser's resize event
|
|
249
|
+
*/
|
|
250
|
+
resizeWithBrowserSize: function (enabled) {
|
|
251
|
+
if (enabled) {
|
|
252
|
+
//enable
|
|
253
|
+
if (!this.__resizeWithBrowserSize) {
|
|
254
|
+
this.__resizeWithBrowserSize = true;
|
|
255
|
+
cc._addEventListener(window, 'resize', this._resizeEvent);
|
|
256
|
+
cc._addEventListener(window, 'orientationchange', this._resizeEvent);
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
//disable
|
|
260
|
+
if (this.__resizeWithBrowserSize) {
|
|
261
|
+
this.__resizeWithBrowserSize = false;
|
|
262
|
+
window.removeEventListener('resize', this._resizeEvent);
|
|
263
|
+
window.removeEventListener('orientationchange', this._resizeEvent);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Sets the callback function for cc.view's resize action,<br/>
|
|
270
|
+
* this callback will be invoked before applying resolution policy, <br/>
|
|
271
|
+
* so you can do any additional modifications within the callback.<br/>
|
|
272
|
+
* Useful only on web.
|
|
273
|
+
* @param {Function|null} callback The callback function
|
|
274
|
+
*/
|
|
275
|
+
setResizeCallback: function (callback) {
|
|
276
|
+
if (cc.isFunction(callback) || callback == null) {
|
|
277
|
+
this._resizeCallback = callback;
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
_initFrameSize: function () {
|
|
282
|
+
var locFrameSize = this._frameSize;
|
|
283
|
+
locFrameSize.width = cc.__BrowserGetter.availWidth(this._frame);
|
|
284
|
+
locFrameSize.height = cc.__BrowserGetter.availHeight(this._frame);
|
|
285
|
+
},
|
|
286
|
+
|
|
287
|
+
// hack
|
|
288
|
+
_adjustSizeKeepCanvasSize: function () {
|
|
289
|
+
var designWidth = this._originalDesignResolutionSize.width;
|
|
290
|
+
var designHeight = this._originalDesignResolutionSize.height;
|
|
291
|
+
if (designWidth > 0)
|
|
292
|
+
this.setDesignResolutionSize(designWidth, designHeight, this._resolutionPolicy);
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
_setViewPortMeta: function () {
|
|
296
|
+
if (this._isAdjustViewPort) {
|
|
297
|
+
var vp = document.getElementById("cocosMetaElement");
|
|
298
|
+
if(vp){
|
|
299
|
+
document.head.removeChild(vp);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
var viewportMetas,
|
|
303
|
+
elems = document.getElementsByName("viewport"),
|
|
304
|
+
currentVP = elems ? elems[0] : null,
|
|
305
|
+
content;
|
|
306
|
+
|
|
307
|
+
vp = cc.newElement("meta");
|
|
308
|
+
vp.id = "cocosMetaElement";
|
|
309
|
+
vp.name = "viewport";
|
|
310
|
+
vp.content = "";
|
|
311
|
+
|
|
312
|
+
viewportMetas = cc.__BrowserGetter.meta;
|
|
313
|
+
|
|
314
|
+
content = currentVP ? currentVP.content : "";
|
|
315
|
+
for (var key in viewportMetas) {
|
|
316
|
+
var pattern = new RegExp(key);
|
|
317
|
+
if (!pattern.test(content)) {
|
|
318
|
+
content += "," + key + "=" + viewportMetas[key];
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if(/^,/.test(content))
|
|
322
|
+
content = content.substr(1);
|
|
323
|
+
|
|
324
|
+
vp.content = content;
|
|
325
|
+
// For adopting certain android devices which don't support second viewport
|
|
326
|
+
if (currentVP)
|
|
327
|
+
currentVP.content = content;
|
|
328
|
+
|
|
329
|
+
document.head.appendChild(vp);
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
// RenderTexture hacker
|
|
334
|
+
_setScaleXYForRenderTexture: function () {
|
|
335
|
+
//hack for RenderTexture on canvas mode when adapting multiple resolution resources
|
|
336
|
+
var scaleFactor = cc.contentScaleFactor();
|
|
337
|
+
this._scaleX = scaleFactor;
|
|
338
|
+
this._scaleY = scaleFactor;
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
// Other helper functions
|
|
342
|
+
_resetScale: function () {
|
|
343
|
+
this._scaleX = this._originalScaleX;
|
|
344
|
+
this._scaleY = this._originalScaleY;
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
// Useless, just make sure the compatibility temporarily, should be removed
|
|
348
|
+
_adjustSizeToBrowser: function () {
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
initialize: function () {
|
|
352
|
+
this._initialized = true;
|
|
353
|
+
},
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Sets whether the engine modify the "viewport" meta in your web page.<br/>
|
|
357
|
+
* It's enabled by default, we strongly suggest you not to disable it.<br/>
|
|
358
|
+
* And even when it's enabled, you can still set your own "viewport" meta, it won't be overridden<br/>
|
|
359
|
+
* Only useful on web
|
|
360
|
+
* @param {Boolean} enabled Enable automatic modification to "viewport" meta
|
|
361
|
+
*/
|
|
362
|
+
adjustViewPort: function (enabled) {
|
|
363
|
+
this._isAdjustViewPort = enabled;
|
|
364
|
+
},
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Retina support is enabled by default for Apple device but disabled for other devices,<br/>
|
|
368
|
+
* it takes effect only when you called setDesignResolutionPolicy<br/>
|
|
369
|
+
* Only useful on web
|
|
370
|
+
* @param {Boolean} enabled Enable or disable retina display
|
|
371
|
+
*/
|
|
372
|
+
enableRetina: function(enabled) {
|
|
373
|
+
this._retinaEnabled = enabled ? true : false;
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Check whether retina display is enabled.<br/>
|
|
378
|
+
* Only useful on web
|
|
379
|
+
* @return {Boolean}
|
|
380
|
+
*/
|
|
381
|
+
isRetinaEnabled: function() {
|
|
382
|
+
return this._retinaEnabled;
|
|
383
|
+
},
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* If enabled, the application will try automatically to enter full screen mode on mobile devices<br/>
|
|
387
|
+
* You can pass true as parameter to enable it and disable it by passing false.<br/>
|
|
388
|
+
* Only useful on web
|
|
389
|
+
* @param {Boolean} enabled Enable or disable auto full screen on mobile devices
|
|
390
|
+
*/
|
|
391
|
+
enableAutoFullScreen: function(enabled) {
|
|
392
|
+
this._autoFullScreen = enabled ? true : false;
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Check whether auto full screen is enabled.<br/>
|
|
397
|
+
* Only useful on web
|
|
398
|
+
* @return {Boolean} Auto full screen enabled or not
|
|
399
|
+
*/
|
|
400
|
+
isAutoFullScreenEnabled: function() {
|
|
401
|
+
return this._autoFullScreen;
|
|
402
|
+
},
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Force destroying EGL view, subclass must implement this method.
|
|
406
|
+
*/
|
|
407
|
+
end: function () {
|
|
408
|
+
},
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Get whether render system is ready(no matter opengl or canvas),<br/>
|
|
412
|
+
* this name is for the compatibility with cocos2d-x, subclass must implement this method.
|
|
413
|
+
* @return {Boolean}
|
|
414
|
+
*/
|
|
415
|
+
isOpenGLReady: function () {
|
|
416
|
+
return (this._hDC != null && this._hRC != null);
|
|
417
|
+
},
|
|
418
|
+
|
|
419
|
+
/*
|
|
420
|
+
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
|
421
|
+
* @param {Number} zoomFactor
|
|
422
|
+
*/
|
|
423
|
+
setFrameZoomFactor: function (zoomFactor) {
|
|
424
|
+
this._frameZoomFactor = zoomFactor;
|
|
425
|
+
this.centerWindow();
|
|
426
|
+
cc.director.setProjection(cc.director.getProjection());
|
|
427
|
+
},
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Exchanges the front and back buffers, subclass must implement this method.
|
|
431
|
+
*/
|
|
432
|
+
swapBuffers: function () {
|
|
433
|
+
},
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Open or close IME keyboard , subclass must implement this method.
|
|
437
|
+
* @param {Boolean} isOpen
|
|
438
|
+
*/
|
|
439
|
+
setIMEKeyboardState: function (isOpen) {
|
|
440
|
+
},
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Sets the resolution translate on EGLView
|
|
444
|
+
* @param {Number} offsetLeft
|
|
445
|
+
* @param {Number} offsetTop
|
|
446
|
+
*/
|
|
447
|
+
setContentTranslateLeftTop: function (offsetLeft, offsetTop) {
|
|
448
|
+
this._contentTranslateLeftTop = {left: offsetLeft, top: offsetTop};
|
|
449
|
+
},
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Returns the resolution translate on EGLView
|
|
453
|
+
* @return {cc.Size|Object}
|
|
454
|
+
*/
|
|
455
|
+
getContentTranslateLeftTop: function () {
|
|
456
|
+
return this._contentTranslateLeftTop;
|
|
457
|
+
},
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Returns the frame size of the view.<br/>
|
|
461
|
+
* On native platforms, it returns the screen size since the view is a fullscreen view.<br/>
|
|
462
|
+
* On web, it returns the size of the canvas's outer DOM element.
|
|
463
|
+
* @return {cc.Size}
|
|
464
|
+
*/
|
|
465
|
+
getFrameSize: function () {
|
|
466
|
+
return cc.size(this._frameSize.width, this._frameSize.height);
|
|
467
|
+
},
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* On native, it sets the frame size of view.<br/>
|
|
471
|
+
* On web, it sets the size of the canvas's outer DOM element.
|
|
472
|
+
* @param {Number} width
|
|
473
|
+
* @param {Number} height
|
|
474
|
+
*/
|
|
475
|
+
setFrameSize: function (width, height) {
|
|
476
|
+
this._frameSize.width = width;
|
|
477
|
+
this._frameSize.height = height;
|
|
478
|
+
this._frame.style.width = width + "px";
|
|
479
|
+
this._frame.style.height = height + "px";
|
|
480
|
+
//this.centerWindow();
|
|
481
|
+
this._resizeEvent();
|
|
482
|
+
cc.director.setProjection(cc.director.getProjection());
|
|
483
|
+
},
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Empty function
|
|
487
|
+
*/
|
|
488
|
+
centerWindow: function () {
|
|
489
|
+
},
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Returns the visible area size of the view port.
|
|
493
|
+
* @return {cc.Size}
|
|
494
|
+
*/
|
|
495
|
+
getVisibleSize: function () {
|
|
496
|
+
return cc.size(this._visibleRect.width,this._visibleRect.height);
|
|
497
|
+
},
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Returns the visible origin of the view port.
|
|
501
|
+
* @return {cc.Point}
|
|
502
|
+
*/
|
|
503
|
+
getVisibleOrigin: function () {
|
|
504
|
+
return cc.p(this._visibleRect.x,this._visibleRect.y);
|
|
505
|
+
},
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Returns whether developer can set content's scale factor.
|
|
509
|
+
* @return {Boolean}
|
|
510
|
+
*/
|
|
511
|
+
canSetContentScaleFactor: function () {
|
|
512
|
+
return true;
|
|
513
|
+
},
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Returns the current resolution policy
|
|
517
|
+
* @see cc.ResolutionPolicy
|
|
518
|
+
* @return {cc.ResolutionPolicy}
|
|
519
|
+
*/
|
|
520
|
+
getResolutionPolicy: function () {
|
|
521
|
+
return this._resolutionPolicy;
|
|
522
|
+
},
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Sets the current resolution policy
|
|
526
|
+
* @see cc.ResolutionPolicy
|
|
527
|
+
* @param {cc.ResolutionPolicy|Number} resolutionPolicy
|
|
528
|
+
*/
|
|
529
|
+
setResolutionPolicy: function (resolutionPolicy) {
|
|
530
|
+
var _t = this;
|
|
531
|
+
if (resolutionPolicy instanceof cc.ResolutionPolicy) {
|
|
532
|
+
_t._resolutionPolicy = resolutionPolicy;
|
|
533
|
+
}
|
|
534
|
+
// Ensure compatibility with JSB
|
|
535
|
+
else {
|
|
536
|
+
var _locPolicy = cc.ResolutionPolicy;
|
|
537
|
+
if(resolutionPolicy === _locPolicy.EXACT_FIT)
|
|
538
|
+
_t._resolutionPolicy = _t._rpExactFit;
|
|
539
|
+
if(resolutionPolicy === _locPolicy.SHOW_ALL)
|
|
540
|
+
_t._resolutionPolicy = _t._rpShowAll;
|
|
541
|
+
if(resolutionPolicy === _locPolicy.NO_BORDER)
|
|
542
|
+
_t._resolutionPolicy = _t._rpNoBorder;
|
|
543
|
+
if(resolutionPolicy === _locPolicy.FIXED_HEIGHT)
|
|
544
|
+
_t._resolutionPolicy = _t._rpFixedHeight;
|
|
545
|
+
if(resolutionPolicy === _locPolicy.FIXED_WIDTH)
|
|
546
|
+
_t._resolutionPolicy = _t._rpFixedWidth;
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Sets the resolution policy with designed view size in points.<br/>
|
|
552
|
+
* The resolution policy include: <br/>
|
|
553
|
+
* [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.<br/>
|
|
554
|
+
* [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.<br/>
|
|
555
|
+
* [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.<br/>
|
|
556
|
+
* [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width<br/>
|
|
557
|
+
* [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height<br/>
|
|
558
|
+
* [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy<br/>
|
|
559
|
+
* @param {Number} width Design resolution width.
|
|
560
|
+
* @param {Number} height Design resolution height.
|
|
561
|
+
* @param {cc.ResolutionPolicy|Number} resolutionPolicy The resolution policy desired
|
|
562
|
+
*/
|
|
563
|
+
setDesignResolutionSize: function (width, height, resolutionPolicy) {
|
|
564
|
+
// Defensive code
|
|
565
|
+
if( !(width > 0 || height > 0) ){
|
|
566
|
+
cc.log(cc._LogInfos.EGLView_setDesignResolutionSize);
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
this.setResolutionPolicy(resolutionPolicy);
|
|
571
|
+
var policy = this._resolutionPolicy;
|
|
572
|
+
if (!policy){
|
|
573
|
+
cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2);
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
policy.preApply(this);
|
|
577
|
+
|
|
578
|
+
// Reinit frame size
|
|
579
|
+
if(cc.sys.isMobile)
|
|
580
|
+
this._setViewPortMeta();
|
|
581
|
+
|
|
582
|
+
this._initFrameSize();
|
|
583
|
+
|
|
584
|
+
this._originalDesignResolutionSize.width = this._designResolutionSize.width = width;
|
|
585
|
+
this._originalDesignResolutionSize.height = this._designResolutionSize.height = height;
|
|
586
|
+
|
|
587
|
+
var result = policy.apply(this, this._designResolutionSize);
|
|
588
|
+
|
|
589
|
+
if(result.scale && result.scale.length == 2){
|
|
590
|
+
this._scaleX = result.scale[0];
|
|
591
|
+
this._scaleY = result.scale[1];
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if(result.viewport){
|
|
595
|
+
var vp = this._viewPortRect,
|
|
596
|
+
vb = this._visibleRect,
|
|
597
|
+
rv = result.viewport;
|
|
598
|
+
|
|
599
|
+
vp.x = rv.x;
|
|
600
|
+
vp.y = rv.y;
|
|
601
|
+
vp.width = rv.width;
|
|
602
|
+
vp.height = rv.height;
|
|
603
|
+
|
|
604
|
+
vb.x = -vp.x / this._scaleX;
|
|
605
|
+
vb.y = -vp.y / this._scaleY;
|
|
606
|
+
vb.width = cc._canvas.width / this._scaleX;
|
|
607
|
+
vb.height = cc._canvas.height / this._scaleY;
|
|
608
|
+
cc._renderContext.setOffset && cc._renderContext.setOffset(vp.x, -vp.y)
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// reset director's member variables to fit visible rect
|
|
612
|
+
var director = cc.director;
|
|
613
|
+
director._winSizeInPoints.width = this._designResolutionSize.width;
|
|
614
|
+
director._winSizeInPoints.height = this._designResolutionSize.height;
|
|
615
|
+
policy.postApply(this);
|
|
616
|
+
cc.winSize.width = director._winSizeInPoints.width;
|
|
617
|
+
cc.winSize.height = director._winSizeInPoints.height;
|
|
618
|
+
|
|
619
|
+
if (cc._renderType == cc._RENDER_TYPE_WEBGL) {
|
|
620
|
+
// reset director's member variables to fit visible rect
|
|
621
|
+
director._createStatsLabel();
|
|
622
|
+
director.setGLDefaultValues();
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
this._originalScaleX = this._scaleX;
|
|
626
|
+
this._originalScaleY = this._scaleY;
|
|
627
|
+
// For editbox
|
|
628
|
+
if (cc.DOM)
|
|
629
|
+
cc.DOM._resetEGLViewDiv();
|
|
630
|
+
cc.visibleRect && cc.visibleRect.init(this._visibleRect);
|
|
631
|
+
},
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Returns the designed size for the view.
|
|
635
|
+
* Default resolution size is the same as 'getFrameSize'.
|
|
636
|
+
* @return {cc.Size}
|
|
637
|
+
*/
|
|
638
|
+
getDesignResolutionSize: function () {
|
|
639
|
+
return cc.size(this._designResolutionSize.width, this._designResolutionSize.height);
|
|
640
|
+
},
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Sets view port rectangle with points.
|
|
644
|
+
* @param {Number} x
|
|
645
|
+
* @param {Number} y
|
|
646
|
+
* @param {Number} w width
|
|
647
|
+
* @param {Number} h height
|
|
648
|
+
*/
|
|
649
|
+
setViewPortInPoints: function (x, y, w, h) {
|
|
650
|
+
var locFrameZoomFactor = this._frameZoomFactor, locScaleX = this._scaleX, locScaleY = this._scaleY;
|
|
651
|
+
cc._renderContext.viewport((x * locScaleX * locFrameZoomFactor + this._viewPortRect.x * locFrameZoomFactor),
|
|
652
|
+
(y * locScaleY * locFrameZoomFactor + this._viewPortRect.y * locFrameZoomFactor),
|
|
653
|
+
(w * locScaleX * locFrameZoomFactor),
|
|
654
|
+
(h * locScaleY * locFrameZoomFactor));
|
|
655
|
+
},
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Sets Scissor rectangle with points.
|
|
659
|
+
* @param {Number} x
|
|
660
|
+
* @param {Number} y
|
|
661
|
+
* @param {Number} w
|
|
662
|
+
* @param {Number} h
|
|
663
|
+
*/
|
|
664
|
+
setScissorInPoints: function (x, y, w, h) {
|
|
665
|
+
var locFrameZoomFactor = this._frameZoomFactor, locScaleX = this._scaleX, locScaleY = this._scaleY;
|
|
666
|
+
cc._renderContext.scissor((x * locScaleX * locFrameZoomFactor + this._viewPortRect.x * locFrameZoomFactor),
|
|
667
|
+
(y * locScaleY * locFrameZoomFactor + this._viewPortRect.y * locFrameZoomFactor),
|
|
668
|
+
(w * locScaleX * locFrameZoomFactor),
|
|
669
|
+
(h * locScaleY * locFrameZoomFactor));
|
|
670
|
+
},
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Returns whether GL_SCISSOR_TEST is enable
|
|
674
|
+
* @return {Boolean}
|
|
675
|
+
*/
|
|
676
|
+
isScissorEnabled: function () {
|
|
677
|
+
var gl = cc._renderContext;
|
|
678
|
+
return gl.isEnabled(gl.SCISSOR_TEST);
|
|
679
|
+
},
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Returns the current scissor rectangle
|
|
683
|
+
* @return {cc.Rect}
|
|
684
|
+
*/
|
|
685
|
+
getScissorRect: function () {
|
|
686
|
+
var gl = cc._renderContext, scaleX = this._scaleX, scaleY = this._scaleY;
|
|
687
|
+
var boxArr = gl.getParameter(gl.SCISSOR_BOX);
|
|
688
|
+
return cc.rect((boxArr[0] - this._viewPortRect.x) / scaleX, (boxArr[1] - this._viewPortRect.y) / scaleY,
|
|
689
|
+
boxArr[2] / scaleX, boxArr[3] / scaleY);
|
|
690
|
+
},
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Sets the name of the view
|
|
694
|
+
* @param {String} viewName
|
|
695
|
+
*/
|
|
696
|
+
setViewName: function (viewName) {
|
|
697
|
+
if (viewName != null && viewName.length > 0) {
|
|
698
|
+
this._viewName = viewName;
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Returns the name of the view
|
|
704
|
+
* @return {String}
|
|
705
|
+
*/
|
|
706
|
+
getViewName: function () {
|
|
707
|
+
return this._viewName;
|
|
708
|
+
},
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Returns the view port rectangle.
|
|
712
|
+
* @return {cc.Rect}
|
|
713
|
+
*/
|
|
714
|
+
getViewPortRect: function () {
|
|
715
|
+
return this._viewPortRect;
|
|
716
|
+
},
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Returns scale factor of the horizontal direction (X axis).
|
|
720
|
+
* @return {Number}
|
|
721
|
+
*/
|
|
722
|
+
getScaleX: function () {
|
|
723
|
+
return this._scaleX;
|
|
724
|
+
},
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Returns scale factor of the vertical direction (Y axis).
|
|
728
|
+
* @return {Number}
|
|
729
|
+
*/
|
|
730
|
+
getScaleY: function () {
|
|
731
|
+
return this._scaleY;
|
|
732
|
+
},
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Returns device pixel ratio for retina display.
|
|
736
|
+
* @return {Number}
|
|
737
|
+
*/
|
|
738
|
+
getDevicePixelRatio: function() {
|
|
739
|
+
return this._devicePixelRatio;
|
|
740
|
+
},
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Returns the real location in view for a translation based on a related position
|
|
744
|
+
* @param {Number} tx The X axis translation
|
|
745
|
+
* @param {Number} ty The Y axis translation
|
|
746
|
+
* @param {Object} relatedPos The related position object including "left", "top", "width", "height" informations
|
|
747
|
+
* @return {cc.Point}
|
|
748
|
+
*/
|
|
749
|
+
convertToLocationInView: function (tx, ty, relatedPos) {
|
|
750
|
+
return {x: this._devicePixelRatio * (tx - relatedPos.left), y: this._devicePixelRatio * (relatedPos.top + relatedPos.height - ty)};
|
|
751
|
+
},
|
|
752
|
+
|
|
753
|
+
_convertMouseToLocationInView: function(point, relatedPos) {
|
|
754
|
+
var locViewPortRect = this._viewPortRect, _t = this;
|
|
755
|
+
point.x = ((_t._devicePixelRatio * (point.x - relatedPos.left)) - locViewPortRect.x) / _t._scaleX;
|
|
756
|
+
point.y = (_t._devicePixelRatio * (relatedPos.top + relatedPos.height - point.y) - locViewPortRect.y) / _t._scaleY;
|
|
757
|
+
},
|
|
758
|
+
|
|
759
|
+
_convertTouchesWithScale: function(touches){
|
|
760
|
+
var locViewPortRect = this._viewPortRect, locScaleX = this._scaleX, locScaleY = this._scaleY, selTouch, selPoint, selPrePoint;
|
|
761
|
+
for( var i = 0; i < touches.length; i ++){
|
|
762
|
+
selTouch = touches[i];
|
|
763
|
+
selPoint = selTouch._point;
|
|
764
|
+
selPrePoint = selTouch._prevPoint;
|
|
765
|
+
selTouch._setPoint((selPoint.x - locViewPortRect.x) / locScaleX,
|
|
766
|
+
(selPoint.y - locViewPortRect.y) / locScaleY);
|
|
767
|
+
selTouch._setPrevPoint((selPrePoint.x - locViewPortRect.x) / locScaleX,
|
|
768
|
+
(selPrePoint.y - locViewPortRect.y) / locScaleY);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* @function
|
|
775
|
+
* @return {cc.EGLView}
|
|
776
|
+
* @private
|
|
777
|
+
*/
|
|
778
|
+
cc.EGLView._getInstance = function () {
|
|
779
|
+
if (!this._instance) {
|
|
780
|
+
this._instance = this._instance || new cc.EGLView();
|
|
781
|
+
this._instance.initialize();
|
|
782
|
+
}
|
|
783
|
+
return this._instance;
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* <p>cc.ContainerStrategy class is the root strategy class of container's scale strategy,
|
|
788
|
+
* it controls the behavior of how to scale the cc.container and cc._canvas object</p>
|
|
789
|
+
*
|
|
790
|
+
* @class
|
|
791
|
+
* @extends cc.Class
|
|
792
|
+
*/
|
|
793
|
+
cc.ContainerStrategy = cc.Class.extend(/** @lends cc.ContainerStrategy# */{
|
|
794
|
+
/**
|
|
795
|
+
* Manipulation before appling the strategy
|
|
796
|
+
* @param {cc.view} The target view
|
|
797
|
+
*/
|
|
798
|
+
preApply: function (view) {
|
|
799
|
+
},
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Function to apply this strategy
|
|
803
|
+
* @param {cc.view} view
|
|
804
|
+
* @param {cc.Size} designedResolution
|
|
805
|
+
*/
|
|
806
|
+
apply: function (view, designedResolution) {
|
|
807
|
+
},
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Manipulation after applying the strategy
|
|
811
|
+
* @param {cc.view} view The target view
|
|
812
|
+
*/
|
|
813
|
+
postApply: function (view) {
|
|
814
|
+
|
|
815
|
+
},
|
|
816
|
+
|
|
817
|
+
_setupContainer: function (view, w, h) {
|
|
818
|
+
var frame = view._frame;
|
|
819
|
+
if (cc.view._autoFullScreen && cc.sys.isMobile && frame == document.documentElement) {
|
|
820
|
+
// Automatically full screen when user touches on mobile version
|
|
821
|
+
cc.screen.autoFullScreen(frame);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
var locCanvasElement = cc._canvas, locContainer = cc.container;
|
|
825
|
+
// Setup container
|
|
826
|
+
locContainer.style.width = locCanvasElement.style.width = w + "px";
|
|
827
|
+
locContainer.style.height = locCanvasElement.style.height = h + "px";
|
|
828
|
+
// Setup pixel ratio for retina display
|
|
829
|
+
var devicePixelRatio = view._devicePixelRatio = 1;
|
|
830
|
+
if (view.isRetinaEnabled())
|
|
831
|
+
devicePixelRatio = view._devicePixelRatio = window.devicePixelRatio || 1;
|
|
832
|
+
// Setup canvas
|
|
833
|
+
locCanvasElement.width = w * devicePixelRatio;
|
|
834
|
+
locCanvasElement.height = h * devicePixelRatio;
|
|
835
|
+
cc._renderContext.resetCache && cc._renderContext.resetCache();
|
|
836
|
+
|
|
837
|
+
var body = document.body, style;
|
|
838
|
+
if (body && (style = body.style)) {
|
|
839
|
+
style.paddingTop = style.paddingTop || "0px";
|
|
840
|
+
style.paddingRight = style.paddingRight || "0px";
|
|
841
|
+
style.paddingBottom = style.paddingBottom || "0px";
|
|
842
|
+
style.paddingLeft = style.paddingLeft || "0px";
|
|
843
|
+
style.borderTop = style.borderTop || "0px";
|
|
844
|
+
style.borderRight = style.borderRight || "0px";
|
|
845
|
+
style.borderBottom = style.borderBottom || "0px";
|
|
846
|
+
style.borderLeft = style.borderLeft || "0px";
|
|
847
|
+
style.marginTop = style.marginTop || "0px";
|
|
848
|
+
style.marginRight = style.marginRight || "0px";
|
|
849
|
+
style.marginBottom = style.marginBottom || "0px";
|
|
850
|
+
style.marginLeft = style.marginLeft || "0px";
|
|
851
|
+
}
|
|
852
|
+
},
|
|
853
|
+
|
|
854
|
+
_fixContainer: function () {
|
|
855
|
+
// Add container to document body
|
|
856
|
+
document.body.insertBefore(cc.container, document.body.firstChild);
|
|
857
|
+
// Set body's width height to window's size, and forbid overflow, so that game will be centered
|
|
858
|
+
var bs = document.body.style;
|
|
859
|
+
bs.width = window.innerWidth + "px";
|
|
860
|
+
bs.height = window.innerHeight + "px";
|
|
861
|
+
bs.overflow = "hidden";
|
|
862
|
+
// Body size solution doesn't work on all mobile browser so this is the aleternative: fixed container
|
|
863
|
+
var contStyle = cc.container.style;
|
|
864
|
+
contStyle.position = "fixed";
|
|
865
|
+
contStyle.left = contStyle.top = "0px";
|
|
866
|
+
// Reposition body
|
|
867
|
+
document.body.scrollTop = 0;
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* <p>cc.ContentStrategy class is the root strategy class of content's scale strategy,
|
|
873
|
+
* it controls the behavior of how to scale the scene and setup the viewport for the game</p>
|
|
874
|
+
*
|
|
875
|
+
* @class
|
|
876
|
+
* @extends cc.Class
|
|
877
|
+
*/
|
|
878
|
+
cc.ContentStrategy = cc.Class.extend(/** @lends cc.ContentStrategy# */{
|
|
879
|
+
|
|
880
|
+
_result: {
|
|
881
|
+
scale: [1, 1],
|
|
882
|
+
viewport: null
|
|
883
|
+
},
|
|
884
|
+
|
|
885
|
+
_buildResult: function (containerW, containerH, contentW, contentH, scaleX, scaleY) {
|
|
886
|
+
// Makes content fit better the canvas
|
|
887
|
+
Math.abs(containerW - contentW) < 2 && (contentW = containerW);
|
|
888
|
+
Math.abs(containerH - contentH) < 2 && (contentH = containerH);
|
|
889
|
+
|
|
890
|
+
var viewport = cc.rect(Math.round((containerW - contentW) / 2),
|
|
891
|
+
Math.round((containerH - contentH) / 2),
|
|
892
|
+
contentW, contentH);
|
|
893
|
+
|
|
894
|
+
// Translate the content
|
|
895
|
+
if (cc._renderType == cc._RENDER_TYPE_CANVAS){
|
|
896
|
+
//TODO: modify something for setTransform
|
|
897
|
+
//cc._renderContext.translate(viewport.x, viewport.y + contentH);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
this._result.scale = [scaleX, scaleY];
|
|
901
|
+
this._result.viewport = viewport;
|
|
902
|
+
return this._result;
|
|
903
|
+
},
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Manipulation before applying the strategy
|
|
907
|
+
* @param {cc.view} view The target view
|
|
908
|
+
*/
|
|
909
|
+
preApply: function (view) {
|
|
910
|
+
},
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* Function to apply this strategy
|
|
914
|
+
* The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
|
|
915
|
+
* The target view can then apply these value to itself, it's preferred not to modify directly its private variables
|
|
916
|
+
* @param {cc.view} view
|
|
917
|
+
* @param {cc.Size} designedResolution
|
|
918
|
+
* @return {object} scaleAndViewportRect
|
|
919
|
+
*/
|
|
920
|
+
apply: function (view, designedResolution) {
|
|
921
|
+
return {"scale": [1, 1]};
|
|
922
|
+
},
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Manipulation after applying the strategy
|
|
926
|
+
* @param {cc.view} view The target view
|
|
927
|
+
*/
|
|
928
|
+
postApply: function (view) {
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
|
|
932
|
+
(function () {
|
|
933
|
+
|
|
934
|
+
// Container scale strategys
|
|
935
|
+
/**
|
|
936
|
+
* @class
|
|
937
|
+
* @extends cc.ContainerStrategy
|
|
938
|
+
*/
|
|
939
|
+
var EqualToFrame = cc.ContainerStrategy.extend({
|
|
940
|
+
apply: function (view) {
|
|
941
|
+
this._setupContainer(view, view._frameSize.width, view._frameSize.height);
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* @class
|
|
947
|
+
* @extends cc.ContainerStrategy
|
|
948
|
+
*/
|
|
949
|
+
var ProportionalToFrame = cc.ContainerStrategy.extend({
|
|
950
|
+
apply: function (view, designedResolution) {
|
|
951
|
+
var frameW = view._frameSize.width, frameH = view._frameSize.height, containerStyle = cc.container.style,
|
|
952
|
+
designW = designedResolution.width, designH = designedResolution.height,
|
|
953
|
+
scaleX = frameW / designW, scaleY = frameH / designH,
|
|
954
|
+
containerW, containerH;
|
|
955
|
+
|
|
956
|
+
scaleX < scaleY ? (containerW = frameW, containerH = designH * scaleX) : (containerW = designW * scaleY, containerH = frameH);
|
|
957
|
+
|
|
958
|
+
// Adjust container size with integer value
|
|
959
|
+
var offx = Math.round((frameW - containerW) / 2);
|
|
960
|
+
var offy = Math.round((frameH - containerH) / 2);
|
|
961
|
+
containerW = frameW - 2 * offx;
|
|
962
|
+
containerH = frameH - 2 * offy;
|
|
963
|
+
|
|
964
|
+
this._setupContainer(view, containerW, containerH);
|
|
965
|
+
// Setup container's margin
|
|
966
|
+
containerStyle.marginLeft = offx + "px";
|
|
967
|
+
containerStyle.marginRight = offx + "px";
|
|
968
|
+
containerStyle.marginTop = offy + "px";
|
|
969
|
+
containerStyle.marginBottom = offy + "px";
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* @class
|
|
975
|
+
* @extends EqualToFrame
|
|
976
|
+
*/
|
|
977
|
+
var EqualToWindow = EqualToFrame.extend({
|
|
978
|
+
preApply: function (view) {
|
|
979
|
+
this._super(view);
|
|
980
|
+
view._frame = document.documentElement;
|
|
981
|
+
},
|
|
982
|
+
|
|
983
|
+
apply: function (view) {
|
|
984
|
+
this._super(view);
|
|
985
|
+
this._fixContainer();
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* @class
|
|
991
|
+
* @extends ProportionalToFrame
|
|
992
|
+
*/
|
|
993
|
+
var ProportionalToWindow = ProportionalToFrame.extend({
|
|
994
|
+
preApply: function (view) {
|
|
995
|
+
this._super(view);
|
|
996
|
+
view._frame = document.documentElement;
|
|
997
|
+
},
|
|
998
|
+
|
|
999
|
+
apply: function (view, designedResolution) {
|
|
1000
|
+
this._super(view, designedResolution);
|
|
1001
|
+
this._fixContainer();
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* @class
|
|
1007
|
+
* @extends cc.ContainerStrategy
|
|
1008
|
+
*/
|
|
1009
|
+
var OriginalContainer = cc.ContainerStrategy.extend({
|
|
1010
|
+
apply: function (view) {
|
|
1011
|
+
this._setupContainer(view, cc._canvas.width, cc._canvas.height);
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
|
|
1015
|
+
// #NOT STABLE on Android# Alias: Strategy that makes the container's size equals to the window's size
|
|
1016
|
+
// cc.ContainerStrategy.EQUAL_TO_WINDOW = new EqualToWindow();
|
|
1017
|
+
// #NOT STABLE on Android# Alias: Strategy that scale proportionally the container's size to window's size
|
|
1018
|
+
// cc.ContainerStrategy.PROPORTION_TO_WINDOW = new ProportionalToWindow();
|
|
1019
|
+
// Alias: Strategy that makes the container's size equals to the frame's size
|
|
1020
|
+
cc.ContainerStrategy.EQUAL_TO_FRAME = new EqualToFrame();
|
|
1021
|
+
// Alias: Strategy that scale proportionally the container's size to frame's size
|
|
1022
|
+
cc.ContainerStrategy.PROPORTION_TO_FRAME = new ProportionalToFrame();
|
|
1023
|
+
// Alias: Strategy that keeps the original container's size
|
|
1024
|
+
cc.ContainerStrategy.ORIGINAL_CONTAINER = new OriginalContainer();
|
|
1025
|
+
|
|
1026
|
+
// Content scale strategys
|
|
1027
|
+
var ExactFit = cc.ContentStrategy.extend({
|
|
1028
|
+
apply: function (view, designedResolution) {
|
|
1029
|
+
var containerW = cc._canvas.width, containerH = cc._canvas.height,
|
|
1030
|
+
scaleX = containerW / designedResolution.width, scaleY = containerH / designedResolution.height;
|
|
1031
|
+
|
|
1032
|
+
return this._buildResult(containerW, containerH, containerW, containerH, scaleX, scaleY);
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
var ShowAll = cc.ContentStrategy.extend({
|
|
1037
|
+
apply: function (view, designedResolution) {
|
|
1038
|
+
var containerW = cc._canvas.width, containerH = cc._canvas.height,
|
|
1039
|
+
designW = designedResolution.width, designH = designedResolution.height,
|
|
1040
|
+
scaleX = containerW / designW, scaleY = containerH / designH, scale = 0,
|
|
1041
|
+
contentW, contentH;
|
|
1042
|
+
|
|
1043
|
+
scaleX < scaleY ? (scale = scaleX, contentW = containerW, contentH = designH * scale)
|
|
1044
|
+
: (scale = scaleY, contentW = designW * scale, contentH = containerH);
|
|
1045
|
+
|
|
1046
|
+
return this._buildResult(containerW, containerH, contentW, contentH, scale, scale);
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
var NoBorder = cc.ContentStrategy.extend({
|
|
1051
|
+
apply: function (view, designedResolution) {
|
|
1052
|
+
var containerW = cc._canvas.width, containerH = cc._canvas.height,
|
|
1053
|
+
designW = designedResolution.width, designH = designedResolution.height,
|
|
1054
|
+
scaleX = containerW / designW, scaleY = containerH / designH, scale,
|
|
1055
|
+
contentW, contentH;
|
|
1056
|
+
|
|
1057
|
+
scaleX < scaleY ? (scale = scaleY, contentW = designW * scale, contentH = containerH)
|
|
1058
|
+
: (scale = scaleX, contentW = containerW, contentH = designH * scale);
|
|
1059
|
+
|
|
1060
|
+
return this._buildResult(containerW, containerH, contentW, contentH, scale, scale);
|
|
1061
|
+
}
|
|
1062
|
+
});
|
|
1063
|
+
|
|
1064
|
+
var FixedHeight = cc.ContentStrategy.extend({
|
|
1065
|
+
apply: function (view, designedResolution) {
|
|
1066
|
+
var containerW = cc._canvas.width, containerH = cc._canvas.height,
|
|
1067
|
+
designH = designedResolution.height, scale = containerH / designH,
|
|
1068
|
+
contentW = containerW, contentH = containerH;
|
|
1069
|
+
|
|
1070
|
+
return this._buildResult(containerW, containerH, contentW, contentH, scale, scale);
|
|
1071
|
+
},
|
|
1072
|
+
|
|
1073
|
+
postApply: function (view) {
|
|
1074
|
+
cc.director._winSizeInPoints = view.getVisibleSize();
|
|
1075
|
+
}
|
|
1076
|
+
});
|
|
1077
|
+
|
|
1078
|
+
var FixedWidth = cc.ContentStrategy.extend({
|
|
1079
|
+
apply: function (view, designedResolution) {
|
|
1080
|
+
var containerW = cc._canvas.width, containerH = cc._canvas.height,
|
|
1081
|
+
designW = designedResolution.width, scale = containerW / designW,
|
|
1082
|
+
contentW = containerW, contentH = containerH;
|
|
1083
|
+
|
|
1084
|
+
return this._buildResult(containerW, containerH, contentW, contentH, scale, scale);
|
|
1085
|
+
},
|
|
1086
|
+
|
|
1087
|
+
postApply: function (view) {
|
|
1088
|
+
cc.director._winSizeInPoints = view.getVisibleSize();
|
|
1089
|
+
}
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1092
|
+
// Alias: Strategy to scale the content's size to container's size, non proportional
|
|
1093
|
+
cc.ContentStrategy.EXACT_FIT = new ExactFit();
|
|
1094
|
+
// Alias: Strategy to scale the content's size proportionally to maximum size and keeps the whole content area to be visible
|
|
1095
|
+
cc.ContentStrategy.SHOW_ALL = new ShowAll();
|
|
1096
|
+
// Alias: Strategy to scale the content's size proportionally to fill the whole container area
|
|
1097
|
+
cc.ContentStrategy.NO_BORDER = new NoBorder();
|
|
1098
|
+
// Alias: Strategy to scale the content's height to container's height and proportionally scale its width
|
|
1099
|
+
cc.ContentStrategy.FIXED_HEIGHT = new FixedHeight();
|
|
1100
|
+
// Alias: Strategy to scale the content's width to container's width and proportionally scale its height
|
|
1101
|
+
cc.ContentStrategy.FIXED_WIDTH = new FixedWidth();
|
|
1102
|
+
|
|
1103
|
+
})();
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* <p>cc.ResolutionPolicy class is the root strategy class of scale strategy,
|
|
1107
|
+
* its main task is to maintain the compatibility with Cocos2d-x</p>
|
|
1108
|
+
*
|
|
1109
|
+
* @class
|
|
1110
|
+
* @extends cc.Class
|
|
1111
|
+
* @param {cc.ContainerStrategy} containerStg The container strategy
|
|
1112
|
+
* @param {cc.ContentStrategy} contentStg The content strategy
|
|
1113
|
+
*/
|
|
1114
|
+
cc.ResolutionPolicy = cc.Class.extend(/** @lends cc.ResolutionPolicy# */{
|
|
1115
|
+
_containerStrategy: null,
|
|
1116
|
+
_contentStrategy: null,
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* Constructor of cc.ResolutionPolicy
|
|
1120
|
+
* @param {cc.ContainerStrategy} containerStg
|
|
1121
|
+
* @param {cc.ContentStrategy} contentStg
|
|
1122
|
+
*/
|
|
1123
|
+
ctor: function (containerStg, contentStg) {
|
|
1124
|
+
this.setContainerStrategy(containerStg);
|
|
1125
|
+
this.setContentStrategy(contentStg);
|
|
1126
|
+
},
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Manipulation before applying the resolution policy
|
|
1130
|
+
* @param {cc.view} view The target view
|
|
1131
|
+
*/
|
|
1132
|
+
preApply: function (view) {
|
|
1133
|
+
this._containerStrategy.preApply(view);
|
|
1134
|
+
this._contentStrategy.preApply(view);
|
|
1135
|
+
},
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Function to apply this resolution policy
|
|
1139
|
+
* The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
|
|
1140
|
+
* The target view can then apply these value to itself, it's preferred not to modify directly its private variables
|
|
1141
|
+
* @param {cc.view} view The target view
|
|
1142
|
+
* @param {cc.Size} designedResolution The user defined design resolution
|
|
1143
|
+
* @return {object} An object contains the scale X/Y values and the viewport rect
|
|
1144
|
+
*/
|
|
1145
|
+
apply: function (view, designedResolution) {
|
|
1146
|
+
this._containerStrategy.apply(view, designedResolution);
|
|
1147
|
+
return this._contentStrategy.apply(view, designedResolution);
|
|
1148
|
+
},
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* Manipulation after appyling the strategy
|
|
1152
|
+
* @param {cc.view} view The target view
|
|
1153
|
+
*/
|
|
1154
|
+
postApply: function (view) {
|
|
1155
|
+
this._containerStrategy.postApply(view);
|
|
1156
|
+
this._contentStrategy.postApply(view);
|
|
1157
|
+
},
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* Setup the container's scale strategy
|
|
1161
|
+
* @param {cc.ContainerStrategy} containerStg
|
|
1162
|
+
*/
|
|
1163
|
+
setContainerStrategy: function (containerStg) {
|
|
1164
|
+
if (containerStg instanceof cc.ContainerStrategy)
|
|
1165
|
+
this._containerStrategy = containerStg;
|
|
1166
|
+
},
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Setup the content's scale strategy
|
|
1170
|
+
* @param {cc.ContentStrategy} contentStg
|
|
1171
|
+
*/
|
|
1172
|
+
setContentStrategy: function (contentStg) {
|
|
1173
|
+
if (contentStg instanceof cc.ContentStrategy)
|
|
1174
|
+
this._contentStrategy = contentStg;
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* @memberOf cc.ResolutionPolicy#
|
|
1180
|
+
* @name EXACT_FIT
|
|
1181
|
+
* @constant
|
|
1182
|
+
* @type Number
|
|
1183
|
+
* @static
|
|
1184
|
+
* The entire application is visible in the specified area without trying to preserve the original aspect ratio.<br/>
|
|
1185
|
+
* Distortion can occur, and the application may appear stretched or compressed.
|
|
1186
|
+
*/
|
|
1187
|
+
cc.ResolutionPolicy.EXACT_FIT = 0;
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* @memberOf cc.ResolutionPolicy#
|
|
1191
|
+
* @name NO_BORDER
|
|
1192
|
+
* @constant
|
|
1193
|
+
* @type Number
|
|
1194
|
+
* @static
|
|
1195
|
+
* The entire application fills the specified area, without distortion but possibly with some cropping,<br/>
|
|
1196
|
+
* while maintaining the original aspect ratio of the application.
|
|
1197
|
+
*/
|
|
1198
|
+
cc.ResolutionPolicy.NO_BORDER = 1;
|
|
1199
|
+
|
|
1200
|
+
/**
|
|
1201
|
+
* @memberOf cc.ResolutionPolicy#
|
|
1202
|
+
* @name SHOW_ALL
|
|
1203
|
+
* @constant
|
|
1204
|
+
* @type Number
|
|
1205
|
+
* @static
|
|
1206
|
+
* The entire application is visible in the specified area without distortion while maintaining the original<br/>
|
|
1207
|
+
* aspect ratio of the application. Borders can appear on two sides of the application.
|
|
1208
|
+
*/
|
|
1209
|
+
cc.ResolutionPolicy.SHOW_ALL = 2;
|
|
1210
|
+
|
|
1211
|
+
/**
|
|
1212
|
+
* @memberOf cc.ResolutionPolicy#
|
|
1213
|
+
* @name FIXED_HEIGHT
|
|
1214
|
+
* @constant
|
|
1215
|
+
* @type Number
|
|
1216
|
+
* @static
|
|
1217
|
+
* The application takes the height of the design resolution size and modifies the width of the internal<br/>
|
|
1218
|
+
* canvas so that it fits the aspect ratio of the device<br/>
|
|
1219
|
+
* no distortion will occur however you must make sure your application works on different<br/>
|
|
1220
|
+
* aspect ratios
|
|
1221
|
+
*/
|
|
1222
|
+
cc.ResolutionPolicy.FIXED_HEIGHT = 3;
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* @memberOf cc.ResolutionPolicy#
|
|
1226
|
+
* @name FIXED_WIDTH
|
|
1227
|
+
* @constant
|
|
1228
|
+
* @type Number
|
|
1229
|
+
* @static
|
|
1230
|
+
* The application takes the width of the design resolution size and modifies the height of the internal<br/>
|
|
1231
|
+
* canvas so that it fits the aspect ratio of the device<br/>
|
|
1232
|
+
* no distortion will occur however you must make sure your application works on different<br/>
|
|
1233
|
+
* aspect ratios
|
|
1234
|
+
*/
|
|
1235
|
+
cc.ResolutionPolicy.FIXED_WIDTH = 4;
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* @memberOf cc.ResolutionPolicy#
|
|
1239
|
+
* @name UNKNOWN
|
|
1240
|
+
* @constant
|
|
1241
|
+
* @type Number
|
|
1242
|
+
* @static
|
|
1243
|
+
* Unknow policy
|
|
1244
|
+
*/
|
|
1245
|
+
cc.ResolutionPolicy.UNKNOWN = 5;
|