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,899 @@
|
|
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
|
+
cc._tmp.WebGLTexture2D = function () {
|
28
|
+
|
29
|
+
/**
|
30
|
+
* <p>
|
31
|
+
* This class allows to easily create OpenGL or Canvas 2D textures from images, text or raw data. <br/>
|
32
|
+
* The created cc.Texture2D object will always have power-of-two dimensions. <br/>
|
33
|
+
* Depending on how you create the cc.Texture2D object, the actual image area of the texture might be smaller than the texture dimensions <br/>
|
34
|
+
* i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0). <br/>
|
35
|
+
* Be aware that the content of the generated textures will be upside-down! </p>
|
36
|
+
* @name cc.Texture2D
|
37
|
+
* @class
|
38
|
+
* @extends cc.Class
|
39
|
+
*
|
40
|
+
* @property {WebGLTexture} name - <@readonly> WebGLTexture Object
|
41
|
+
* @property {Number} defaultPixelFormat - The default pixel format
|
42
|
+
* @property {Number} pixelFormat - <@readonly> Pixel format of the texture
|
43
|
+
* @property {Number} pixelsWidth - <@readonly> Width in pixels
|
44
|
+
* @property {Number} pixelsHeight - <@readonly> Height in pixels
|
45
|
+
* @property {Number} width - Content width in points
|
46
|
+
* @property {Number} height - Content height in points
|
47
|
+
* @property {cc.GLProgram} shaderProgram - The shader program used by drawAtPoint and drawInRect
|
48
|
+
* @property {Number} maxS - Texture max S
|
49
|
+
* @property {Number} maxT - Texture max T
|
50
|
+
*/
|
51
|
+
//Original : Texture2DWebGL
|
52
|
+
cc.Texture2D = cc.Class.extend(/** @lends cc.Texture2D# */{
|
53
|
+
// By default PVR images are treated as if they don't have the alpha channel premultiplied
|
54
|
+
_pVRHaveAlphaPremultiplied: true,
|
55
|
+
_pixelFormat: null,
|
56
|
+
_pixelsWide: 0,
|
57
|
+
_pixelsHigh: 0,
|
58
|
+
_name: "",
|
59
|
+
_contentSize: null,
|
60
|
+
maxS: 0,
|
61
|
+
maxT: 0,
|
62
|
+
_hasPremultipliedAlpha: false,
|
63
|
+
_hasMipmaps: false,
|
64
|
+
|
65
|
+
shaderProgram: null,
|
66
|
+
|
67
|
+
_textureLoaded: false,
|
68
|
+
_htmlElementObj: null,
|
69
|
+
_webTextureObj: null,
|
70
|
+
|
71
|
+
url: null,
|
72
|
+
|
73
|
+
/**
|
74
|
+
* constructor of cc.Texture2D
|
75
|
+
*/
|
76
|
+
ctor: function () {
|
77
|
+
this._contentSize = cc.size(0, 0);
|
78
|
+
this._pixelFormat = cc.Texture2D.defaultPixelFormat;
|
79
|
+
},
|
80
|
+
|
81
|
+
/**
|
82
|
+
* release texture
|
83
|
+
*/
|
84
|
+
releaseTexture: function () {
|
85
|
+
if (this._webTextureObj)
|
86
|
+
cc._renderContext.deleteTexture(this._webTextureObj);
|
87
|
+
cc.loader.release(this.url);
|
88
|
+
},
|
89
|
+
|
90
|
+
/**
|
91
|
+
* pixel format of the texture
|
92
|
+
* @return {Number}
|
93
|
+
*/
|
94
|
+
getPixelFormat: function () {
|
95
|
+
return this._pixelFormat;
|
96
|
+
},
|
97
|
+
|
98
|
+
/**
|
99
|
+
* width in pixels
|
100
|
+
* @return {Number}
|
101
|
+
*/
|
102
|
+
getPixelsWide: function () {
|
103
|
+
return this._pixelsWide;
|
104
|
+
},
|
105
|
+
|
106
|
+
/**
|
107
|
+
* height in pixels
|
108
|
+
* @return {Number}
|
109
|
+
*/
|
110
|
+
getPixelsHigh: function () {
|
111
|
+
return this._pixelsHigh;
|
112
|
+
},
|
113
|
+
|
114
|
+
/**
|
115
|
+
* get WebGLTexture Object
|
116
|
+
* @return {WebGLTexture}
|
117
|
+
*/
|
118
|
+
getName: function () {
|
119
|
+
return this._webTextureObj;
|
120
|
+
},
|
121
|
+
|
122
|
+
/**
|
123
|
+
* content size
|
124
|
+
* @return {cc.Size}
|
125
|
+
*/
|
126
|
+
getContentSize: function () {
|
127
|
+
return cc.size(this._contentSize.width / cc.contentScaleFactor(), this._contentSize.height / cc.contentScaleFactor());
|
128
|
+
},
|
129
|
+
|
130
|
+
_getWidth: function () {
|
131
|
+
return this._contentSize.width / cc.contentScaleFactor();
|
132
|
+
},
|
133
|
+
_getHeight: function () {
|
134
|
+
return this._contentSize.height / cc.contentScaleFactor();
|
135
|
+
},
|
136
|
+
|
137
|
+
/**
|
138
|
+
* get content size in pixels
|
139
|
+
* @return {cc.Size}
|
140
|
+
*/
|
141
|
+
getContentSizeInPixels: function () {
|
142
|
+
return this._contentSize;
|
143
|
+
},
|
144
|
+
|
145
|
+
/**
|
146
|
+
* texture max S
|
147
|
+
* @return {Number}
|
148
|
+
*/
|
149
|
+
getMaxS: function () {
|
150
|
+
return this.maxS;
|
151
|
+
},
|
152
|
+
|
153
|
+
/**
|
154
|
+
* set texture max S
|
155
|
+
* @param {Number} maxS
|
156
|
+
*/
|
157
|
+
setMaxS: function (maxS) {
|
158
|
+
this.maxS = maxS;
|
159
|
+
},
|
160
|
+
|
161
|
+
/**
|
162
|
+
* get texture max T
|
163
|
+
* @return {Number}
|
164
|
+
*/
|
165
|
+
getMaxT: function () {
|
166
|
+
return this.maxT;
|
167
|
+
},
|
168
|
+
|
169
|
+
/**
|
170
|
+
* set texture max T
|
171
|
+
* @param {Number} maxT
|
172
|
+
*/
|
173
|
+
setMaxT: function (maxT) {
|
174
|
+
this.maxT = maxT;
|
175
|
+
},
|
176
|
+
|
177
|
+
/**
|
178
|
+
* return shader program used by drawAtPoint and drawInRect
|
179
|
+
* @return {cc.GLProgram}
|
180
|
+
*/
|
181
|
+
getShaderProgram: function () {
|
182
|
+
return this.shaderProgram;
|
183
|
+
},
|
184
|
+
|
185
|
+
/**
|
186
|
+
* set shader program used by drawAtPoint and drawInRect
|
187
|
+
* @param {cc.GLProgram} shaderProgram
|
188
|
+
*/
|
189
|
+
setShaderProgram: function (shaderProgram) {
|
190
|
+
this.shaderProgram = shaderProgram;
|
191
|
+
},
|
192
|
+
|
193
|
+
/**
|
194
|
+
* whether or not the texture has their Alpha premultiplied
|
195
|
+
* @return {Boolean}
|
196
|
+
*/
|
197
|
+
hasPremultipliedAlpha: function () {
|
198
|
+
return this._hasPremultipliedAlpha;
|
199
|
+
},
|
200
|
+
|
201
|
+
/**
|
202
|
+
* whether or not use mipmap
|
203
|
+
* @return {Boolean}
|
204
|
+
*/
|
205
|
+
hasMipmaps: function () {
|
206
|
+
return this._hasMipmaps;
|
207
|
+
},
|
208
|
+
|
209
|
+
/**
|
210
|
+
* description
|
211
|
+
* @return {string}
|
212
|
+
*/
|
213
|
+
description: function () {
|
214
|
+
var _t = this;
|
215
|
+
return "<cc.Texture2D | Name = " + _t._name + " | Dimensions = " + _t._pixelsWide + " x " + _t._pixelsHigh
|
216
|
+
+ " | Coordinates = (" + _t.maxS + ", " + _t.maxT + ")>";
|
217
|
+
},
|
218
|
+
|
219
|
+
/**
|
220
|
+
* These functions are needed to create mutable textures
|
221
|
+
* @param {Array} data
|
222
|
+
*/
|
223
|
+
releaseData: function (data) {
|
224
|
+
data = null;
|
225
|
+
},
|
226
|
+
|
227
|
+
keepData: function (data, length) {
|
228
|
+
//The texture data mustn't be saved becuase it isn't a mutable texture.
|
229
|
+
return data;
|
230
|
+
},
|
231
|
+
|
232
|
+
/**
|
233
|
+
* Intializes with a texture2d with data
|
234
|
+
* @param {Array} data
|
235
|
+
* @param {Number} pixelFormat
|
236
|
+
* @param {Number} pixelsWide
|
237
|
+
* @param {Number} pixelsHigh
|
238
|
+
* @param {cc.Size} contentSize
|
239
|
+
* @return {Boolean}
|
240
|
+
*/
|
241
|
+
initWithData: function (data, pixelFormat, pixelsWide, pixelsHigh, contentSize) {
|
242
|
+
var self = this, tex2d = cc.Texture2D;
|
243
|
+
var gl = cc._renderContext;
|
244
|
+
var format = gl.RGBA, type = gl.UNSIGNED_BYTE;
|
245
|
+
|
246
|
+
var bitsPerPixel = cc.Texture2D._B[pixelFormat];
|
247
|
+
|
248
|
+
var bytesPerRow = pixelsWide * bitsPerPixel / 8;
|
249
|
+
if (bytesPerRow % 8 === 0) {
|
250
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 8);
|
251
|
+
} else if (bytesPerRow % 4 === 0) {
|
252
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
|
253
|
+
} else if (bytesPerRow % 2 === 0) {
|
254
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 2);
|
255
|
+
} else {
|
256
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
|
257
|
+
}
|
258
|
+
|
259
|
+
self._webTextureObj = gl.createTexture();
|
260
|
+
cc.glBindTexture2D(self);
|
261
|
+
|
262
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
263
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
264
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
265
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
266
|
+
|
267
|
+
// Specify OpenGL texture image
|
268
|
+
switch (pixelFormat) {
|
269
|
+
case tex2d.PIXEL_FORMAT_RGBA8888:
|
270
|
+
format = gl.RGBA;
|
271
|
+
break;
|
272
|
+
case tex2d.PIXEL_FORMAT_RGB888:
|
273
|
+
format = gl.RGB;
|
274
|
+
break;
|
275
|
+
case tex2d.PIXEL_FORMAT_RGBA4444:
|
276
|
+
type = gl.UNSIGNED_SHORT_4_4_4_4;
|
277
|
+
break;
|
278
|
+
case tex2d.PIXEL_FORMAT_RGB5A1:
|
279
|
+
type = gl.UNSIGNED_SHORT_5_5_5_1;
|
280
|
+
break;
|
281
|
+
case tex2d.PIXEL_FORMAT_RGB565:
|
282
|
+
type = gl.UNSIGNED_SHORT_5_6_5;
|
283
|
+
break;
|
284
|
+
case tex2d.PIXEL_FORMAT_AI88:
|
285
|
+
format = gl.LUMINANCE_ALPHA;
|
286
|
+
break;
|
287
|
+
case tex2d.PIXEL_FORMAT_A8:
|
288
|
+
format = gl.ALPHA;
|
289
|
+
break;
|
290
|
+
case tex2d.PIXEL_FORMAT_I8:
|
291
|
+
format = gl.LUMINANCE;
|
292
|
+
break;
|
293
|
+
default:
|
294
|
+
cc.assert(0, cc._LogInfos.Texture2D_initWithData);
|
295
|
+
}
|
296
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, format, pixelsWide, pixelsHigh, 0, format, type, data);
|
297
|
+
|
298
|
+
|
299
|
+
self._contentSize.width = contentSize.width;
|
300
|
+
self._contentSize.height = contentSize.height;
|
301
|
+
self._pixelsWide = pixelsWide;
|
302
|
+
self._pixelsHigh = pixelsHigh;
|
303
|
+
self._pixelFormat = pixelFormat;
|
304
|
+
self.maxS = contentSize.width / pixelsWide;
|
305
|
+
self.maxT = contentSize.height / pixelsHigh;
|
306
|
+
|
307
|
+
self._hasPremultipliedAlpha = false;
|
308
|
+
self._hasMipmaps = false;
|
309
|
+
self.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
|
310
|
+
|
311
|
+
self._textureLoaded = true;
|
312
|
+
|
313
|
+
return true;
|
314
|
+
},
|
315
|
+
|
316
|
+
/**
|
317
|
+
Drawing extensions to make it easy to draw basic quads using a CCTexture2D object.
|
318
|
+
These functions require gl.TEXTURE_2D and both gl.VERTEX_ARRAY and gl.TEXTURE_COORD_ARRAY client states to be enabled.
|
319
|
+
*/
|
320
|
+
|
321
|
+
/**
|
322
|
+
* draws a texture at a given point
|
323
|
+
* @param {cc.Point} point
|
324
|
+
*/
|
325
|
+
drawAtPoint: function (point) {
|
326
|
+
var self = this;
|
327
|
+
var coordinates = [
|
328
|
+
0.0, self.maxT,
|
329
|
+
self.maxS, self.maxT,
|
330
|
+
0.0, 0.0,
|
331
|
+
self.maxS, 0.0 ];
|
332
|
+
|
333
|
+
var width = self._pixelsWide * self.maxS,
|
334
|
+
height = self._pixelsHigh * self.maxT;
|
335
|
+
|
336
|
+
var vertices = [
|
337
|
+
point.x, point.y, 0.0,
|
338
|
+
width + point.x, point.y, 0.0,
|
339
|
+
point.x, height + point.y, 0.0,
|
340
|
+
width + point.x, height + point.y, 0.0 ];
|
341
|
+
|
342
|
+
cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
|
343
|
+
self._shaderProgram.use();
|
344
|
+
self._shaderProgram.setUniformsForBuiltins();
|
345
|
+
|
346
|
+
cc.glBindTexture2D(self);
|
347
|
+
|
348
|
+
var gl = cc._renderContext;
|
349
|
+
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, vertices);
|
350
|
+
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, coordinates);
|
351
|
+
|
352
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
353
|
+
},
|
354
|
+
|
355
|
+
/**
|
356
|
+
* draws a texture inside a rect
|
357
|
+
* @param {cc.Rect} rect
|
358
|
+
*/
|
359
|
+
drawInRect: function (rect) {
|
360
|
+
var self = this;
|
361
|
+
var coordinates = [
|
362
|
+
0.0, self.maxT,
|
363
|
+
self.maxS, self.maxT,
|
364
|
+
0.0, 0.0,
|
365
|
+
self.maxS, 0.0];
|
366
|
+
|
367
|
+
var vertices = [ rect.x, rect.y, /*0.0,*/
|
368
|
+
rect.x + rect.width, rect.y, /*0.0,*/
|
369
|
+
rect.x, rect.y + rect.height, /*0.0,*/
|
370
|
+
rect.x + rect.width, rect.y + rect.height /*0.0*/ ];
|
371
|
+
|
372
|
+
cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS);
|
373
|
+
self._shaderProgram.use();
|
374
|
+
self._shaderProgram.setUniformsForBuiltins();
|
375
|
+
|
376
|
+
cc.glBindTexture2D(self);
|
377
|
+
|
378
|
+
var gl = cc._renderContext;
|
379
|
+
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, vertices);
|
380
|
+
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 0, coordinates);
|
381
|
+
|
382
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
383
|
+
},
|
384
|
+
|
385
|
+
/**
|
386
|
+
Extensions to make it easy to create a CCTexture2D object from an image file.
|
387
|
+
Note that RGBA type textures will have their alpha premultiplied - use the blending mode (gl.ONE, gl.ONE_MINUS_SRC_ALPHA).
|
388
|
+
*/
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Initializes a texture from a UIImage object
|
392
|
+
* @param uiImage
|
393
|
+
* @return {Boolean}
|
394
|
+
*/
|
395
|
+
initWithImage: function (uiImage) {
|
396
|
+
if (uiImage == null) {
|
397
|
+
cc.log(cc._LogInfos.Texture2D_initWithImage);
|
398
|
+
return false;
|
399
|
+
}
|
400
|
+
|
401
|
+
var imageWidth = uiImage.getWidth();
|
402
|
+
var imageHeight = uiImage.getHeight();
|
403
|
+
|
404
|
+
var maxTextureSize = cc.configuration.getMaxTextureSize();
|
405
|
+
if (imageWidth > maxTextureSize || imageHeight > maxTextureSize) {
|
406
|
+
cc.log(cc._LogInfos.Texture2D_initWithImage_2, imageWidth, imageHeight, maxTextureSize, maxTextureSize);
|
407
|
+
return false;
|
408
|
+
}
|
409
|
+
this._textureLoaded = true;
|
410
|
+
|
411
|
+
// always load premultiplied images
|
412
|
+
return this._initPremultipliedATextureWithImage(uiImage, imageWidth, imageHeight);
|
413
|
+
},
|
414
|
+
|
415
|
+
/**
|
416
|
+
* init with HTML element
|
417
|
+
* @param {HTMLImageElement|HTMLCanvasElement} element
|
418
|
+
*/
|
419
|
+
initWithElement: function (element) {
|
420
|
+
if (!element)
|
421
|
+
return;
|
422
|
+
this._webTextureObj = cc._renderContext.createTexture();
|
423
|
+
this._htmlElementObj = element;
|
424
|
+
this._textureLoaded = true;
|
425
|
+
},
|
426
|
+
|
427
|
+
/**
|
428
|
+
* HTMLElement Object getter
|
429
|
+
* @return {HTMLElement}
|
430
|
+
*/
|
431
|
+
getHtmlElementObj: function () {
|
432
|
+
return this._htmlElementObj;
|
433
|
+
},
|
434
|
+
|
435
|
+
/**
|
436
|
+
* whether texture is loaded
|
437
|
+
* @return {Boolean}
|
438
|
+
*/
|
439
|
+
isLoaded: function () {
|
440
|
+
return this._textureLoaded;
|
441
|
+
},
|
442
|
+
|
443
|
+
/**
|
444
|
+
* handler of texture loaded event
|
445
|
+
*/
|
446
|
+
handleLoadedTexture: function () {
|
447
|
+
var self = this;
|
448
|
+
// Not sure about this ! Some texture need to be updated even after loaded
|
449
|
+
if (!cc._rendererInitialized)
|
450
|
+
return;
|
451
|
+
if (!self._htmlElementObj) {
|
452
|
+
var img = cc.loader.getRes(self.url);
|
453
|
+
if (!img) return;
|
454
|
+
self.initWithElement(img);
|
455
|
+
}
|
456
|
+
if (!self._htmlElementObj.width || !self._htmlElementObj.height)
|
457
|
+
return;
|
458
|
+
|
459
|
+
//upload image to buffer
|
460
|
+
var gl = cc._renderContext;
|
461
|
+
|
462
|
+
cc.glBindTexture2D(self);
|
463
|
+
|
464
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
|
465
|
+
|
466
|
+
// Specify OpenGL texture image
|
467
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, self._htmlElementObj);
|
468
|
+
|
469
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
470
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
471
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
472
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
473
|
+
|
474
|
+
self.shaderProgram = cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE);
|
475
|
+
cc.glBindTexture2D(null);
|
476
|
+
|
477
|
+
var pixelsWide = self._htmlElementObj.width;
|
478
|
+
var pixelsHigh = self._htmlElementObj.height;
|
479
|
+
|
480
|
+
self._pixelsWide = self._contentSize.width = pixelsWide;
|
481
|
+
self._pixelsHigh = self._contentSize.height = pixelsHigh;
|
482
|
+
self._pixelFormat = cc.Texture2D.PIXEL_FORMAT_RGBA8888;
|
483
|
+
self.maxS = 1;
|
484
|
+
self.maxT = 1;
|
485
|
+
|
486
|
+
self._hasPremultipliedAlpha = false;
|
487
|
+
self._hasMipmaps = false;
|
488
|
+
|
489
|
+
//dispatch load event to listener.
|
490
|
+
self.dispatchEvent("load");
|
491
|
+
},
|
492
|
+
|
493
|
+
/**
|
494
|
+
Extensions to make it easy to create a cc.Texture2D object from a string of text.
|
495
|
+
Note that the generated textures are of type A8 - use the blending mode (gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA).
|
496
|
+
*/
|
497
|
+
/**
|
498
|
+
* Initializes a texture from a string with dimensions, alignment, font name and font size (note: initWithString does not support on HTML5)
|
499
|
+
* @param {String} text
|
500
|
+
* @param {String | cc.FontDefinition} fontName or fontDefinition
|
501
|
+
* @param {Number} fontSize
|
502
|
+
* @param {cc.Size} dimensions
|
503
|
+
* @param {Number} hAlignment
|
504
|
+
* @param {Number} vAlignment
|
505
|
+
* @return {Boolean}
|
506
|
+
*/
|
507
|
+
initWithString: function (text, fontName, fontSize, dimensions, hAlignment, vAlignment) {
|
508
|
+
cc.log(cc._LogInfos.Texture2D_initWithString);
|
509
|
+
return null;
|
510
|
+
},
|
511
|
+
|
512
|
+
/**
|
513
|
+
* Initializes a texture from a ETC file (note: initWithETCFile does not support on HTML5)
|
514
|
+
* @note Compatible to Cocos2d-x
|
515
|
+
* @param {String} file
|
516
|
+
* @return {Boolean}
|
517
|
+
*/
|
518
|
+
initWithETCFile: function (file) {
|
519
|
+
cc.log(cc._LogInfos.Texture2D_initWithETCFile_2);
|
520
|
+
return false;
|
521
|
+
},
|
522
|
+
|
523
|
+
/**
|
524
|
+
* Initializes a texture from a PVR file
|
525
|
+
* @param {String} file
|
526
|
+
* @return {Boolean}
|
527
|
+
*/
|
528
|
+
initWithPVRFile: function (file) {
|
529
|
+
cc.log(cc._LogInfos.Texture2D_initWithPVRFile_2);
|
530
|
+
return false;
|
531
|
+
},
|
532
|
+
|
533
|
+
/**
|
534
|
+
Extensions to make it easy to create a cc.Texture2D object from a PVRTC file
|
535
|
+
Note that the generated textures don't have their alpha premultiplied - use the blending mode (gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA).
|
536
|
+
*/
|
537
|
+
/**
|
538
|
+
* Initializes a texture from a PVRTC buffer
|
539
|
+
* @note compatible to cocos2d-iphone interface.
|
540
|
+
* @param {Array} data
|
541
|
+
* @param {Number} level
|
542
|
+
* @param {Number} bpp
|
543
|
+
* @param {Boolean} hasAlpha
|
544
|
+
* @param {Number} length
|
545
|
+
* @param {Number} pixelFormat
|
546
|
+
* @return {Boolean}
|
547
|
+
*/
|
548
|
+
initWithPVRTCData: function (data, level, bpp, hasAlpha, length, pixelFormat) {
|
549
|
+
cc.log(cc._LogInfos.Texture2D_initWithPVRTCData_2);
|
550
|
+
return false;
|
551
|
+
},
|
552
|
+
|
553
|
+
/**
|
554
|
+
* sets the min filter, mag filter, wrap s and wrap t texture parameters. <br/>
|
555
|
+
* If the texture size is NPOT (non power of 2), then in can only use gl.CLAMP_TO_EDGE in gl.TEXTURE_WRAP_{S,T}.
|
556
|
+
* @param {Object|Number} texParams texParams object or minFilter
|
557
|
+
* @param {Number} [magFilter]
|
558
|
+
* @param {Number} [wrapS]
|
559
|
+
* @param {Number} [wrapT]
|
560
|
+
*/
|
561
|
+
setTexParameters: function (texParams, magFilter, wrapS, wrapT) {
|
562
|
+
var _t = this;
|
563
|
+
var gl = cc._renderContext;
|
564
|
+
|
565
|
+
if(magFilter !== undefined)
|
566
|
+
texParams = {minFilter: texParams, magFilter: magFilter, wrapS: wrapS, wrapT: wrapT};
|
567
|
+
|
568
|
+
cc.assert((_t._pixelsWide == cc.NextPOT(_t._pixelsWide) && _t._pixelsHigh == cc.NextPOT(_t._pixelsHigh)) ||
|
569
|
+
(texParams.wrapS == gl.CLAMP_TO_EDGE && texParams.wrapT == gl.CLAMP_TO_EDGE),
|
570
|
+
"WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures");
|
571
|
+
|
572
|
+
cc.glBindTexture2D(_t);
|
573
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texParams.minFilter);
|
574
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texParams.magFilter);
|
575
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, texParams.wrapS);
|
576
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, texParams.wrapT);
|
577
|
+
},
|
578
|
+
|
579
|
+
/**
|
580
|
+
* sets antialias texture parameters: <br/>
|
581
|
+
* - GL_TEXTURE_MIN_FILTER = GL_NEAREST <br/>
|
582
|
+
* - GL_TEXTURE_MAG_FILTER = GL_NEAREST
|
583
|
+
*/
|
584
|
+
setAntiAliasTexParameters: function () {
|
585
|
+
var gl = cc._renderContext;
|
586
|
+
|
587
|
+
cc.glBindTexture2D(this);
|
588
|
+
if (!this._hasMipmaps)
|
589
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
590
|
+
else
|
591
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
|
592
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
593
|
+
},
|
594
|
+
|
595
|
+
/**
|
596
|
+
* sets alias texture parameters:
|
597
|
+
* GL_TEXTURE_MIN_FILTER = GL_NEAREST
|
598
|
+
* GL_TEXTURE_MAG_FILTER = GL_NEAREST
|
599
|
+
*/
|
600
|
+
setAliasTexParameters: function () {
|
601
|
+
var gl = cc._renderContext;
|
602
|
+
|
603
|
+
cc.glBindTexture2D(this);
|
604
|
+
if (!this._hasMipmaps)
|
605
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
606
|
+
else
|
607
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_NEAREST);
|
608
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
609
|
+
},
|
610
|
+
|
611
|
+
/**
|
612
|
+
* Generates mipmap images for the texture.<br/>
|
613
|
+
* It only works if the texture size is POT (power of 2).
|
614
|
+
*/
|
615
|
+
generateMipmap: function () {
|
616
|
+
var _t = this;
|
617
|
+
cc.assert(_t._pixelsWide == cc.NextPOT(_t._pixelsWide) && _t._pixelsHigh == cc.NextPOT(_t._pixelsHigh), "Mimpap texture only works in POT textures");
|
618
|
+
|
619
|
+
cc.glBindTexture2D(_t);
|
620
|
+
cc._renderContext.generateMipmap(cc._renderContext.TEXTURE_2D);
|
621
|
+
_t._hasMipmaps = true;
|
622
|
+
},
|
623
|
+
|
624
|
+
/**
|
625
|
+
* returns the pixel format.
|
626
|
+
* @return {String}
|
627
|
+
*/
|
628
|
+
stringForFormat: function () {
|
629
|
+
return cc.Texture2D._M[this._pixelFormat];
|
630
|
+
},
|
631
|
+
|
632
|
+
/**
|
633
|
+
* returns the bits-per-pixel of the in-memory OpenGL texture
|
634
|
+
* @return {Number}
|
635
|
+
*/
|
636
|
+
bitsPerPixelForFormat: function (format) {//TODO I want to delete the format argument, use this._pixelFormat
|
637
|
+
format = format || this._pixelFormat;
|
638
|
+
var value = cc.Texture2D._B[format];
|
639
|
+
if (value != null) return value;
|
640
|
+
cc.log(cc._LogInfos.Texture2D_bitsPerPixelForFormat, format);
|
641
|
+
return -1;
|
642
|
+
},
|
643
|
+
|
644
|
+
_initPremultipliedATextureWithImage: function (uiImage, width, height) {
|
645
|
+
var tex2d = cc.Texture2D;
|
646
|
+
var tempData = uiImage.getData();
|
647
|
+
var inPixel32 = null;
|
648
|
+
var inPixel8 = null;
|
649
|
+
var outPixel16 = null;
|
650
|
+
var hasAlpha = uiImage.hasAlpha();
|
651
|
+
var imageSize = cc.size(uiImage.getWidth(), uiImage.getHeight());
|
652
|
+
var pixelFormat = tex2d.defaultPixelFormat;
|
653
|
+
var bpp = uiImage.getBitsPerComponent();
|
654
|
+
var i;
|
655
|
+
|
656
|
+
// compute pixel format
|
657
|
+
if (!hasAlpha) {
|
658
|
+
if (bpp >= 8) {
|
659
|
+
pixelFormat = tex2d.PIXEL_FORMAT_RGB888;
|
660
|
+
} else {
|
661
|
+
cc.log(cc._LogInfos.Texture2D__initPremultipliedATextureWithImage);
|
662
|
+
pixelFormat = tex2d.PIXEL_FORMAT_RGB565;
|
663
|
+
}
|
664
|
+
}
|
665
|
+
|
666
|
+
// Repack the pixel data into the right format
|
667
|
+
var length = width * height;
|
668
|
+
|
669
|
+
if (pixelFormat == tex2d.PIXEL_FORMAT_RGB565) {
|
670
|
+
if (hasAlpha) {
|
671
|
+
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB"
|
672
|
+
tempData = new Uint16Array(width * height);
|
673
|
+
inPixel32 = uiImage.getData();
|
674
|
+
|
675
|
+
for (i = 0; i < length; ++i) {
|
676
|
+
tempData[i] =
|
677
|
+
((((inPixel32[i] >> 0) & 0xFF) >> 3) << 11) | // R
|
678
|
+
((((inPixel32[i] >> 8) & 0xFF) >> 2) << 5) | // G
|
679
|
+
((((inPixel32[i] >> 16) & 0xFF) >> 3) << 0); // B
|
680
|
+
}
|
681
|
+
} else {
|
682
|
+
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBB" to "RRRRRGGGGGGBBBBB"
|
683
|
+
tempData = new Uint16Array(width * height);
|
684
|
+
inPixel8 = uiImage.getData();
|
685
|
+
|
686
|
+
for (i = 0; i < length; ++i) {
|
687
|
+
tempData[i] =
|
688
|
+
(((inPixel8[i] & 0xFF) >> 3) << 11) | // R
|
689
|
+
(((inPixel8[i] & 0xFF) >> 2) << 5) | // G
|
690
|
+
(((inPixel8[i] & 0xFF) >> 3) << 0); // B
|
691
|
+
}
|
692
|
+
}
|
693
|
+
} else if (pixelFormat == tex2d.PIXEL_FORMAT_RGBA4444) {
|
694
|
+
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA"
|
695
|
+
tempData = new Uint16Array(width * height);
|
696
|
+
inPixel32 = uiImage.getData();
|
697
|
+
|
698
|
+
for (i = 0; i < length; ++i) {
|
699
|
+
tempData[i] =
|
700
|
+
((((inPixel32[i] >> 0) & 0xFF) >> 4) << 12) | // R
|
701
|
+
((((inPixel32[i] >> 8) & 0xFF) >> 4) << 8) | // G
|
702
|
+
((((inPixel32[i] >> 16) & 0xFF) >> 4) << 4) | // B
|
703
|
+
((((inPixel32[i] >> 24) & 0xFF) >> 4) << 0); // A
|
704
|
+
}
|
705
|
+
} else if (pixelFormat == tex2d.PIXEL_FORMAT_RGB5A1) {
|
706
|
+
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA"
|
707
|
+
tempData = new Uint16Array(width * height);
|
708
|
+
inPixel32 = uiImage.getData();
|
709
|
+
|
710
|
+
for (i = 0; i < length; ++i) {
|
711
|
+
tempData[i] =
|
712
|
+
((((inPixel32[i] >> 0) & 0xFF) >> 3) << 11) | // R
|
713
|
+
((((inPixel32[i] >> 8) & 0xFF) >> 3) << 6) | // G
|
714
|
+
((((inPixel32[i] >> 16) & 0xFF) >> 3) << 1) | // B
|
715
|
+
((((inPixel32[i] >> 24) & 0xFF) >> 7) << 0); // A
|
716
|
+
}
|
717
|
+
} else if (pixelFormat == tex2d.PIXEL_FORMAT_A8) {
|
718
|
+
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "AAAAAAAA"
|
719
|
+
tempData = new Uint8Array(width * height);
|
720
|
+
inPixel32 = uiImage.getData();
|
721
|
+
|
722
|
+
for (i = 0; i < length; ++i) {
|
723
|
+
tempData[i] = (inPixel32 >> 24) & 0xFF; // A
|
724
|
+
}
|
725
|
+
}
|
726
|
+
|
727
|
+
if (hasAlpha && pixelFormat == tex2d.PIXEL_FORMAT_RGB888) {
|
728
|
+
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRRRRGGGGGGGGBBBBBBBB"
|
729
|
+
inPixel32 = uiImage.getData();
|
730
|
+
tempData = new Uint8Array(width * height * 3);
|
731
|
+
|
732
|
+
for (i = 0; i < length; ++i) {
|
733
|
+
tempData[i * 3] = (inPixel32 >> 0) & 0xFF; // R
|
734
|
+
tempData[i * 3 + 1] = (inPixel32 >> 8) & 0xFF; // G
|
735
|
+
tempData[i * 3 + 2] = (inPixel32 >> 16) & 0xFF; // B
|
736
|
+
}
|
737
|
+
}
|
738
|
+
|
739
|
+
this.initWithData(tempData, pixelFormat, width, height, imageSize);
|
740
|
+
|
741
|
+
if (tempData != uiImage.getData())
|
742
|
+
tempData = null;
|
743
|
+
|
744
|
+
this._hasPremultipliedAlpha = uiImage.isPremultipliedAlpha();
|
745
|
+
return true;
|
746
|
+
},
|
747
|
+
|
748
|
+
/**
|
749
|
+
* add listener for loaded event
|
750
|
+
* @param {Function} callback
|
751
|
+
* @param {cc.Node} target
|
752
|
+
* @deprecated since 3.1, please use addEventListener instead
|
753
|
+
*/
|
754
|
+
addLoadedEventListener: function (callback, target) {
|
755
|
+
this.addEventListener("load", callback, target);
|
756
|
+
},
|
757
|
+
|
758
|
+
/**
|
759
|
+
* remove listener from listeners by target
|
760
|
+
* @param {cc.Node} target
|
761
|
+
*/
|
762
|
+
removeLoadedEventListener: function (target) {
|
763
|
+
this.removeEventListener("load", target);
|
764
|
+
}
|
765
|
+
});
|
766
|
+
};
|
767
|
+
|
768
|
+
cc._tmp.WebGLTextureAtlas = function () {
|
769
|
+
var _p = cc.TextureAtlas.prototype;
|
770
|
+
_p._setupVBO = function () {
|
771
|
+
var _t = this;
|
772
|
+
var gl = cc._renderContext;
|
773
|
+
//create WebGLBuffer
|
774
|
+
_t._buffersVBO[0] = gl.createBuffer();
|
775
|
+
_t._buffersVBO[1] = gl.createBuffer();
|
776
|
+
|
777
|
+
_t._quadsWebBuffer = gl.createBuffer();
|
778
|
+
_t._mapBuffers();
|
779
|
+
};
|
780
|
+
|
781
|
+
_p._mapBuffers = function () {
|
782
|
+
var _t = this;
|
783
|
+
var gl = cc._renderContext;
|
784
|
+
|
785
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadsWebBuffer);
|
786
|
+
gl.bufferData(gl.ARRAY_BUFFER, _t._quadsArrayBuffer, gl.DYNAMIC_DRAW);
|
787
|
+
|
788
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]);
|
789
|
+
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, _t._indices, gl.STATIC_DRAW);
|
790
|
+
|
791
|
+
//cc.checkGLErrorDebug();
|
792
|
+
};
|
793
|
+
|
794
|
+
/**
|
795
|
+
* <p>Draws n quads from an index (offset). <br />
|
796
|
+
* n + start can't be greater than the capacity of the atlas</p>
|
797
|
+
* @param {Number} n
|
798
|
+
* @param {Number} start
|
799
|
+
*/
|
800
|
+
_p.drawNumberOfQuads = function (n, start) {
|
801
|
+
var _t = this;
|
802
|
+
start = start || 0;
|
803
|
+
if (0 === n || !_t.texture || !_t.texture.isLoaded())
|
804
|
+
return;
|
805
|
+
|
806
|
+
var gl = cc._renderContext;
|
807
|
+
cc.glBindTexture2D(_t.texture);
|
808
|
+
|
809
|
+
//
|
810
|
+
// Using VBO without VAO
|
811
|
+
//
|
812
|
+
//vertices
|
813
|
+
//gl.bindBuffer(gl.ARRAY_BUFFER, _t._buffersVBO[0]);
|
814
|
+
// XXX: update is done in draw... perhaps it should be done in a timer
|
815
|
+
cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
|
816
|
+
|
817
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, _t._quadsWebBuffer);
|
818
|
+
if (_t.dirty){
|
819
|
+
gl.bufferData(gl.ARRAY_BUFFER, _t._quadsArrayBuffer, gl.DYNAMIC_DRAW);
|
820
|
+
_t.dirty = false;
|
821
|
+
}
|
822
|
+
|
823
|
+
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 3, gl.FLOAT, false, 24, 0); // vertices
|
824
|
+
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR, 4, gl.UNSIGNED_BYTE, true, 24, 12); // colors
|
825
|
+
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS, 2, gl.FLOAT, false, 24, 16); // tex coords
|
826
|
+
|
827
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, _t._buffersVBO[1]);
|
828
|
+
|
829
|
+
if (cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP)
|
830
|
+
gl.drawElements(gl.TRIANGLE_STRIP, n * 6, gl.UNSIGNED_SHORT, start * 6 * _t._indices.BYTES_PER_ELEMENT);
|
831
|
+
else
|
832
|
+
gl.drawElements(gl.TRIANGLES, n * 6, gl.UNSIGNED_SHORT, start * 6 * _t._indices.BYTES_PER_ELEMENT);
|
833
|
+
|
834
|
+
cc.g_NumberOfDraws++;
|
835
|
+
//cc.checkGLErrorDebug();
|
836
|
+
};
|
837
|
+
};
|
838
|
+
|
839
|
+
cc._tmp.WebGLTextureCache = function () {
|
840
|
+
var _p = cc.textureCache;
|
841
|
+
|
842
|
+
_p.handleLoadedTexture = function (url) {
|
843
|
+
var locTexs = this._textures;
|
844
|
+
//remove judge(webgl)
|
845
|
+
if (!cc._rendererInitialized) {
|
846
|
+
locTexs = this._loadedTexturesBefore;
|
847
|
+
}
|
848
|
+
var tex = locTexs[url];
|
849
|
+
if (!tex) {
|
850
|
+
tex = locTexs[url] = new cc.Texture2D();
|
851
|
+
tex.url = url;
|
852
|
+
}
|
853
|
+
tex.handleLoadedTexture();
|
854
|
+
};
|
855
|
+
|
856
|
+
/**
|
857
|
+
* <p>Returns a Texture2D object given an file image <br />
|
858
|
+
* If the file image was not previously loaded, it will create a new Texture2D <br />
|
859
|
+
* object and it will return it. It will use the filename as a key.<br />
|
860
|
+
* Otherwise it will return a reference of a previously loaded image. <br />
|
861
|
+
* Supported image extensions: .png, .jpg, .gif</p>
|
862
|
+
* @param {String} url
|
863
|
+
* @param {Function} cb
|
864
|
+
* @param {Object} target
|
865
|
+
* @return {cc.Texture2D}
|
866
|
+
* @example
|
867
|
+
* //example
|
868
|
+
* cc.textureCache.addImage("hello.png");
|
869
|
+
*/
|
870
|
+
_p.addImage = function (url, cb, target) {
|
871
|
+
cc.assert(url, cc._LogInfos.Texture2D_addImage_2);
|
872
|
+
|
873
|
+
var locTexs = this._textures;
|
874
|
+
//remove judge(webgl)
|
875
|
+
if (!cc._rendererInitialized) {
|
876
|
+
locTexs = this._loadedTexturesBefore;
|
877
|
+
}
|
878
|
+
var tex = locTexs[url] || locTexs[cc.loader._aliases[url]];
|
879
|
+
if (tex) {
|
880
|
+
cb && cb.call(target, tex);
|
881
|
+
return tex;
|
882
|
+
}
|
883
|
+
|
884
|
+
tex = locTexs[url] = new cc.Texture2D();
|
885
|
+
tex.url = url;
|
886
|
+
var loadFunc = cc.loader._checkIsImageURL(url) ? cc.loader.load : cc.loader.loadImg;
|
887
|
+
loadFunc.call(cc.loader, url, function (err, img) {
|
888
|
+
if (err)
|
889
|
+
return cb && cb.call(target, err);
|
890
|
+
cc.textureCache.handleLoadedTexture(url);
|
891
|
+
|
892
|
+
var texResult = locTexs[url];
|
893
|
+
cb && cb.call(target, texResult);
|
894
|
+
});
|
895
|
+
|
896
|
+
return tex;
|
897
|
+
};
|
898
|
+
_p = null;
|
899
|
+
};
|