diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index d029cef82f..b3297c7deb 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -818,18 +818,10 @@ 15EFA212198A2BB5000C57D3 /* CCProtectedNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */; }; 15EFA213198A2BB5000C57D3 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */; }; 15EFA214198A2BB5000C57D3 /* CCProtectedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */; }; - 15FB206A1AE7BE7400C31518 /* SpritePolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20661AE7BE7400C31518 /* SpritePolygon.cpp */; }; - 15FB206B1AE7BE7400C31518 /* SpritePolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20661AE7BE7400C31518 /* SpritePolygon.cpp */; }; - 15FB206C1AE7BE7400C31518 /* SpritePolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20671AE7BE7400C31518 /* SpritePolygon.h */; }; - 15FB206D1AE7BE7400C31518 /* SpritePolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20671AE7BE7400C31518 /* SpritePolygon.h */; }; - 15FB206E1AE7BE7400C31518 /* SpritePolygonCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20681AE7BE7400C31518 /* SpritePolygonCache.cpp */; }; - 15FB206F1AE7BE7400C31518 /* SpritePolygonCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20681AE7BE7400C31518 /* SpritePolygonCache.cpp */; }; - 15FB20701AE7BE7400C31518 /* SpritePolygonCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20691AE7BE7400C31518 /* SpritePolygonCache.h */; }; - 15FB20711AE7BE7400C31518 /* SpritePolygonCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20691AE7BE7400C31518 /* SpritePolygonCache.h */; }; - 15FB20741AE7BF8600C31518 /* MarchingSquare.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20721AE7BF8600C31518 /* MarchingSquare.cpp */; }; - 15FB20751AE7BF8600C31518 /* MarchingSquare.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20721AE7BF8600C31518 /* MarchingSquare.cpp */; }; - 15FB20761AE7BF8600C31518 /* MarchingSquare.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20731AE7BF8600C31518 /* MarchingSquare.h */; }; - 15FB20771AE7BF8600C31518 /* MarchingSquare.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20731AE7BF8600C31518 /* MarchingSquare.h */; }; + 15FB20741AE7BF8600C31518 /* CCAutoPolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */; }; + 15FB20751AE7BF8600C31518 /* CCAutoPolygon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */; }; + 15FB20761AE7BF8600C31518 /* CCAutoPolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20731AE7BF8600C31518 /* CCAutoPolygon.h */; }; + 15FB20771AE7BF8600C31518 /* CCAutoPolygon.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB20731AE7BF8600C31518 /* CCAutoPolygon.h */; }; 15FB20871AE7C57D00C31518 /* shapes.cc in Sources */ = {isa = PBXBuildFile; fileRef = 15FB207A1AE7C57D00C31518 /* shapes.cc */; }; 15FB20881AE7C57D00C31518 /* shapes.cc in Sources */ = {isa = PBXBuildFile; fileRef = 15FB207A1AE7C57D00C31518 /* shapes.cc */; }; 15FB20891AE7C57D00C31518 /* shapes.h in Headers */ = {isa = PBXBuildFile; fileRef = 15FB207B1AE7C57D00C31518 /* shapes.h */; }; @@ -1848,6 +1840,10 @@ 826294331AAF001C00CB7CF7 /* HttpAsynConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2A1A5349A3004E4C60 /* HttpAsynConnection.m */; }; 826294341AAF003E00CB7CF7 /* HttpClient-apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2B1A5349A3004E4C60 /* HttpClient-apple.mm */; }; 826294351AAF004C00CB7CF7 /* HttpCookie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52B47A2C1A5349A3004E4C60 /* HttpCookie.cpp */; }; + 8525E3A21B291E42008EE815 /* clipper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8525E3A11B291E42008EE815 /* clipper.hpp */; }; + 8525E3A31B291E42008EE815 /* clipper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 8525E3A11B291E42008EE815 /* clipper.hpp */; }; + 85B3743A1B204B9400C488D6 /* clipper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85B374381B204B9400C488D6 /* clipper.cpp */; }; + 85B3743B1B204B9400C488D6 /* clipper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85B374381B204B9400C488D6 /* clipper.cpp */; }; A07A4CAF1783777C0073F6A7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A342158F2AB200E66CFE /* Foundation.framework */; }; B2165EEA19921124000BE3E6 /* CCPrimitiveCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B257B45E198A353E00D9A687 /* CCPrimitiveCommand.cpp */; }; B217703C1977ECB4009EE11B /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B217703B1977ECB4009EE11B /* IOKit.framework */; }; @@ -3669,12 +3665,8 @@ 15B3707719EE414C00ABE682 /* Manifest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Manifest.h; sourceTree = ""; }; 15EFA20F198A2BB5000C57D3 /* CCProtectedNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCProtectedNode.cpp; sourceTree = ""; }; 15EFA210198A2BB5000C57D3 /* CCProtectedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProtectedNode.h; sourceTree = ""; }; - 15FB20661AE7BE7400C31518 /* SpritePolygon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpritePolygon.cpp; sourceTree = ""; }; - 15FB20671AE7BE7400C31518 /* SpritePolygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpritePolygon.h; sourceTree = ""; }; - 15FB20681AE7BE7400C31518 /* SpritePolygonCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpritePolygonCache.cpp; sourceTree = ""; }; - 15FB20691AE7BE7400C31518 /* SpritePolygonCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpritePolygonCache.h; sourceTree = ""; }; - 15FB20721AE7BF8600C31518 /* MarchingSquare.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MarchingSquare.cpp; sourceTree = ""; }; - 15FB20731AE7BF8600C31518 /* MarchingSquare.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarchingSquare.h; sourceTree = ""; }; + 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCAutoPolygon.cpp; sourceTree = ""; }; + 15FB20731AE7BF8600C31518 /* CCAutoPolygon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCAutoPolygon.h; sourceTree = ""; }; 15FB207A1AE7C57D00C31518 /* shapes.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shapes.cc; sourceTree = ""; }; 15FB207B1AE7C57D00C31518 /* shapes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shapes.h; sourceTree = ""; }; 15FB207C1AE7C57D00C31518 /* utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utils.h; sourceTree = ""; }; @@ -4601,6 +4593,8 @@ 5E9F61231A3FFE3D0038DE01 /* CCFrustum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFrustum.h; sourceTree = ""; }; 5E9F61241A3FFE3D0038DE01 /* CCPlane.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPlane.cpp; sourceTree = ""; }; 5E9F61251A3FFE3D0038DE01 /* CCPlane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPlane.h; sourceTree = ""; }; + 8525E3A11B291E42008EE815 /* clipper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = clipper.hpp; sourceTree = ""; }; + 85B374381B204B9400C488D6 /* clipper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clipper.cpp; sourceTree = ""; }; A07A4D641783777C0073F6A7 /* libcocos2d iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocos2d iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; B20564AA1A6E5744001C1B6E /* ccShader_PositionColorTextureAsPointsize.vert */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ccShader_PositionColorTextureAsPointsize.vert; sourceTree = ""; }; B217703B1977ECB4009EE11B /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; @@ -6023,12 +6017,8 @@ 1A570275180BCC840088DEC7 /* sprite-nodes */ = { isa = PBXGroup; children = ( - 15FB20721AE7BF8600C31518 /* MarchingSquare.cpp */, - 15FB20731AE7BF8600C31518 /* MarchingSquare.h */, - 15FB20661AE7BE7400C31518 /* SpritePolygon.cpp */, - 15FB20671AE7BE7400C31518 /* SpritePolygon.h */, - 15FB20681AE7BE7400C31518 /* SpritePolygonCache.cpp */, - 15FB20691AE7BE7400C31518 /* SpritePolygonCache.h */, + 15FB20721AE7BF8600C31518 /* CCAutoPolygon.cpp */, + 15FB20731AE7BF8600C31518 /* CCAutoPolygon.h */, 1A57028E180BCCAB0088DEC7 /* CCAnimation.cpp */, 1A57028F180BCCAB0088DEC7 /* CCAnimation.h */, 1A570290180BCCAB0088DEC7 /* CCAnimationCache.cpp */, @@ -6091,6 +6081,7 @@ 1A57033E180BD0490088DEC7 /* external */ = { isa = PBXGroup; children = ( + 68B39B391B1C5C670084F72C /* clipper */, B6DD2F731B04820C00E47F5F /* recast */, B6CAB0021AF9A9EE00B9B856 /* bullet */, 15FB20781AE7C57D00C31518 /* poly2tri */, @@ -7719,6 +7710,16 @@ path = TextReader; sourceTree = ""; }; + 68B39B391B1C5C670084F72C /* clipper */ = { + isa = PBXGroup; + children = ( + 8525E3A11B291E42008EE815 /* clipper.hpp */, + 85B374381B204B9400C488D6 /* clipper.cpp */, + ); + name = clipper; + path = ../external/clipper; + sourceTree = ""; + }; B29594B81926D61F003EEF37 /* 3d */ = { isa = PBXGroup; children = ( @@ -8910,7 +8911,7 @@ 3E2F27A719CFBFE400E7C490 /* AudioEngine.h in Headers */, 15AE183A19AAD2F700C27E9E /* CCRay.h in Headers */, 15AE18A319AAD33D00C27E9E /* CCParticleSystemQuadLoader.h in Headers */, - 15FB20761AE7BF8600C31518 /* MarchingSquare.h in Headers */, + 15FB20761AE7BF8600C31518 /* CCAutoPolygon.h in Headers */, B665E2C41AA80A6500DDB1C5 /* CCPUGeometryRotatorTranslator.h in Headers */, 46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */, 15AE199D19AAD39600C27E9E /* ScrollViewReader.h in Headers */, @@ -9157,7 +9158,6 @@ 15AE1A3319AAD3D500C27E9E /* b2CircleShape.h in Headers */, 1A5701E0180BCB8C0088DEC7 /* CCLayer.h in Headers */, 1A5701E4180BCB8C0088DEC7 /* CCScene.h in Headers */, - 15FB20701AE7BE7400C31518 /* SpritePolygonCache.h in Headers */, B6CAB2C11AF9AA1A00B9B856 /* btEmptyShape.h in Headers */, B665E3D81AA80A6600DDB1C5 /* CCPUScriptParser.h in Headers */, 382384091A25900F002C4610 /* FlatBuffersSerialize.h in Headers */, @@ -9512,6 +9512,7 @@ 15AE183219AAD2F700C27E9E /* CCOBB.h in Headers */, 15AE1BE319AAE01E00C27E9E /* CCScrollView.h in Headers */, B665E2941AA80A6500DDB1C5 /* CCPUEmitter.h in Headers */, + 8525E3A21B291E42008EE815 /* clipper.hpp in Headers */, 15FB209D1AE7C57D00C31518 /* sweep_context.h in Headers */, 50CB247519D9C5A100687767 /* AudioCache.h in Headers */, 3823841C1A2590D2002C4610 /* ComAudioReader.h in Headers */, @@ -9667,7 +9668,6 @@ B6CAB2D31AF9AA1A00B9B856 /* btMultiSphereShape.h in Headers */, B665E1F41AA80A6500DDB1C5 /* CCPUAffector.h in Headers */, 1A01C69E18F57BE800EFE3A6 /* CCString.h in Headers */, - 15FB206C1AE7BE7400C31518 /* SpritePolygon.h in Headers */, 50ABC00F1926664800A911A9 /* CCFileUtils.h in Headers */, B665E2981AA80A6500DDB1C5 /* CCPUEmitterManager.h in Headers */, 15AE1A3719AAD3D500C27E9E /* b2PolygonShape.h in Headers */, @@ -9945,7 +9945,6 @@ B665E2451AA80A6500DDB1C5 /* CCPUCollisionAvoidanceAffector.h in Headers */, B6CAB3381AF9AA1A00B9B856 /* btQuantization.h in Headers */, 50ABBEC41925AB6F00A911A9 /* CCVector.h in Headers */, - 15FB20711AE7BE7400C31518 /* SpritePolygonCache.h in Headers */, 50ABBE501925AB6F00A911A9 /* CCEventCustom.h in Headers */, 15AE1AD719AAD40300C27E9E /* b2WheelJoint.h in Headers */, B665E3311AA80A6500DDB1C5 /* CCPUOnCountObserverTranslator.h in Headers */, @@ -10143,6 +10142,7 @@ B665E2AD1AA80A6500DDB1C5 /* CCPUFlockCenteringAffector.h in Headers */, 15AE196B19AAD35100C27E9E /* DictionaryHelper.h in Headers */, B6CAB4C21AF9AA1A00B9B856 /* SpuLibspe2Support.h in Headers */, + 8525E3A31B291E42008EE815 /* clipper.hpp in Headers */, B6CAB5021AF9AA1A00B9B856 /* btConvexHullComputer.h in Headers */, B665E2411AA80A6500DDB1C5 /* CCPUCircleEmitterTranslator.h in Headers */, B6CAB2BA1AF9AA1A00B9B856 /* btConvexTriangleMeshShape.h in Headers */, @@ -10395,13 +10395,12 @@ B6DD2FE01B04825B00E47F5F /* DetourObstacleAvoidance.h in Headers */, B6CAB5081AF9AA1A00B9B856 /* btGeometryUtil.h in Headers */, 1A5702F1180BCE750088DEC7 /* CCTMXLayer.h in Headers */, - 15FB20771AE7BF8600C31518 /* MarchingSquare.h in Headers */, + 15FB20771AE7BF8600C31518 /* CCAutoPolygon.h in Headers */, B6CAB4F81AF9AA1A00B9B856 /* btAlignedAllocator.h in Headers */, 15AE18AE19AAD33D00C27E9E /* CCBFileLoader.h in Headers */, B6CAB2D41AF9AA1A00B9B856 /* btMultiSphereShape.h in Headers */, 15AE197819AAD35700C27E9E /* CCActionTimeline.h in Headers */, B6CAAFF11AF9A9E100B9B856 /* CCPhysics3DDebugDrawer.h in Headers */, - 15FB206D1AE7BE7400C31518 /* SpritePolygon.h in Headers */, 15AE1AA019AAD40300C27E9E /* b2Timer.h in Headers */, 5034CA44191D591100CE6051 /* ccShader_Label.vert in Headers */, 1A5702F5180BCE750088DEC7 /* CCTMXObjectGroup.h in Headers */, @@ -11113,6 +11112,7 @@ B6CAB4C51AF9AA1A00B9B856 /* boxBoxDistance.cpp in Sources */, B6CAB29F1AF9AA1A00B9B856 /* btConvex2dShape.cpp in Sources */, B6CAB4331AF9AA1A00B9B856 /* btGpu3DGridBroadphase.cpp in Sources */, + 85B3743A1B204B9400C488D6 /* clipper.cpp in Sources */, 15AE1A8819AAD40300C27E9E /* b2PrismaticJoint.cpp in Sources */, 182C5CB21A95964700C30D34 /* Node3DReader.cpp in Sources */, 50ABBE491925AB6F00A911A9 /* CCEventAcceleration.cpp in Sources */, @@ -11250,7 +11250,6 @@ 50ABC0191926664800A911A9 /* CCSAXParser.cpp in Sources */, 15AE189219AAD33D00C27E9E /* CCLayerGradientLoader.cpp in Sources */, B6CAB4471AF9AA1A00B9B856 /* btThreadSupportInterface.cpp in Sources */, - 15FB206E1AE7BE7400C31518 /* SpritePolygonCache.cpp in Sources */, 15AE1B6A19AADA9900C27E9E /* UIDeprecated.cpp in Sources */, 15AE183C19AAD2F700C27E9E /* CCSkeleton3D.cpp in Sources */, B6CAB36F1AF9AA1A00B9B856 /* btGjkConvexCast.cpp in Sources */, @@ -11366,7 +11365,7 @@ 15AE199A19AAD39600C27E9E /* PageViewReader.cpp in Sources */, 1A57030C180BCF190088DEC7 /* CCComponent.cpp in Sources */, 382383F61A258FA7002C4610 /* idl_gen_fbs.cpp in Sources */, - 15FB20741AE7BF8600C31518 /* MarchingSquare.cpp in Sources */, + 15FB20741AE7BF8600C31518 /* CCAutoPolygon.cpp in Sources */, B665E2A61AA80A6500DDB1C5 /* CCPUEventHandlerTranslator.cpp in Sources */, 15AE1A5919AAD40300C27E9E /* b2StackAllocator.cpp in Sources */, B6CAB20B1AF9AA1A00B9B856 /* btQuantizedBvh.cpp in Sources */, @@ -11390,7 +11389,6 @@ B665E2721AA80A6500DDB1C5 /* CCPUDoPlacementParticleEventHandler.cpp in Sources */, 50ABBD3C1925AB0000A911A9 /* CCGeometry.cpp in Sources */, B6CAB3C31AF9AA1A00B9B856 /* btHingeConstraint.cpp in Sources */, - 15FB206A1AE7BE7400C31518 /* SpritePolygon.cpp in Sources */, B29A7DDD19EE1B7700872B35 /* BoneData.c in Sources */, 15AE188A19AAD33D00C27E9E /* CCControlLoader.cpp in Sources */, 5012168E1AC47380009A4BEA /* CCRenderState.cpp in Sources */, @@ -11990,8 +11988,8 @@ 15AE18AB19AAD33D00C27E9E /* CCBAnimationManager.cpp in Sources */, 15AE1B7219AADA9A00C27E9E /* UIListView.cpp in Sources */, 1A5701BE180BCB5A0088DEC7 /* CCLabelAtlas.cpp in Sources */, + 15FB20751AE7BF8600C31518 /* CCAutoPolygon.cpp in Sources */, B6CAB2021AF9AA1A00B9B856 /* btMultiSapBroadphase.cpp in Sources */, - 15FB20751AE7BF8600C31518 /* MarchingSquare.cpp in Sources */, 15AE1A3D19AAD3D500C27E9E /* b2CollideEdge.cpp in Sources */, 1A5701C2180BCB5A0088DEC7 /* CCLabelBMFont.cpp in Sources */, 1A087AE91860400400196EF5 /* edtaa3func.cpp in Sources */, @@ -12280,7 +12278,6 @@ B6CAB2AC1AF9AA1A00B9B856 /* btConvexPointCloudShape.cpp in Sources */, B6CAB22C1AF9AA1A00B9B856 /* btCollisionObject.cpp in Sources */, 15AE183919AAD2F700C27E9E /* CCRay.cpp in Sources */, - 15FB206B1AE7BE7400C31518 /* SpritePolygon.cpp in Sources */, 15AE1B8219AADA9A00C27E9E /* UITextBMFont.cpp in Sources */, B6CAB29C1AF9AA1A00B9B856 /* btConeShape.cpp in Sources */, 50ABBE6A1925AB6F00A911A9 /* CCEventListenerFocus.cpp in Sources */, @@ -12357,7 +12354,6 @@ B665E29F1AA80A6500DDB1C5 /* CCPUEventHandler.cpp in Sources */, 15AE195519AAD35100C27E9E /* CCDisplayManager.cpp in Sources */, B665E43B1AA80A6600DDB1C5 /* CCPUVortexAffectorTranslator.cpp in Sources */, - 15FB206F1AE7BE7400C31518 /* SpritePolygonCache.cpp in Sources */, 15AE1BA719AADFDF00C27E9E /* UIRelativeBox.cpp in Sources */, 15AE1ACE19AAD40300C27E9E /* b2PulleyJoint.cpp in Sources */, B665E2DF1AA80A6500DDB1C5 /* CCPULineAffector.cpp in Sources */, @@ -12373,6 +12369,7 @@ B665E3131AA80A6500DDB1C5 /* CCPUObserverManager.cpp in Sources */, 50CB248019D9C5A100687767 /* AudioPlayer.mm in Sources */, 50ABBE9A1925AB6F00A911A9 /* CCRef.cpp in Sources */, + 85B3743B1B204B9400C488D6 /* clipper.cpp in Sources */, 15AE18BF19AAD33D00C27E9E /* CCLabelTTFLoader.cpp in Sources */, B6CAB27E1AF9AA1A00B9B856 /* btBox2dShape.cpp in Sources */, 15AE1B9519AADA9A00C27E9E /* CocosGUI.cpp in Sources */, diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index b38c10b28e..88669d2829 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -5925,6 +5925,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../tests/cpp-tests/proj.ios/Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -5938,6 +5939,7 @@ "$(inherited)", "$(SRCROOT)/../external/curl/prebuilt/ios", ); + PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../cocos/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios"; @@ -5949,6 +5951,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "../tests/cpp-tests/proj.ios/Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -5962,6 +5965,7 @@ "$(inherited)", "$(SRCROOT)/../external/curl/prebuilt/ios", ); + PROVISIONING_PROFILE = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../cocos/platform/ios/Simulation $(SRCROOT)/../external/curl/include/ios"; diff --git a/cocos/2d/CCAutoPolygon.cpp b/cocos/2d/CCAutoPolygon.cpp new file mode 100644 index 0000000000..a07eb7d0d3 --- /dev/null +++ b/cocos/2d/CCAutoPolygon.cpp @@ -0,0 +1,669 @@ +/**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#include "CCAutoPolygon.h" +#include "poly2tri/poly2tri.h" +#include "base/CCDirector.h" +#include "renderer/CCTextureCache.h" +#include "clipper/clipper.hpp" +#include +#include + +USING_NS_CC; + +static unsigned short quadIndices[]={0,1,2, 3,2,1}; +const static float PRECISION = 10.0f; + +PolygonInfo::PolygonInfo(const PolygonInfo& other): +triangles(), +isVertsOwner(true), +rect() +{ + filename = other.filename; + isVertsOwner = other.isVertsOwner; + rect = other.rect; + triangles.verts = new V3F_C4B_T2F[other.triangles.vertCount]; + triangles.indices = new unsigned short[other.triangles.indexCount]; + triangles.vertCount = other.triangles.vertCount; + triangles.indexCount = other.triangles.indexCount; + memcpy(triangles.verts, other.triangles.verts, other.triangles.vertCount*sizeof(V3F_C4B_T2F)); + memcpy(triangles.indices, other.triangles.indices, other.triangles.indexCount*sizeof(unsigned short)); +}; + +PolygonInfo& PolygonInfo::operator= (const PolygonInfo& other) +{ + if(this != &other) + { + releaseVertsAndIndices(); + filename = other.filename; + isVertsOwner = other.isVertsOwner; + rect = other.rect; + triangles.verts = new V3F_C4B_T2F[other.triangles.vertCount]; + triangles.indices = new unsigned short[other.triangles.indexCount]; + triangles.vertCount = other.triangles.vertCount; + triangles.indexCount = other.triangles.indexCount; + memcpy(triangles.verts, other.triangles.verts, other.triangles.vertCount*sizeof(V3F_C4B_T2F)); + memcpy(triangles.indices, other.triangles.indices, other.triangles.indexCount*sizeof(unsigned short)); + } + return *this; +} + +PolygonInfo::~PolygonInfo() +{ + releaseVertsAndIndices(); +} + +void PolygonInfo::setQuad(V3F_C4B_T2F_Quad *quad) +{ + releaseVertsAndIndices(); + isVertsOwner = false; + triangles.indices = quadIndices; + triangles.vertCount = 4; + triangles.indexCount = 6; + triangles.verts = (V3F_C4B_T2F*)quad; +} + +void PolygonInfo::releaseVertsAndIndices() +{ + if(isVertsOwner) + { + if(nullptr != triangles.verts) + { + CC_SAFE_DELETE_ARRAY(triangles.verts); + } + + if(nullptr != triangles.indices) + { + CC_SAFE_DELETE_ARRAY(triangles.indices); + } + } +} + +const unsigned int PolygonInfo::getVertCount() const +{ + return (unsigned int)triangles.vertCount; +} + +const unsigned int PolygonInfo::getTriaglesCount() const +{ + return (unsigned int)triangles.indexCount/3; +} + +const float PolygonInfo::getArea() const +{ + float area = 0; + V3F_C4B_T2F *verts = triangles.verts; + unsigned short *indices = triangles.indices; + for(int i = 0; i < triangles.indexCount; i+=3) + { + auto A = verts[indices[i]].vertices; + auto B = verts[indices[i+1]].vertices; + auto C = verts[indices[i+2]].vertices; + area += (A.x*(B.y-C.y) + B.x*(C.y-A.y) + C.x*(A.y - B.y))/2; + } + return area; +} + +AutoPolygon::AutoPolygon(const std::string &filename) +:_image(nullptr) +,_data(nullptr) +,_filename("") +,_width(0) +,_height(0) +,_scaleFactor(0) +{ + _filename = filename; + _image = new Image(); + _image->initWithImageFile(filename); + CCASSERT(_image->getRenderFormat()==Texture2D::PixelFormat::RGBA8888, "unsupported format, currently only supports rgba8888"); + _data = _image->getData(); + _width = _image->getWidth(); + _height = _image->getHeight(); + _scaleFactor = Director::getInstance()->getContentScaleFactor(); +} + +AutoPolygon::~AutoPolygon() +{ + CC_SAFE_DELETE(_image); +} + +std::vector AutoPolygon::trace(const Rect& rect, const float& threshold) +{ + Vec2 first = findFirstNoneTransparentPixel(rect, threshold); + return marchSquare(rect, first, threshold); +} + +Vec2 AutoPolygon::findFirstNoneTransparentPixel(const Rect& rect, const float& threshold) +{ + bool found = false; + Vec2 i; + for(i.y = rect.origin.y; i.y < rect.origin.y+rect.size.height; i.y++) + { + if(found)break; + for(i.x = rect.origin.x; i.x < rect.origin.x+rect.size.width; i.x++) + { + auto alpha = getAlphaByPos(i); + if(alpha>threshold) + { + found = true; + break; + } + } + } + CCASSERT(found, "image is all transparent!"); + return i; +} + +unsigned char AutoPolygon::getAlphaByIndex(const unsigned int& i) +{ + return *(_data+i*4+3); +} +unsigned char AutoPolygon::getAlphaByPos(const Vec2& pos) +{ + return *(_data+((int)pos.y*_width+(int)pos.x)*4+3); +} + +unsigned int AutoPolygon::getSquareValue(const unsigned int& x, const unsigned int& y, const Rect& rect, const float& threshold) +{ + /* + checking the 2x2 pixel grid, assigning these values to each pixel, if not transparent + +---+---+ + | 1 | 2 | + +---+---+ + | 4 | 8 | <- current pixel (curx,cury) + +---+---+ + */ + unsigned int sv = 0; + //NOTE: due to the way we pick points from texture, rect needs to be smaller, otherwise it goes outside 1 pixel + auto fixedRect = Rect(rect.origin, rect.size-Size(2,2)); + + Vec2 tl = Vec2(x-1, y-1); + sv += (fixedRect.containsPoint(tl) && getAlphaByPos(tl) > threshold)? 1 : 0; + Vec2 tr = Vec2(x, y-1); + sv += (fixedRect.containsPoint(tr) && getAlphaByPos(tr) > threshold)? 2 : 0; + Vec2 bl = Vec2(x-1, y); + sv += (fixedRect.containsPoint(bl) && getAlphaByPos(bl) > threshold)? 4 : 0; + Vec2 br = Vec2(x, y); + sv += (fixedRect.containsPoint(br) && getAlphaByPos(br) > threshold)? 8 : 0; + CCASSERT(sv != 0 && sv != 15, "square value should not be 0, or 15"); + return sv; +} + +std::vector AutoPolygon::marchSquare(const Rect& rect, const Vec2& start, const float& threshold) +{ + int stepx = 0; + int stepy = 0; + int prevx = 0; + int prevy = 0; + int startx = start.x; + int starty = start.y; + int curx = startx; + int cury = starty; + unsigned int count = 0; + unsigned int totalPixel = _width*_height; + bool problem = false; + std::vector case9s; + std::vector case6s; + int i; + std::vector::iterator it; + std::vector _points; + do{ + int sv = getSquareValue(curx, cury, rect, threshold); + switch(sv){ + + case 1: + case 5: + case 13: + /* going UP with these cases: + 1 5 13 + +---+---+ +---+---+ +---+---+ + | 1 | | | 1 | | | 1 | | + +---+---+ +---+---+ +---+---+ + | | | | 4 | | | 4 | 8 | + +---+---+ +---+---+ +---+---+ + */ + stepx = 0; + stepy = -1; + break; + + + case 8: + case 10: + case 11: + /* going DOWN with these cases: + 8 10 11 + +---+---+ +---+---+ +---+---+ + | | | | | 2 | | 1 | 2 | + +---+---+ +---+---+ +---+---+ + | | 8 | | | 8 | | | 8 | + +---+---+ +---+---+ +---+---+ + */ + stepx = 0; + stepy = 1; + break; + + + case 4: + case 12: + case 14: + /* going LEFT with these cases: + 4 12 14 + +---+---+ +---+---+ +---+---+ + | | | | | | | | 2 | + +---+---+ +---+---+ +---+---+ + | 4 | | | 4 | 8 | | 4 | 8 | + +---+---+ +---+---+ +---+---+ + */ + stepx = -1; + stepy = 0; + break; + + + case 2 : + case 3 : + case 7 : + /* going RIGHT with these cases: + 2 3 7 + +---+---+ +---+---+ +---+---+ + | | 2 | | 1 | 2 | | 1 | 2 | + +---+---+ +---+---+ +---+---+ + | | | | | | | 4 | | + +---+---+ +---+---+ +---+---+ + */ + stepx=1; + stepy=0; + break; + case 9 : + /* + +---+---+ + | 1 | | + +---+---+ + | | 8 | + +---+---+ + this should normaly go UP, but if we already been here, we go down + */ + //find index from xy; + i = getIndexFromPos(curx, cury); + it = find (case9s.begin(), case9s.end(), i); + if (it != case9s.end()) + { + //found, so we go down, and delete from case9s; + stepx = 0; + stepy = 1; + case9s.erase(it); + problem = true; + } + else + { + //not found, we go up, and add to case9s; + stepx = 0; + stepy = -1; + case9s.push_back(i); + } + break; + case 6 : + /* + 6 + +---+---+ + | | 2 | + +---+---+ + | 4 | | + +---+---+ + this normally go RIGHT, but if its coming from UP, it should go LEFT + */ + i = getIndexFromPos(curx, cury); + it = find (case6s.begin(), case6s.end(), i); + if (it != case6s.end()) + { + //found, so we go down, and delete from case9s; + stepx = -1; + stepy = 0; + case6s.erase(it); + problem = true; + } + else{ + //not found, we go up, and add to case9s; + stepx = 1; + stepy = 0; + case6s.push_back(i); + } + break; + default: + CCLOG("this shouldn't happen."); + } + //little optimization + // if previous direction is same as current direction, + // then we should modify the last vec to current + curx += stepx; + cury += stepy; + if(stepx == prevx && stepy == prevy) + { + _points.back().x = (float)(curx-rect.origin.x) / _scaleFactor; + _points.back().y = (float)(rect.size.height - cury + rect.origin.y) / _scaleFactor; + } + else if(problem) + { + //TODO: we triangulation cannot work collineer points, so we need to modify same point a little + //TODO: maybe we can detect if we go into a hole and coming back the hole, we should extract those points and remove them + _points.push_back(Vec2((float)(curx- rect.origin.x) / _scaleFactor, (float)(rect.size.height - cury + rect.origin.y) / _scaleFactor)); + } + else{ + _points.push_back(Vec2((float)(curx-rect.origin.x) / _scaleFactor, (float)(rect.size.height - cury + rect.origin.y) / _scaleFactor)); + } + + count++; + prevx = stepx; + prevy = stepy; + problem = false; + CCASSERT(count <= totalPixel, "oh no, marching square cannot find starting position"); + } while(curx != startx || cury != starty); + return _points; +} + +float AutoPolygon::perpendicularDistance(const cocos2d::Vec2& i, const cocos2d::Vec2& start, const cocos2d::Vec2& end) +{ + float res; + float slope; + float intercept; + + if(start.x == end.x) + { + res = fabsf(i.x- end.x); + } + else if (start.y == end.y) + { + res = fabsf(i.y - end.y); + } + else{ + slope = (end.y - start.y) / (end.x - start.x); + intercept = start.y - (slope*start.x); + res = fabsf(slope * i.x - i.y + intercept) / sqrtf(powf(slope, 2)+1); + } + return res; +} +std::vector AutoPolygon::rdp(std::vector v, const float& optimization) +{ + if(v.size() < 3) + return v; + + int index = -1; + float dist = 0; + //not looping first and last point + for(size_t i = 1; i < v.size()-1; i++) + { + float cdist = perpendicularDistance(v[i], v.front(), v.back()); + if(cdist > dist) + { + dist = cdist; + index = i; + } + } + if (dist>optimization) + { + std::vector::const_iterator begin = v.begin(); + std::vector::const_iterator end = v.end(); + std::vector l1(begin, begin+index+1); + std::vector l2(begin+index, end); + + std::vector r1 = rdp(l1, optimization); + std::vector r2 = rdp(l2, optimization); + + r1.insert(r1.end(), r2.begin()+1, r2.end()); + return r1; + } + else { + std::vector ret; + ret.push_back(v.front()); + ret.push_back(v.back()); + return ret; + } +} +std::vector AutoPolygon::reduce(const std::vector& points, const Rect& rect , const float& epsilon) +{ + auto size = points.size(); + // if there are less than 3 points, then we have nothing + if(size<3) + { + log("AUTOPOLYGON: cannot reduce points for %s that has less than 3 points in input, e: %f", _filename.c_str(), epsilon); + return std::vector(); + } + // if there are less than 9 points (but more than 3), then we don't need to reduce it + else if (size < 9) + { + log("AUTOPOLYGON: cannot reduce points for %s e: %f",_filename.c_str(), epsilon); + return points; + } + float maxEp = MIN(rect.size.width, rect.size.height); + float ep = clampf(epsilon, 0.0, maxEp/_scaleFactor/2); + std::vector result = rdp(points, ep); + + auto last = result.back(); + if(last.y > result.front().y && last.getDistance(result.front()) < ep*0.5) + { + result.front().y = last.y; + result.pop_back(); + } + return result; +} + +std::vector AutoPolygon::expand(const std::vector& points, const cocos2d::Rect &rect, const float& epsilon) +{ + auto size = points.size(); + // if there are less than 3 points, then we have nothig + if(size<3) + { + log("AUTOPOLYGON: cannot expand points for %s with less than 3 points, e: %f", _filename.c_str(), epsilon); + return std::vector(); + } + ClipperLib::Path subj; + ClipperLib::PolyTree solution; + ClipperLib::PolyTree out; + for(std::vector::const_iterator it = points.begin(); it x* PRECISION, it->y * PRECISION); + } + ClipperLib::ClipperOffset co; + co.AddPath(subj, ClipperLib::jtMiter, ClipperLib::etClosedPolygon); + co.Execute(solution, epsilon * PRECISION); + + ClipperLib::PolyNode* p = solution.GetFirst(); + if(!p) + { + log("AUTOPOLYGON: Clipper failed to expand the points"); + return points; + } + while(p->IsHole()){ + p = p->GetNext(); + } + + //turn the result into simply polygon (AKA, fix overlap) + + //clamp into the specified rect + ClipperLib::Clipper cl; + cl.StrictlySimple(true); + cl.AddPath(p->Contour, ClipperLib::ptSubject, true); + //create the clipping rect + ClipperLib::Path clamp; + clamp.push_back(ClipperLib::IntPoint(0, 0)); + clamp.push_back(ClipperLib::IntPoint(rect.size.width/_scaleFactor * PRECISION, 0)); + clamp.push_back(ClipperLib::IntPoint(rect.size.width/_scaleFactor * PRECISION, rect.size.height/_scaleFactor * PRECISION)); + clamp.push_back(ClipperLib::IntPoint(0, rect.size.height/_scaleFactor * PRECISION)); + cl.AddPath(clamp, ClipperLib::ptClip, true); + cl.Execute(ClipperLib::ctIntersection, out); + + std::vector outPoints; + ClipperLib::PolyNode* p2 = out.GetFirst(); + while(p2->IsHole()){ + p2 = p2->GetNext(); + } + auto end = p2->Contour.end(); + for(std::vector::const_iterator pt = p2->Contour.begin(); pt < end; pt++) + { + outPoints.push_back(Vec2(pt->X/PRECISION, pt->Y/PRECISION)); + } + return outPoints; +} + +TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector& points) +{ + // if there are less than 3 points, then we can't triangulate + if(points.size()<3) + { + log("AUTOPOLYGON: cannot triangulate %s with less than 3 points", _filename.c_str()); + return TrianglesCommand::Triangles(); + } + std::vector p2points; + for(std::vector::const_iterator it = points.begin(); itx, it->y); + p2points.push_back(p); + } + p2t::CDT cdt(p2points); + cdt.Triangulate(); + std::vector tris = cdt.GetTriangles(); + + V3F_C4B_T2F* verts= new V3F_C4B_T2F[points.size()]; + unsigned short* indices = new unsigned short[tris.size()*3]; + unsigned short idx = 0; + unsigned short vdx = 0; + + for(std::vector::const_iterator ite = tris.begin(); ite < tris.end(); ite++) + { + for(int i = 0; i < 3; i++) + { + auto p = (*ite)->GetPoint(i); + auto v3 = Vec3(p->x, p->y, 0); + bool found = false; + size_t j; + size_t length = vdx; + for(j = 0; j < length; j++) + { + if(verts[j].vertices == v3) + { + found = true; + break; + } + } + if(found) + { + //if we found the same vertice, don't add to verts, but use the same vert with indices + indices[idx] = j; + idx++; + } + else + { + //vert does not exist yet, so we need to create a new one, + auto c4b = Color4B::WHITE; + auto t2f = Tex2F(0,0); // don't worry about tex coords now, we calculate that later + V3F_C4B_T2F vert = {v3,c4b,t2f}; + verts[vdx] = vert; + indices[idx] = vdx; + idx++; + vdx++; + } + } + } + for(auto j : p2points) + { + delete j; + }; + TrianglesCommand::Triangles triangles = {verts, indices, vdx, idx}; + return triangles; +} + +void AutoPolygon::calculateUV(const Rect& rect, V3F_C4B_T2F* verts, const ssize_t& count) +{ + /* + whole texture UV coordination + 0,0 1,0 + +---------------------+ + | |0.1 + | |0.2 + | +--------+ |0.3 + | |texRect | |0.4 + | | | |0.5 + | | | |0.6 + | +--------+ |0.7 + | |0.8 + | |0.9 + +---------------------+ + 0,1 1,1 + */ + + CCASSERT(_width && _height, "please specify width and height for this AutoPolygon instance"); + float texWidth = _width; + float texHeight = _height; + + auto end = &verts[count]; + for(auto i = verts; i != end; i++) + { + // for every point, offcset with the centerpoint + float u = (i->vertices.x*_scaleFactor + rect.origin.x) / texWidth; + float v = (rect.origin.y+rect.size.height - i->vertices.y*_scaleFactor) / texHeight; + i->texCoords.u = u; + i->texCoords.v = v; + } +} + +Rect AutoPolygon::getRealRect(const Rect& rect) +{ + Rect realRect = rect; + //check rect to see if its zero + if(realRect.equals(Rect::ZERO)) + { + //if the instance doesn't have width and height, then the whole operation is kaput + CCASSERT(_height && _width, "Please specify a width and height for this instance before using its functions"); + realRect = Rect(0,0, _width, _height); + } + else{ + //rect is specified, so convert to real rect + auto scale = Director::getInstance()->getContentScaleFactor(); + realRect = Rect(rect.origin*scale, rect.size*scale); + } + return realRect; +} + +PolygonInfo AutoPolygon::generateTriangles(const Rect& rect, const float& epsilon, const float& threshold) +{ + Rect realRect = getRealRect(rect); + auto p = trace(realRect, threshold); + p = reduce(p, realRect, epsilon); + p = expand(p, realRect, epsilon); + auto tri = triangulate(p); + calculateUV(realRect, tri.verts, tri.vertCount); + PolygonInfo ret; + ret.triangles = tri; + ret.filename = _filename; + ret.rect = realRect; + return ret; +} +PolygonInfo AutoPolygon::generatePolygon(const std::string& filename, const Rect& rect, const float epsilon, const float threshold) +{ + AutoPolygon ap(filename); + auto ret = ap.generateTriangles(rect, epsilon, threshold); + return ret; +} diff --git a/cocos/2d/CCAutoPolygon.h b/cocos/2d/CCAutoPolygon.h new file mode 100644 index 0000000000..e20ac0b000 --- /dev/null +++ b/cocos/2d/CCAutoPolygon.h @@ -0,0 +1,269 @@ +/**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#ifndef COCOS_2D_CCAUTOPOLYGON_H__ +#define COCOS_2D_CCAUTOPOLYGON_H__ + +#include +#include +#include "platform/CCImage.h" +#include "renderer/CCTrianglesCommand.h" + +NS_CC_BEGIN + +/** + * @addtogroup _2d + * @{ + */ + +/** + * PolygonInfo is an object holding the required data to display Sprites。 + * It can be a simple as a triangle, or as complex as a whole 3D mesh + */ +class CC_DLL PolygonInfo +{ +public: + /// @name Creators + /// @{ + /** + * Creates an empty Polygon info + * @memberof PolygonInfo + * @return PolygonInfo object + */ + PolygonInfo(): + isVertsOwner(true), + rect(cocos2d::Rect::ZERO), + filename("") + { + triangles.verts = nullptr; + triangles.indices = nullptr; + triangles.vertCount = 0; + triangles.indexCount = 0; + }; + + /** + * Create an polygoninfo from the data of another Polygoninfo + * @param other another PolygonInfo to be copied + * @return duplicate of the other PolygonInfo + */ + PolygonInfo(const PolygonInfo& other); + // end of creators group + /// @} + + /** + * Copy the member of the other PolygonInfo + * @param other another PolygonInfo to be copied + */ + PolygonInfo& operator= (const PolygonInfo &other); + ~PolygonInfo(); + + /** + * set the data to be a pointer to a quad + * the member verts will not be released when this PolygonInfo destructs + * as the verts memory are managed by other objects + * @param quad a pointer to the V3F_C4B_T2F_Quad obje + */ + void setQuad(V3F_C4B_T2F_Quad *quad); + + /** + * get vertex count + * @return number of vertices + */ + const unsigned int getVertCount() const; + + /** + * get triangles count + * @return number of triangles + */ + const unsigned int getTriaglesCount() const; + + /** + * get sum of all triangle area size + * @return sum of all triangle area size + */ + const float getArea() const; + + Rect rect; + std::string filename; + TrianglesCommand::Triangles triangles; + +protected: + bool isVertsOwner; + +private: + void releaseVertsAndIndices(); +}; + + +/** + * AutoPolygon is a helper Object + * AutoPolygon's purpose is to process an image into 2d polygon mesh in runtime + * It has functions for each step in the process, from tracing all the points, to triangulation + * the result can be then passed to Sprite::create() to create a Polygon Sprite + */ +class CC_DLL AutoPolygon +{ +public: + /** + * create an AutoPolygon and initialize it with an image file + * the image must be a 32bit PNG for current version 3.7 + * @param filename a path to image file, e.g., "scene1/monster.png". + * @return an AutoPolygon object; + */ + AutoPolygon(const std::string &filename); + + /** + * Destructor of AutoPolygon. + */ + ~AutoPolygon(); + + /** + * trace all the points along the outline of the image, + * @warning must create AutoPolygon with filename to use this function + * @param rect a texture rect for specify an area of the image, use Rect::Zero for the size of the image, default to Rect::Zero + * @param threshold the value when alpha is greater than this value will be counted as opaque, default to 0.0 + * @return a vector of vec2 of all the points found in clockwise order + * @code + * auto ap = AutoPolygon("grossini.png"); + * std::vector points = ap.trace();//default to size of the image and threshold 0.0 + * @endcode + */ + std::vector trace(const cocos2d::Rect& rect, const float& threshold = 0.0); + + /** + * reduce the ammount of points so its faster for GPU to process and draw + * based on Ramer-Douglas-Puecker algorithm + * @param points a vector of Vec2 points as input + * @param rect a texture rect for specify an area of the image to avoid over reduction + * @param epsilon the perpendicular distance where points smaller than this value will be discarded + * @return a vector of Vec2 of the remaining points in clockwise order + * @code + * auto ap = AutoPolygon(); + * std::vector reduced = ap.reduce(inputPoints, rect);//default epsilon is 2 + * @endcode + */ + std::vector reduce(const std::vector& points, const Rect& rect, const float& epsilon = 2.0); + + /** + * expand the points along their edge, useful after you reduce the points that cuts into the sprite + * using ClipperLib + * @param points a vector of Vec2 points as input + * @param rect a texture rect for specify an area of the image, the expanded points will be clamped in this rect, ultimately resulting in a quad if the expansion is too great + * @param epsilon the distance which the edges will expand + * @return a vector of Vec2 as the result of the expansion + * @code + * auto ap = AutoPolygon(); + * std::vector expanded = ap.expand(inputPoints, rect, 2.0); + * @endcode + */ + std::vector expand(const std::vector& points, const Rect& rect, const float& epsilon); + + /** + * Triangulate the input points into triangles for rendering + * using poly2tri + * @warning points must be closed loop, cannot have 2 points sharing the same position and cannot intersect itself + * @param points a vector of vec2 points as input + * @return a Triangles object with points and indices + * @code + * auto ap = AutoPolygon(); + * TrianglesCommand::Triangles myPolygons = ap.triangulate(myPoints); + * @endcode + */ + TrianglesCommand::Triangles triangulate(const std::vector& points); + + /** + * calculate the UV coordinates for each points based on a texture rect + * @warning This method requires the AutoPolygon object to know the texture file dimension + * @param rect a texture rect to specify where to map the UV + * @param verts a pointer to the verts array, served both as input and output verts + * @param count the count for the verts arrac + * @code + * auto ap = AutoPolygon("grossini.png"); + * TrianglesCommand::Triangles myPolygons = ap.triangulate(myPoints); + * ap.calculateUV(rect, myPolygons.verts, 20); + * @endcode + */ + void calculateUV(const Rect& rect, V3F_C4B_T2F* verts, const ssize_t& count); + + /** + * a helper function, packing trace, reduce, expand, triangulate and calculate uv in one function + * @param rect texture rect, use Rect::ZERO for the size of the texture, default is Rect::ZERO + * @param epsilon the value used to reduce and expand, default to 2.0 + * @param threshold the value where bigger than the threshold will be counted as opaque, used in trace + * @return a PolygonInfo, to use with sprite + * @code + * auto ap = AutoPolygon("grossini.png"); + * PolygonInfo myInfo = ap.generateTriangles();//use all default values + * auto sp1 = Sprite::create(myInfo); + * polygonInfo myInfo2 = ap.generateTriangles(Rect::ZERO, 5.0, 0.1);//ap can be reused to generate another set of PolygonInfo with different settings + * auto sp2 = Sprite::create(myInfo2); + * @endcode + */ + PolygonInfo generateTriangles(const Rect& rect = Rect::ZERO, const float& epsilon = 2.0, const float& threshold = 0.05); + + /** + * a helper function, packing autoPolygon creation, trace, reduce, expand, triangulate and calculate uv in one function + * @warning if you want to repetitively generate polygons, consider create an AutoPolygon object, and use generateTriangles function, as it only reads the file once + * @param filename A path to image file, e.g., "scene1/monster.png". + * @param rect texture rect, use Rect::ZERO for the size of the texture, default is Rect::ZERO + * @param epsilon the value used to reduce and expand, default to 2.0 + * @param threshold the value where bigger than the threshold will be counted as opaque, used in trace + * @return a PolygonInfo, to use with sprite + * @code + * auto sp = Sprite::create(AutoPolygon::generatePolygon("grossini.png")); + * @endcode + */ + static PolygonInfo generatePolygon(const std::string& filename, const Rect& rect = Rect::ZERO, const float epsilon = 2.0, const float threshold = 0.05); +protected: + Vec2 findFirstNoneTransparentPixel(const Rect& rect, const float& threshold); + std::vector marchSquare(const Rect& rect, const Vec2& first, const float& threshold); + unsigned int getSquareValue(const unsigned int& x, const unsigned int& y, const Rect& rect, const float& threshold); + + unsigned char getAlphaByIndex(const unsigned int& i); + unsigned char getAlphaByPos(const Vec2& pos); + + int getIndexFromPos(const unsigned int& x, const unsigned int& y){return y*_width+x;}; + cocos2d::Vec2 getPosFromIndex(const unsigned int& i){return cocos2d::Vec2(i%_width, i/_width);}; + + std::vector rdp(std::vector v, const float& optimization); + float perpendicularDistance(const cocos2d::Vec2& i, const cocos2d::Vec2& start, const cocos2d::Vec2& end); + + //real rect is the size that is in scale with the texture file + Rect getRealRect(const Rect& rect); + + Image* _image; + unsigned char * _data; + std::string _filename; + unsigned int _width; + unsigned int _height; + float _scaleFactor; + unsigned int _threshold; +}; + +NS_CC_END + +#endif // #ifndef COCOS_2D_CCAUTOPOLYGON_H__ \ No newline at end of file diff --git a/cocos/2d/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp index 3312bbc8dc..c5b3096c8f 100644 --- a/cocos/2d/CCFontFreeType.cpp +++ b/cocos/2d/CCFontFreeType.cpp @@ -343,7 +343,6 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid } } - xAdvance += 2 * _outlineSize; outRect.size.width = blendWidth; outRect.size.height = blendHeight; outWidth = blendWidth; diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index cc031af230..8a37a60c16 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -955,24 +955,41 @@ void Label::onDraw(const Mat4& transform, bool transformUpdated) } } - if (_currentLabelType == LabelType::TTF) - { - glprogram->setUniformLocationWith4f(_uniformTextColor, - _textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a); - - if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW) - { - glprogram->setUniformLocationWith4f(_uniformEffectColor, - _effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a); - } - } - glprogram->setUniformsForBuiltins(transform); - for(const auto &child: _children) { child->updateTransform(); } + + if (_currentLabelType == LabelType::TTF) + { + switch (_currLabelEffect) { + case LabelEffect::OUTLINE: + //draw text with outline + glprogram->setUniformLocationWith4f(_uniformTextColor, + _textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a); + glprogram->setUniformLocationWith4f(_uniformEffectColor, + _effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a); + for (const auto& batchNode:_batchNodes) + { + batchNode->getTextureAtlas()->drawQuads(); + } + + //draw text without outline + glprogram->setUniformLocationWith4f(_uniformEffectColor, + _effectColorF.r, _effectColorF.g, _effectColorF.b, 0.f); + break; + case LabelEffect::GLOW: + glprogram->setUniformLocationWith4f(_uniformEffectColor, + _effectColorF.r, _effectColorF.g, _effectColorF.b, _effectColorF.a); + case LabelEffect::NORMAL: + glprogram->setUniformLocationWith4f(_uniformTextColor, + _textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a); + break; + default: + break; + } + } for (const auto& batchNode:_batchNodes) { diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index b134fdabdf..2cff686d9c 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -401,7 +401,7 @@ void Node::updateRotation3D() float x = _rotationQuat.x, y = _rotationQuat.y, z = _rotationQuat.z, w = _rotationQuat.w; _rotationX = atan2f(2.f * (w * x + y * z), 1.f - 2.f * (x * x + y * y)); _rotationY = asinf(2.f * (w * y - z * x)); - _rotationZ_X = atanf(2.f * (w * z + x * y) / (1.f - 2.f * (y * y + z * z))); + _rotationZ_X = atan2f(2.f * (w * z + x * y), 1.f - 2.f * (y * y + z * z)); _rotationX = CC_RADIANS_TO_DEGREES(_rotationX); _rotationY = CC_RADIANS_TO_DEGREES(_rotationY); diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 656f4bf605..5482e8934c 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -86,6 +86,18 @@ Sprite* Sprite::create(const std::string& filename) return nullptr; } +Sprite* Sprite::create(const PolygonInfo& info) +{ + Sprite *sprite = new (std::nothrow) Sprite(); + if(sprite && sprite->initWithPolygon(info)) + { + sprite->autorelease(); + return sprite; + } + CC_SAFE_DELETE(sprite); + return nullptr; +} + Sprite* Sprite::create(const std::string& filename, const Rect& rect) { Sprite *sprite = new (std::nothrow) Sprite(); @@ -207,6 +219,19 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *spriteFrame) return bRet; } +bool Sprite::initWithPolygon(const cocos2d::PolygonInfo &info) +{ + Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(info.filename); + bool res = false; + if(initWithTexture(texture)); + { + _polyInfo = info; + setContentSize(_polyInfo.rect.size/Director::getInstance()->getContentScaleFactor()); + res = true; + } + return res; +} + // designated initializer bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) { @@ -246,6 +271,7 @@ bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) setTexture(texture); setTextureRect(rect, rotated, rect.size); + _polyInfo.setQuad(&_quad); // by default use "Self Render". // if the sprite is added to a batchnode, then it will automatically switch to "batchnode Render" setBatchNode(nullptr); @@ -268,8 +294,7 @@ Sprite::Sprite(void) , _insideBounds(true) { #if CC_SPRITE_DEBUG_DRAW - _debugDrawNode = DrawNode::create(); - addChild(_debugDrawNode); + debugDraw(true) #endif //CC_SPRITE_DEBUG_DRAW } @@ -407,6 +432,47 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme } } +void Sprite::debugDraw(bool on) +{ + DrawNode* draw = getChildByName("debugDraw"); + if(on) + { + if(!draw) + { + draw = DrawNode::create(); + draw->setName("debugDraw"); + addChild(draw); + } + draw->setVisible(true); + draw->clear(); + //draw lines + auto last = _polyInfo.triangles.indexCount/3; + auto _indices = _polyInfo.triangles.indices; + auto _verts = _polyInfo.triangles.verts; + for(unsigned int i = 0; i < last; i++) + { + //draw 3 lines + Vec3 from =_verts[_indices[i*3]].vertices; + Vec3 to = _verts[_indices[i*3+1]].vertices; + draw->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN); + + from =_verts[_indices[i*3+1]].vertices; + to = _verts[_indices[i*3+2]].vertices; + draw->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN); + + from =_verts[_indices[i*3+2]].vertices; + to = _verts[_indices[i*3]].vertices; + draw->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN); + } + } + else + { + if(draw) + draw->setVisible(false); + } +} + + // override this method to generate "double scale" sprites void Sprite::setVertexRect(const Rect& rect) { @@ -598,33 +664,11 @@ void Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) if(_insideBounds) #endif { - _trianglesCommand.init(_globalZOrder, _texture->getName(), getGLProgramState(), _blendFunc, getRenderedTriangles(), transform, flags); + _trianglesCommand.init(_globalZOrder, _texture->getName(), getGLProgramState(), _blendFunc, _polyInfo.triangles, transform, flags); renderer->addCommand(&_trianglesCommand); - -#if CC_SPRITE_DEBUG_DRAW - _debugDrawNode->clear(); - Vec2 vertices[4] = { - Vec2( _quad.bl.vertices.x, _quad.bl.vertices.y ), - Vec2( _quad.br.vertices.x, _quad.br.vertices.y ), - Vec2( _quad.tr.vertices.x, _quad.tr.vertices.y ), - Vec2( _quad.tl.vertices.x, _quad.tl.vertices.y ), - }; - _debugDrawNode->drawPoly(vertices, 4, true, Color4F(1.0, 1.0, 1.0, 1.0)); -#endif //CC_SPRITE_DEBUG_DRAW } } -TrianglesCommand::Triangles Sprite::getRenderedTriangles() const -{ - static unsigned short indices[6] = {0, 1, 2, 3, 2, 1}; - TrianglesCommand::Triangles result; - result.indices = indices; - result.verts = (V3F_C4B_T2F*)&_quad; - result.vertCount = 4; - result.indexCount = 6; - return result; -} - // MARK: visit, draw, transform void Sprite::addChild(Node *child, int zOrder, int tag) @@ -1054,7 +1098,7 @@ void Sprite::updateBlendFunc(void) { CCASSERT(! _batchNode, "CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a SpriteBatchNode"); - // it is possible to have an untextured sprite + // it is possible to have an untextured spritec if (! _texture || ! _texture->hasPremultipliedAlpha()) { _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; @@ -1077,4 +1121,14 @@ std::string Sprite::getDescription() const return StringUtils::format("", _tag, texture_id ); } +PolygonInfo Sprite::getPolygonInfo() const +{ + return _polyInfo; +} + +void Sprite::setPolygonInfo(const PolygonInfo& info) +{ + _polyInfo = info; +} + NS_CC_END diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 2f6a65a36a..eb51e92ce2 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -35,6 +35,7 @@ THE SOFTWARE. #include "renderer/CCTextureAtlas.h" #include "renderer/CCTrianglesCommand.h" #include "renderer/CCCustomCommand.h" +#include "2d/CCAutoPolygon.h" NS_CC_BEGIN @@ -98,6 +99,17 @@ public: * @return An autoreleased sprite object. */ static Sprite* create(const std::string& filename); + + /** + * Creates a polygon sprite with a polygon info. + * + * After creation, the rect of sprite will be the size of the image, + * and the offset will be (0,0). + * + * @param polygonInfo A path to image file, e.g., "scene1/monster.png". + * @return An autoreleased sprite object. + */ + static Sprite* create(const PolygonInfo& info); /** * Creates a sprite with an image filename and a rect. @@ -459,6 +471,17 @@ CC_CONSTRUCTOR_ACCESS: * @return True if the sprite is initialized properly, false otherwise. */ virtual bool initWithTexture(Texture2D *texture); + + + /** + * Initializes a sprite with a PolygonInfo. + * + * After initialization, the rect used will be the size of the texture, and the offset will be (0,0). + * + * @param PolygonInfo a Polygon info contains the structure of the polygon. + * @return True if the sprite is initialized properly, false otherwise. + */ + virtual bool initWithPolygon(const PolygonInfo& info); /** * Initializes a sprite with a texture and a rect. @@ -531,6 +554,22 @@ CC_CONSTRUCTOR_ACCESS: */ virtual bool initWithFile(const std::string& filename, const Rect& rect); + void debugDraw(bool on); + + /** + * returns a copy of the polygon information associated with this sprite + * because this is a copy process it is slower than getting the reference, so use wisely + * + * @return a copy of PolygonInfo + */ + PolygonInfo getPolygonInfo() const; + + /** + * set the sprite to use this new PolygonInfo + * + * @param PolygonInfo the polygon information object + */ + void setPolygonInfo(const PolygonInfo& info); protected: void updateColor() override; @@ -538,8 +577,9 @@ protected: virtual void updateBlendFunc(); virtual void setReorderChildDirtyRecursively(); virtual void setDirtyRecursively(bool value); + + - TrianglesCommand::Triangles getRenderedTriangles() const; // // Data used when the sprite is rendered using a SpriteSheet // @@ -559,9 +599,8 @@ protected: Texture2D* _texture; /// Texture2D object that is used to render the sprite SpriteFrame* _spriteFrame; TrianglesCommand _trianglesCommand; /// -#if CC_SPRITE_DEBUG_DRAW - DrawNode *_debugDrawNode; -#endif //CC_SPRITE_DEBUG_DRAW + + // // Shared data // @@ -576,6 +615,7 @@ protected: // vertex coords, texture coords and color info V3F_C4B_T2F_Quad _quad; + PolygonInfo _polyInfo; // opacity and RGB protocol bool _opacityModifyRGB; diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index 5c1f188864..c9c60f3bee 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -66,9 +66,8 @@ set(COCOS_2D_SRC 2d/CCSprite.cpp 2d/CCSpriteFrameCache.cpp 2d/CCSpriteFrame.cpp - 2d/MarchingSquare.cpp - 2d/SpritePolygon.cpp - 2d/SpritePolygonCache.cpp + 2d/CCAutoPolygon.cpp + ../../external/clipper/clipper.cpp 2d/CCTextFieldTTF.cpp 2d/CCTileMapAtlas.cpp 2d/CCTMXLayer.cpp diff --git a/cocos/2d/MarchingSquare.cpp b/cocos/2d/MarchingSquare.cpp deleted file mode 100644 index b59b1502d6..0000000000 --- a/cocos/2d/MarchingSquare.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/**************************************************************************** -Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2011 Zynga Inc. -Copyright (c) 2013-2014 Chukong Technologies Inc. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include "MarchingSquare.h" -#include "cocos2d.h" -#include - -USING_NS_CC; - -MarchingSquare::MarchingSquare(const std::string &filename, const unsigned int threshold) -{ - _filename = filename; - _threshold = threshold; - Image *image = new Image(); - image->initWithImageFile(filename); - CCASSERT(image->getRenderFormat()==Texture2D::PixelFormat::RGBA8888, "unsupported format, currently only supports rgba8888"); - data = image->getData(); - width = image->getWidth(); - height = image->getHeight(); - scaleFactor = Director::getInstance()->getContentScaleFactor(); -} - -void MarchingSquare::trace() -{ - unsigned int first = findFirstNoneTransparentPixel(); - start = Vec2(first%width, first/width); - marchSquare(start.x, start.y); -} - -unsigned int MarchingSquare::findFirstNoneTransparentPixel() -{ - for(unsigned int i = 0; i < width*height; i++) - { - if(getAlphaAt(i) > _threshold) - { -// CCLOG("first non transparent is at x:%d, y%d", i%width, i/width); - return i; - } - } - CCASSERT(false, "image is all transparent!"); -} - -unsigned char MarchingSquare::getAlphaAt(const unsigned int i) -{ - return *(data+i*4+3); -} -unsigned char MarchingSquare::getAlphaAt(const int x, const int y) -{ - if(x < 0 || y < 0 || x > width-1 || y > height-1) - return 0; - return *(data+(y*width+x)*4+3); -} - -unsigned int MarchingSquare::getSquareValue(int x, int y) -{ - /* - checking the 2x2 pixel grid, assigning these values to each pixel, if not transparent - +---+---+ - | 1 | 2 | - +---+---+ - | 4 | 8 | <- current pixel (curx,cury) - +---+---+ - */ - unsigned int sv = 0; - if(getAlphaAt(x-1, y-1) > _threshold) - sv += 1; - if(getAlphaAt(x,y-1) > _threshold) - sv += 2; - if(getAlphaAt(x-1, y) > _threshold) - sv += 4; - if(getAlphaAt(x, y) > _threshold) - sv += 8; - return sv; -} - -void MarchingSquare::marchSquare(int startx, int starty) -{ - int stepx = 0; - int stepy = 0; - int prevx = 0; - int prevy = 0; - int curx = startx; - int cury = starty; - unsigned int count = 0; - unsigned int totalPixel = width*height; - bool problem = false; - std::vector case9s; - std::vector case6s; - int i; - std::vector::iterator it; - do{ - int sv = getSquareValue(curx, cury); - switch(sv){ - - case 1: - case 5: - case 13: - /* going UP with these cases: - 1 5 13 - +---+---+ +---+---+ +---+---+ - | 1 | | | 1 | | | 1 | | - +---+---+ +---+---+ +---+---+ - | | | | 4 | | | 4 | 8 | - +---+---+ +---+---+ +---+---+ - */ - stepx = 0; - stepy = -1; - break; - - - case 8: - case 10: - case 11: - /* going DOWN with these cases: - 8 10 11 - +---+---+ +---+---+ +---+---+ - | | | | | 2 | | 1 | 2 | - +---+---+ +---+---+ +---+---+ - | | 8 | | | 8 | | | 8 | - +---+---+ +---+---+ +---+---+ - */ - stepx = 0; - stepy = 1; - break; - - - case 4: - case 12: - case 14: - /* going LEFT with these cases: - 4 12 14 - +---+---+ +---+---+ +---+---+ - | | | | | | | | 2 | - +---+---+ +---+---+ +---+---+ - | 4 | | | 4 | 8 | | 4 | 8 | - +---+---+ +---+---+ +---+---+ - */ - stepx = -1; - stepy = 0; - break; - - - case 2 : - case 3 : - case 7 : - /* going RIGHT with these cases: - 2 3 7 - +---+---+ +---+---+ +---+---+ - | | 2 | | 1 | 2 | | 1 | 2 | - +---+---+ +---+---+ +---+---+ - | | | | | | | 4 | | - +---+---+ +---+---+ +---+---+ - */ - stepx=1; - stepy=0; - break; - case 9 : - /* - +---+---+ - | 1 | | - +---+---+ - | | 8 | - +---+---+ - this should normaly go UP, but if we already been here, we go down - */ - //find index from xy; - i = getIndexFromPos(curx, cury); - it = find (case9s.begin(), case9s.end(), i); - if (it != case9s.end()) - { - //found, so we go down, and delete from case9s; - stepx = 0; - stepy = 1; - case9s.erase(it); - problem = true; - } - else - { - //not found, we go up, and add to case9s; - stepx = 0; - stepy = -1; - case9s.push_back(i); - } - break; - case 6 : - /* - 6 - +---+---+ - | | 2 | - +---+---+ - | 4 | | - +---+---+ - this normally go RIGHT, but if its coming from UP, it should go LEFT - */ - i = getIndexFromPos(curx, cury); - it = find (case6s.begin(), case6s.end(), i); - if (it != case6s.end()) - { - //found, so we go down, and delete from case9s; - stepx = -1; - stepy = 0; - case6s.erase(it); - problem = true; - } - else{ - //not found, we go up, and add to case9s; - stepx = 1; - stepy = 0; - case6s.push_back(i); - } - break; - case 0: - CCLOG("case 0 at x:%d, y:%d, coming from %d, %d", curx, cury, prevx, prevy); - CCASSERT(false, "this shoudln't happen"); - break; - case 15: - CCLOG("case 15 at x:%d, y:%d, coming from %d, %d", curx, cury, prevx, prevy); - CCASSERT(false, "this shoudln't happen"); - break; - - } - //little optimization - // if previous direction is same as current direction, - // then we should modify the last vec to current - curx += stepx; - cury += stepy; - if(stepx == prevx && stepy == prevy) - { - points.back().x = (float)(curx) / scaleFactor; - points.back().y = (float)(height-cury) / scaleFactor; - } - else if(problem) - { - //TODO: we triangulation cannot work collineer points, so we need to modify same point a little - //TODO: maybe we can detect if we go into a hole and coming back the hole, we should extract those points and remove them - points.back().x -= 0.00001f; - points.back().y -= 0.00001f; - points.push_back(Vec2((float)curx, (float)height-cury)/ scaleFactor); - } - else{ - points.push_back(Vec2((float)curx, (float)height-cury)/ scaleFactor); - } - - count++; - prevx = stepx; - prevy = stepy; - problem = false; - CCASSERT(count <= totalPixel, "oh no, marching square cannot find starting position"); - } while(curx != startx || cury != starty); -} - -void MarchingSquare::printPoints() -{ - for(auto p : points) - { - CCLOG("%.1f %.1f", p.x, height-p.y); - } -} - -float MarchingSquare::perpendicularDistance(cocos2d::Vec2 ii, cocos2d::Vec2 ss, cocos2d::Vec2 ee) -{ - float res; - float slope; - float intercept; - - if(ss.x == ee.x) - { - res = fabsf(ii.x- ee.x); - } - else if (ss.y == ee.y) - { - res = fabsf(ii.y - ee.y); - } - else{ - slope = (ee.y - ss.y) / (ee.x - ss.x); - intercept = ss.y - (slope*ss.x); - res = fabsf(slope * ii.x - ii.y + intercept) / sqrtf(powf(slope, 2)+1); - } - return res; -} -std::vector MarchingSquare::rdp(std::vector v) -{ - if(v.size() < 3) - return v; - - int index = -1; - float dist = 0; - //not looping first and last point - for(int i = 1; i < v.size()-1; i++) - { - float cdist = perpendicularDistance(v[i], v.front(), v.back()); - if(cdist > dist) - { - dist = cdist; - index = i; - } - } - if (dist>epsilon) - { - std::vector::const_iterator begin = v.begin(); - std::vector::const_iterator end = v.end(); - std::vector l1(begin, begin+index+1); - std::vector l2(begin+index, end); - - std::vector r1 = rdp(l1); - std::vector r2 = rdp(l2); - - r1.insert(r1.end(), r2.begin()+1, r2.end()); - return r1; - } - else { - std::vector ret; - ret.push_back(v.front()); - ret.push_back(v.back()); - return ret; - } -} -void MarchingSquare::optimize(float level) -{ - if(level <= 0 || points.size()<4) - return; - epsilon = level; - points = rdp(points); - auto last = points.back(); - - if(last.y > points.front().y) - points.front().y = last.y; - points.pop_back(); - - //delete the last point, because its almost the same as the starting point -// CCLOG("%.1f, %.1f, %.1f, %.1f", points[0].x, points[0].y, points.back().x, points.back().y); -} \ No newline at end of file diff --git a/cocos/2d/MarchingSquare.h b/cocos/2d/MarchingSquare.h deleted file mode 100644 index f2bf792038..0000000000 --- a/cocos/2d/MarchingSquare.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2011 Zynga Inc. -Copyright (c) 2013-2014 Chukong Technologies Inc. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef COCOS_2D_MARCHINGSQUARE_H__ -#define COCOS_2D_MARCHINGSQUARE_H__ - -#include -#include -#include "base/CCConsole.h" -#include "platform/CCPlatformMacros.h" -#include "math/Vec2.h" - -NS_CC_BEGIN - -class CC_DLL MarchingSquare -{ -public: - MarchingSquare(const std::string &filename, const unsigned int threshold = 0); - //TODO: should return list of vec2s - void trace(); - void setThreshold(unsigned int threshold){_threshold = threshold;}; - unsigned int getThreshold(){return _threshold;}; - ssize_t getVecCount(){return points.size();}; - std::vector getPoints(){return points;}; - void printPoints(); - //using Ramer–Douglas–Peucker algorithm - void optimize(float level = 0); -protected: - unsigned int findFirstNoneTransparentPixel(); - void marchSquare(int startx, int starty); - unsigned int getSquareValue(int x, int y); - unsigned char * data; - std::string _filename; - unsigned int width; - unsigned int height; - unsigned int _threshold; - unsigned char getAlphaAt(const unsigned int i); - unsigned char getAlphaAt(const int x, const int y); - cocos2d::Vec2 start; - std::vector points; - int getIndexFromPos(int x, int y){return y*width+x;}; - cocos2d::Vec2 getPosFromIndex(int i){return cocos2d::Vec2(i%width, i/width);}; - - float epsilon; - std::vector rdp(std::vector v); - float perpendicularDistance(cocos2d::Vec2 i, cocos2d::Vec2 start, cocos2d::Vec2 end); - float scaleFactor; - - -}; - -NS_CC_END - -#endif // #ifndef COCOS_2D_MARCHINGSQUARE_H__ \ No newline at end of file diff --git a/cocos/2d/SpritePolygon.cpp b/cocos/2d/SpritePolygon.cpp deleted file mode 100644 index 71f51b3118..0000000000 --- a/cocos/2d/SpritePolygon.cpp +++ /dev/null @@ -1,506 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2011 Zynga Inc. - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "SpritePolygon.h" -#include "3d/CCMesh.h" -#include "3d/CCMeshVertexIndexData.h" - -#include "MarchingSquare.h" - -#include "base/CCDirector.h" -#include "renderer/CCRenderer.h" -#include "renderer/CCTextureCache.h" -#include "renderer/CCGLProgramState.h" -#include "renderer/CCGLProgramCache.h" -#include - -#include "poly2tri/poly2tri.h" -#include "SpritePolygonCache.h" -#include "platform/CCFileUtils.h" -using namespace std; - - -USING_NS_CC; -using namespace cocos2d::experimental; - -SpritePolygon *SpritePolygon::create(const std::string& file, std::vector& verts, std::vector& indices) -{ - SpritePolygon *ret = new (std::nothrow) SpritePolygon(); - if (ret && ret->initWithVerts(file, verts, indices)) - { - ret->autorelease(); - return ret; - } - else - { - CC_SAFE_DELETE(ret); - return nullptr; - } -} -SpritePolygon *SpritePolygon::create(const std::string& file, std::vector& verts,std::vector& indices, const cocos2d::Rect& rect) -{ - SpritePolygon *ret = new (std::nothrow) SpritePolygon(); - if (ret && ret->initWithRect(file, verts, indices, rect)) - { - ret->autorelease(); - return ret; - } - else - { - CC_SAFE_DELETE(ret); - return nullptr; - } -} -SpritePolygon *SpritePolygon::create(const std::string& file, std::vector& verts, const cocos2d::Rect& rect) -{ - SpritePolygon *ret = new (std::nothrow) SpritePolygon(); - if (ret && ret->initWithPoly2tri(file, verts, rect)) - { - ret->autorelease(); - return ret; - } - else - { - CC_SAFE_DELETE(ret); - return nullptr; - } -} -SpritePolygon *SpritePolygon::create(const std::string &file, const cocos2d::Rect &rect, float optimization) -{ - SpritePolygon *ret = new (std::nothrow) SpritePolygon(); - if (ret) - { - auto info = SpritePolygonCache::getInstance()->getSpritePolygonCache(file, rect); - if(info) - { -// CCLOG("created from cache"); - ret->initWithCache(file, info); - } - else{ -// CCLOG("created with marching square"); - ret->initWithMarching(file, rect, optimization); - } - ret->autorelease(); - return ret; - } - else - { - CC_SAFE_DELETE(ret); - return nullptr; - } -} - - -void SpritePolygon::calculateUVandContentSize() -{ - /* - whole texture UV coordination - 0,0 1,0 - +---------------------+ - | |0.1 - | |0.2 - | +--------+ |0.3 - | |texRect | |0.4 - | | | |0.5 - | | | |0.6 - | +--------+ |0.7 - | |0.8 - | |0.9 - +---------------------+ - 0,1 1,1 - - because when we scanned the image upside down, our uv is now upside down too - */ - - float scaleFactor = Director::getInstance()->getContentScaleFactor(); - float texWidth = _texture->getPixelsWide()/scaleFactor; - float texHeight = _texture->getPixelsHigh()/scaleFactor; - - // the texture rect in pixels, for example, an image is 32x32 pixels - Rect* textRect = &_polygonInfo->_rect; - - - bool needDelete = false; - if(textRect->equals(Rect::ZERO)) - { - //zero sized rect specified, so it means the whole image, for our calculation, we need actual image rect - textRect = new Rect(0,0, texWidth, texHeight); - needDelete = true; - } - setContentSize(textRect->size); - - - auto end = &_polygonInfo->_triangles.verts[_polygonInfo->_triangles.vertCount]; - for(auto i = _polygonInfo->_triangles.verts; i != end; i++) - { - // for every point, offset with the centerpoint - float u = i->vertices.x / texWidth; - float v = (texHeight - i->vertices.y) / texHeight; - i->texCoords.u = u; - i->texCoords.v = v; - } - - if(needDelete) - delete textRect; -} - -TrianglesCommand::Triangles SpritePolygon::triangulate(std::vector & verts) -{ - std::vector points; - for(std::vector::const_iterator it = verts.begin(); itx, it->y); - points.push_back(p); - } - auto cdt = new p2t::CDT(points); - cdt->Triangulate(); - std::vector tris = cdt->GetTriangles(); - - vector *_verts = new vector(); - vector *_indices = new vector; - unsigned short idx = 0; - for(std::vector::const_iterator ite = tris.begin(); ite < tris.end(); ite++) - { - for(int i = 0; i < 3; i++) - { - auto p = (*ite)->GetPoint(i); - auto v3 = Vec3(p->x, p->y, 0); - bool found = false; - int j; - for(j = 0; j < _verts->size(); j++) - { - if((*_verts)[j].vertices == v3) - { - found = true; - break; - } - } - if(found) - { - //if we found the same vertice, don't add to verts, but use the same vert with indices - _indices->push_back(j); - } - else - { - //vert does not exist yet, so we need to create a new one, - auto c4b = Color4B::WHITE; - auto t2f = Tex2F(0,0); // don't worry about tex coords now, we calculate that later - V3F_C4B_T2F vert = {v3,c4b,t2f}; - _verts->push_back(vert); - _indices->push_back(idx); - idx++; - } - } - } - for(auto j : points) - { - delete j; - } - delete cdt; - - TrianglesCommand::Triangles triangles = {&(*_verts)[0], &(*_indices)[0], (ssize_t)_verts->size(), (ssize_t)_indices->size()}; - return triangles; -} -bool SpritePolygon::initWithCache(const std::string &file, SpritePolygonInfo *info) -{ - CCASSERT(file.size()>0, "Invalid filename for sprite"); - Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(file); - CCASSERT(texture, "texture was not loaded properly"); - _polygonInfo = info; - initWithTexture(texture); - if(_polygonInfo->_rect.equals(Rect::ZERO)) - { - setContentSize(Size(texture->getPixelsWide(), texture->getPixelsHigh())/Director::getInstance()->getContentScaleFactor()); - } - else - { - setContentSize(_polygonInfo->_rect.size); - } - - - setAnchorPoint(Vec2(0.5,0.5)); - return true; -} -bool SpritePolygon::initWithMarching(const std::string &file, const cocos2d::Rect &rect, float optimization) -{ - CCASSERT(file.size()>0, "Invalid filename for sprite"); - Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(file); - CCASSERT(texture, "texture was not loaded properly"); - initWithTexture(texture); - optimization = (optimization < 0)? (float)texture->getPixelsHigh()*(float)texture->getPixelsWide()*0.00015/Director::getInstance()->getContentScaleFactor() : optimization/Director::getInstance()->getContentScaleFactor(); - - //Marching Square - auto marcher = new MarchingSquare(file); - marcher->trace(); - marcher->optimize(optimization); -// marcher->test(); - - auto p = marcher->getPoints(); - auto triangles = triangulate(p); - delete marcher; - - //save result to cache - _polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(file, rect, triangles); - setAnchorPoint(Vec2(0.5,0.5)); - calculateUVandContentSize(); - -// SpritePolygonCache::printInfo(*_polygonInfo); -#if CC_SPRITE_DEBUG_DRAW - debugDraw(); -#endif - return true; -} -bool SpritePolygon::initWithPoly2tri(const std::string &filename, std::vector & verts, const cocos2d::Rect &Rect) -{ - CCASSERT(filename.size()>0, "Invalid filename for sprite"); - Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); - CCASSERT(texture, "texture was not loaded properly"); - initWithTexture(texture); - _polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(filename, Rect, triangulate(verts)); - setAnchorPoint(Vec2(0.5,0.5)); - calculateUVandContentSize(); - #if CC_SPRITE_DEBUG_DRAW - debugDraw(); - #endif - return true; -} -Rect SpritePolygon::getTextRectFromTriangles(std::vector& _verts) -{ -// CCASSERT(_polygonInfo, "cannot get texture rect because triangles were not defined"); - auto text = getTexture(); - int width = text->getPixelsWide(); - int height = text->getPixelsHigh(); - auto firstV = _verts[0]; - auto left = firstV.texCoords.u; - auto right = firstV.texCoords.u; - auto top = firstV.texCoords.v; - auto bot = firstV.texCoords.v; - for(std::vector::const_iterator v = _verts.begin(); v < _verts.end(); v++) - { - if(v->texCoords.u < left) - { - left = v->texCoords.u; - } - else if (v->texCoords.u > right) - { - right = v->texCoords.u; - } - if(v->texCoords.v < bot) - { - bot = v->texCoords.v; - } - else if (v->texCoords.v > top) - { - top = v->texCoords.v; - } - } - return Rect(left*width, bot*height, right*width, top*height); -} - -bool SpritePolygon::initWithVerts(const std::string& filename,std::vector& verts, std::vector& indices) -{ - CCASSERT(filename.size()>0, "Invalid filename for sprite"); - - Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); - CCASSERT(texture, "texture was not loaded properly"); - - - initWithTexture(texture); - auto _textureRect = getTextRectFromTriangles(verts); - setContentSize(_textureRect.size/Director::getInstance()->getContentScaleFactor()); - setAnchorPoint(Vec2(0.5,0.5)); - _transformDirty = true; - TrianglesCommand::Triangles triangles = {&verts[0], &indices[0], (ssize_t)verts.size(), (ssize_t)indices.size()}; - _polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(filename, _textureRect, triangles); - -#if CC_SPRITE_DEBUG_DRAW - debugDraw(); -#endif - return true; -} - -bool SpritePolygon::initWithRect(const std::string& filename, std::vector& verts, std::vector& indices, const cocos2d::Rect& rect) -{ - CCASSERT(filename.size()>0, "Invalid filename for sprite"); - Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); - CCASSERT(texture, "texture was not loaded properly"); - initWithTexture(texture); - //build v3f_c4b_t2f verts from vec2 vector - vector _verts; - for(std::vector::const_iterator it = verts.begin(); itx, it->y, 0); - auto c4b = Color4B::WHITE; - auto t2f = Tex2F(0,0); - V3F_C4B_T2F vert = {v3,c4b,t2f}; - _verts.push_back(vert); - } - - TrianglesCommand::Triangles triangles = {&_verts[0], &indices[0], (ssize_t)_verts.size(), (ssize_t)indices.size()}; - _polygonInfo = SpritePolygonCache::getInstance()->addSpritePolygonCache(filename, rect, triangles); - calculateUVandContentSize(); - setAnchorPoint(Vec2(0.5,0.5)); -#if CC_SPRITE_DEBUG_DRAW - debugDraw(); -#endif - return true; -} - -bool SpritePolygon::initWithTexture(Texture2D *texture) -{ - Node::init(); - //init the triangles command - setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); - _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - setTexture(texture); - return true; -} -void SpritePolygon::setTexture(const std::string &filename) -{ - Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(filename); - setTexture(texture); -} -static unsigned char cc_2x2_white_image[] = { - // RGBA8888 - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF -}; -#define CC_2x2_WHITE_IMAGE_KEY "/cc_2x2_white_image" -void SpritePolygon::setTexture(Texture2D *texture) -{ - // accept texture==nil as argument - CCASSERT( !texture || dynamic_cast(texture), "setTexture expects a Texture2D. Invalid argument"); - - if (texture == nullptr) - { - // Gets the texture by key firstly. - texture = Director::getInstance()->getTextureCache()->getTextureForKey(CC_2x2_WHITE_IMAGE_KEY); - - // If texture wasn't in cache, create it from RAW data. - if (texture == nullptr) - { - Image* image = new (std::nothrow) Image(); - bool isOK = image->initWithRawData(cc_2x2_white_image, sizeof(cc_2x2_white_image), 2, 2, 8); - CC_UNUSED_PARAM(isOK); - CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully."); - - texture = Director::getInstance()->getTextureCache()->addImage(image, CC_2x2_WHITE_IMAGE_KEY); - CC_SAFE_RELEASE(image); - } - } - - if (_texture != texture) - { - CC_SAFE_RETAIN(texture); - CC_SAFE_RELEASE(_texture); - _texture = texture; - } -} -const float SpritePolygon::getArea(){ - float area = 0; - V3F_C4B_T2F *verts = _polygonInfo->_triangles.verts; - unsigned short *indices = _polygonInfo->_triangles.indices; - for(int i = 0; i < _polygonInfo->_triangles.indexCount; i=i+3) - { - auto A = verts[indices[i]].vertices; - auto B = verts[indices[i+1]].vertices; - auto C = verts[indices[i+2]].vertices; - area += (A.x*(B.y-C.y) + B.x*(C.y-A.y) + C.x*(A.y - B.y))/2; - } - return area; -} - -void SpritePolygon::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) -{ - _tcmd.init(0, _texture->getName(), getGLProgramState(), _blendFunc, _polygonInfo->_triangles, transform, flags); - renderer->addCommand(&_tcmd); -} -void SpritePolygon::debugDraw() -{ - if(!_debugDrawNode) - { - _debugDrawNode = DrawNode::create(); - addChild(_debugDrawNode); - } - else{ - _debugDrawNode->clear(); - } - //draw all points - auto positions = new (std::nothrow) Vec2[_polygonInfo->_triangles.vertCount]; - Vec2 *pos = &positions[0]; - auto verts = _polygonInfo->_triangles.verts; - auto end = &verts[_polygonInfo->_triangles.vertCount]; - for(V3F_C4B_T2F *v = verts; v != end; pos++, v++) - { - pos->x = v->vertices.x; - pos->y = v->vertices.y; - } - _debugDrawNode->drawPoints(positions, (unsigned int)_polygonInfo->_triangles.vertCount, 8, Color4F(0.0f, 1.0f, 1.0f, 1.0f)); - //draw lines - auto last = _polygonInfo->_triangles.indexCount/3; - auto _indices = _polygonInfo->_triangles.indices; - auto _verts = _polygonInfo->_triangles.verts; - for(unsigned int i = 0; i < last; i++) - { - //draw 3 lines - Vec3 from =_verts[_indices[i*3]].vertices; - Vec3 to = _verts[_indices[i*3+1]].vertices; - _debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN); - - from =_verts[_indices[i*3+1]].vertices; - to = _verts[_indices[i*3+2]].vertices; - _debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN); - - from =_verts[_indices[i*3+2]].vertices; - to = _verts[_indices[i*3]].vertices; - _debugDrawNode->drawLine(Vec2(from.x, from.y), Vec2(to.x,to.y), Color4F::GREEN); - - } - CC_SAFE_DELETE_ARRAY(positions); -} - -void SpritePolygon::showDebug(const bool val) -{ - if(val) - { - if(!_debugDrawNode) - { - debugDraw(); - } - else{ - _debugDrawNode->setVisible(val); - } - } - else{ - if(_debugDrawNode) - { - _debugDrawNode->setVisible(val); - } - } -} diff --git a/cocos/2d/SpritePolygon.h b/cocos/2d/SpritePolygon.h deleted file mode 100644 index 445ac5accf..0000000000 --- a/cocos/2d/SpritePolygon.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2011 Zynga Inc. - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef COCOS_2D_SpritePolygon_H__ -#define COCOS_2D_SpritePolygon_H__ - -#include -#include "platform/CCPlatformMacros.h" -#include "2d/CCNode.h" -#include "renderer/CCTrianglesCommand.h" -#include "CCDrawNode.h" -#include "SpritePolygonCache.h" - -NS_CC_BEGIN - -namespace experimental{ - -class CC_DLL SpritePolygon : public cocos2d::Node -{ -public: - //create with manually created vertices, color and uv and - static SpritePolygon *create(const std::string&, std::vector&, std::vector&); - bool initWithVerts(const std::string&, std::vector&, std::vector&); - - //create from list of vertices, with texture rect, and triangle indices, UV is calculated from the texture rect - static SpritePolygon *create(const std::string&, std::vector&, std::vector&, const cocos2d::Rect&rect = cocos2d::Rect::ZERO); - bool initWithRect(const std::string&, std::vector&, std::vector&, const cocos2d::Rect&rect = cocos2d::Rect::ZERO); - -// //create from ordered list of vertices, with texture rect, Triangles and UV is calculated on the fly - static SpritePolygon *create(const std::string&, std::vector&, const cocos2d::Rect& rect = cocos2d::Rect::ZERO); - bool initWithPoly2tri(const std::string&, std::vector&, const cocos2d::Rect&); - - //create from a texture (rect), and automatically trace and optimize the points. - //not recommended for production, its better to use the vec2 list for better performance - static SpritePolygon *create(const std::string&, const cocos2d::Rect& rect = cocos2d::Rect::ZERO, float optimization = -1); - bool initWithMarching(const std::string &file, const cocos2d::Rect &rect, float optimization); - bool initWithCache(const std::string &file, SpritePolygonInfo *info); - - bool initWithTexture(cocos2d::Texture2D *texture); - - virtual void setTexture(const std::string &filename ); - virtual void setTexture(cocos2d::Texture2D *texture); - - /** returns the Texture2D object used by the sprite */ - virtual cocos2d::Texture2D* getTexture(){return _texture;}; - const float getArea(); - const ssize_t getTrianglesCount(){return _polygonInfo->_triangles.indexCount/3;}; - const ssize_t getVertCount(){return _polygonInfo->_triangles.vertCount;}; - - void showDebug(const bool val); -protected: - SpritePolygon() - : _debugDrawNode(nullptr) - , _texture(nullptr) - , _polygonInfo(nullptr) - { - - } - - cocos2d::DrawNode *_debugDrawNode; - void debugDraw(); - - void calculateUVandContentSize(); - - cocos2d::TrianglesCommand _tcmd; - cocos2d::BlendFunc _blendFunc; - cocos2d::Texture2D *_texture; - SpritePolygonInfo *_polygonInfo; - virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags); - - cocos2d::Rect getTextRectFromTriangles(std::vector& verts); - - //======Triangulation - cocos2d::TrianglesCommand::Triangles triangulate(std::vector & verts); - - - //TODO: move those to ccUtils - -}; -} - -NS_CC_END - -#endif // #ifndef COCOS_2D_SpritePolygon_H__ diff --git a/cocos/2d/SpritePolygonCache.cpp b/cocos/2d/SpritePolygonCache.cpp deleted file mode 100644 index 5d62393377..0000000000 --- a/cocos/2d/SpritePolygonCache.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2011 Zynga Inc. - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "SpritePolygonCache.h" -#include "3d/CCMesh.h" -#include "3d/CCMeshVertexIndexData.h" - -#include "base/CCDirector.h" -#include "renderer/CCRenderer.h" -#include "renderer/CCTextureCache.h" -#include "renderer/CCGLProgramState.h" -#include "renderer/CCGLProgramCache.h" -#include - -#include "poly2tri/poly2tri.h" -#include "platform/CCFileUtils.h" -using namespace std; - -USING_NS_CC; - -SpritePolygonCache* SpritePolygonCache::_SpritePolygonCache = nullptr; - -SpritePolygonCache::SpritePolygonCache() -{ - -} - -SpritePolygonCache::~SpritePolygonCache() -{ -} - -SpritePolygonCache* SpritePolygonCache::getInstance() -{ - if (NULL == _SpritePolygonCache) - { - _SpritePolygonCache = new (std::nothrow) SpritePolygonCache(); - _SpritePolygonCache->init(); - } - return _SpritePolygonCache; -} - -void SpritePolygonCache::destroyInstance() -{ - CC_SAFE_DELETE(_SpritePolygonCache); -} - -void SpritePolygonCache::init() -{ - -} - -SpritePolygonInfo* SpritePolygonCache::addSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect, const cocos2d::TrianglesCommand::Triangles trianglesCommand) -{ - auto fullpath = filePath; - - auto it = _SpritePolygonCacheMap.find(fullpath); - if (_SpritePolygonCacheMap.end() != it) - { - VecSpritePolygonInfo vecInfo = it->second; - - auto infoIt = vecInfo.begin(); - for (; infoIt != vecInfo.end(); infoIt++) - { - if ((*infoIt)->_rect.equals(rect)) - { - //Update - CC_SAFE_DELETE((*infoIt)->_triangles.verts); - CC_SAFE_DELETE((*infoIt)->_triangles.indices); - (*infoIt)->_triangles.verts = new V3F_C4B_T2F[trianglesCommand.vertCount]; - (*infoIt)->_triangles.indices = new unsigned short[trianglesCommand.indexCount]; - (*infoIt)->_triangles.vertCount = trianglesCommand.vertCount; - (*infoIt)->_triangles.indexCount = trianglesCommand.indexCount; - memcpy((*infoIt)->_triangles.verts, trianglesCommand.verts, trianglesCommand.vertCount*sizeof(V3F_C4B_T2F)); - memcpy((*infoIt)->_triangles.indices, trianglesCommand.indices, trianglesCommand.indexCount*sizeof(unsigned short)); - return *infoIt; - } - } - } - - VecSpritePolygonInfo vecInfo; - vecInfo.clear(); - if (it != _SpritePolygonCacheMap.end()) - { - vecInfo = it->second; - } - SpritePolygonInfo* info = new SpritePolygonInfo; - if (nullptr != info) - { - info->_rect = rect; - - info->_triangles.verts = new V3F_C4B_T2F[trianglesCommand.vertCount]; - info->_triangles.indices = new unsigned short[trianglesCommand.indexCount]; - info->_triangles.vertCount = trianglesCommand.vertCount; - info->_triangles.indexCount = trianglesCommand.indexCount; - - - memcpy(info->_triangles.verts, trianglesCommand.verts, trianglesCommand.vertCount*sizeof(V3F_C4B_T2F)); - memcpy(info->_triangles.indices, trianglesCommand.indices, trianglesCommand.indexCount*sizeof(unsigned short)); - - vecInfo.push_back(info); - _SpritePolygonCacheMap[filePath] = vecInfo; - } - return info; -} - -SpritePolygonInfo* SpritePolygonCache::getSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect) -{ - auto fullpath = filePath; - - auto it = _SpritePolygonCacheMap.find(fullpath); - if (_SpritePolygonCacheMap.end() == it) - return nullptr; - - auto infoIter = it->second.begin(); - for (; infoIter != it->second.end(); infoIter++) - { - if ((*infoIter)->_rect.equals(rect)) - return *infoIter; - } - - return nullptr; -} - -void SpritePolygonCache::removeSpritePolygonCache(const std::string& filePath, const cocos2d::Rect* rect) -{ - std::string fullpath = FileUtils::getInstance()->fullPathForFilename(filePath); - if (fullpath.size() == 0) - return; - - auto it = _SpritePolygonCacheMap.find(fullpath); - if (_SpritePolygonCacheMap.end() == it) - return; - - if (nullptr == rect) - return; - - auto infoIter = it->second.begin(); - for (; infoIter != it->second.end(); infoIter++) - { - if((*infoIter)->_rect.equals(*rect)) - { - CC_SAFE_DELETE(*infoIter); - it->second.erase(infoIter); - break; - } - } - - return; -} - -void SpritePolygonCache::removeAllSpritePolygonCache() -{ - for (std::unordered_map::iterator it = _SpritePolygonCacheMap.begin(); it != _SpritePolygonCacheMap.end(); ++it) - { - for (auto infoIter = it->second.begin(); infoIter != it->second.end(); infoIter++) - { - CC_SAFE_DELETE(*infoIter); - } - it->second.clear(); - } - _SpritePolygonCacheMap.clear(); -} - -bool SpritePolygonCache::isSpritePolygonCachExist(const std::string& filePath, const cocos2d::Rect& rect) -{ - std::string fullpath = FileUtils::getInstance()->fullPathForFilename(filePath); - if (fullpath.size() == 0) - return false; - - auto it = _SpritePolygonCacheMap.find(fullpath); - if (_SpritePolygonCacheMap.end() == it) - return false; - - auto infoIter = it->second.begin(); - for (; infoIter != it->second.end(); infoIter++) - { - if ((*infoIter)->_rect.equals(rect)) - return true; - } - - return false; -} - - -void SpritePolygonCache::printInfo(SpritePolygonInfo &info){ - CCLOG("========================"); - CCLOG("%zd, %zd", info._triangles.vertCount, info._triangles.indexCount); - - auto vertEnd = &info._triangles.verts[info._triangles.vertCount]; - for(auto v = info._triangles.verts; v < vertEnd; v++) - { - CCLOG("%f, %f", v->vertices.x, v->vertices.y); - } - auto indEnd = &info._triangles.indices[info._triangles.indexCount]; - for(auto i = info._triangles.indices; i < indEnd; i+=3) - { - CCLOG("%d, %d, %d,", *i,*(i+1), *(i+2)); - } - - auto uvEnd = &info._triangles.verts[info._triangles.vertCount]; - for(auto v = info._triangles.verts; v < uvEnd; v++) - { - CCLOG("%f, %f", v->texCoords.u, v->texCoords.v); - } -} - -USING_NS_CC; diff --git a/cocos/2d/SpritePolygonCache.h b/cocos/2d/SpritePolygonCache.h deleted file mode 100644 index 2199169787..0000000000 --- a/cocos/2d/SpritePolygonCache.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2011 Zynga Inc. - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef COCOS_2D_SpritePolygonCACHE_H__ -#define COCOS_2D_SpritePolygonCACHE_H__ - -#include -#include "platform/CCPlatformMacros.h" -#include "2d/CCNode.h" -#include "renderer/CCTrianglesCommand.h" -#include "CCDrawNode.h" - -NS_CC_BEGIN - -typedef struct CC_DLL _SpritePolygonInfo -{ - cocos2d::Rect _rect; - cocos2d::TrianglesCommand::Triangles _triangles; - ~_SpritePolygonInfo() - { - if(nullptr != _triangles.verts) - { - CC_SAFE_DELETE_ARRAY(_triangles.verts); - } - - if(nullptr != _triangles.indices) - { - CC_SAFE_DELETE_ARRAY(_triangles.indices); - } - } -} SpritePolygonInfo; - -typedef std::vector VecSpritePolygonInfo; -typedef std::unordered_map MapSpritePolygonInfo; - -class CC_DLL SpritePolygonCache: public cocos2d::Ref -{ -public: - virtual ~SpritePolygonCache(); - static SpritePolygonCache* getInstance(); - static void destroyInstance(); - SpritePolygonInfo* addSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect, const cocos2d::TrianglesCommand::Triangles trianglesCommand); - SpritePolygonInfo* getSpritePolygonCache(const std::string& filePath, const cocos2d::Rect& rect); - void removeSpritePolygonCache(const std::string& filePath, const cocos2d::Rect* rect = nullptr); - void removeAllSpritePolygonCache(); - bool isSpritePolygonCachExist(const std::string& filePath, const cocos2d::Rect& rect); - - static void printInfo(SpritePolygonInfo &info); -protected: - SpritePolygonCache(); -private: - void init(); -private: - static SpritePolygonCache* _SpritePolygonCache; - MapSpritePolygonInfo _SpritePolygonCacheMap; - -}; - -NS_CC_END - -#endif // #ifndef COCOS_2D_SpritePolygonCACHE_H__ diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 275310dd89..556b7f4070 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -355,6 +355,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -668,6 +669,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -721,9 +723,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - - - @@ -903,6 +902,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -1275,6 +1275,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -1328,9 +1329,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - - - diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 397222cdef..3e2f377738 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -271,6 +271,8 @@ {e492faef-2169-4117-8d73-e0c66271fe25} + + {ff65e340-b79d-4f87-9b4c-ed46bda5d20f} {0f3fa25d-9e2b-4a2e-a1df-834b796b3fb3} @@ -1824,15 +1826,6 @@ external\poly2tri\sweep - - 2d - - - 2d - - - 2d - physics3d @@ -1897,6 +1890,12 @@ renderer + + 2d + + + external\clipper + @@ -3636,15 +3635,6 @@ external\poly2tri\sweep - - 2d - - - 2d - - - 2d - physics3d @@ -3709,6 +3699,12 @@ renderer + + 2d + + + external\clipper + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems index ac08bdcee6..aac1ec770e 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems @@ -191,6 +191,7 @@ + @@ -572,6 +573,7 @@ + @@ -625,9 +627,6 @@ - - - @@ -804,6 +803,7 @@ + CompileAsCpp @@ -1157,6 +1157,7 @@ + @@ -1210,9 +1211,6 @@ - - - diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters index 00beef404e..7787445102 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Shared/libcocos2d_8_1.Shared.vcxitems.filters @@ -1743,9 +1743,6 @@ platform\winrt - - 2d - external\poly2tri\common @@ -1767,12 +1764,6 @@ external\poly2tri - - 2d - - - 2d - renderer @@ -1845,6 +1836,8 @@ physics3d + + @@ -3415,9 +3408,6 @@ platform\winrt - - 2d - external\poly2tri\common @@ -3433,12 +3423,6 @@ external\poly2tri\sweep - - 2d - - - 2d - renderer @@ -3517,6 +3501,8 @@ base + + @@ -3774,6 +3760,9 @@ {932c5f6e-07b3-4b34-97ae-2f3d42024149} + + {37ad3bdd-733d-46e4-b28d-b350521e6f54} + {f1c7e21a-6d78-44ba-9480-d7ba197c7b42} diff --git a/cocos/3d/CCBillBoard.cpp b/cocos/3d/CCBillBoard.cpp index b8bbcb5238..dd5b4b5652 100644 --- a/cocos/3d/CCBillBoard.cpp +++ b/cocos/3d/CCBillBoard.cpp @@ -230,7 +230,7 @@ void BillBoard::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { //FIXME: frustum culling here flags |= Node::FLAGS_RENDER_AS_3D; - _trianglesCommand.init(0, _texture->getName(), getGLProgramState(), _blendFunc, getRenderedTriangles(), _modelViewTransform, flags); + _trianglesCommand.init(0, _texture->getName(), getGLProgramState(), _blendFunc, _polyInfo.triangles, _modelViewTransform, flags); _trianglesCommand.setTransparent(true); _trianglesCommand.set3D(true); renderer->addCommand(&_trianglesCommand); diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 8776eb54f4..dfdeff74ff 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -613,8 +613,9 @@ void Mesh::setLightUniforms(Pass* pass, Scene* scene, const Vec4& color, unsigne if (hasAmbient) { ambient.x /= 255.f; ambient.y /= 255.f; ambient.z /= 255.f; + //override the uniform value of u_color using the calculated color + glProgramState->setUniformVec4("u_color", Vec4(color.x * ambient.x, color.y * ambient.y, color.z * ambient.z, color.w)); } - glProgramState->setUniformVec4("u_color", Vec4(color.x * ambient.x, color.y * ambient.y, color.z * ambient.z, color.w)); } } diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index c44e8424d8..aba46b3eb0 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -159,11 +159,9 @@ void Terrain::onDraw(const Mat4 &transform, uint32_t flags) if(_isCameraViewChanged ) { - auto camPos = camera->getPosition3D(); - auto camModelMat = camera->getNodeToWorldTransform(); - camModelMat.transformPoint(&camPos); + auto m = camera->getNodeToWorldTransform(); //set lod - setChunksLOD(camPos); + setChunksLOD(Vec3(m.m[12], m.m[13], m.m[14])); } if(_isCameraViewChanged ) @@ -265,7 +263,7 @@ void Terrain::setChunksLOD(Vec3 cameraPos) { AABB aabb = _chunkesArray[m][n]->_parent->_worldSpaceAABB; auto center = aabb.getCenter(); - float dist = Vec3(center.x,0,center.z).distance(Vec3(cameraPos.x,0,cameraPos.z)); + float dist = Vec2(center.x, center.z).distance(Vec2(cameraPos.x, cameraPos.z)); _chunkesArray[m][n]->_currentLod = 3; for(int i =0;i<3;i++) { diff --git a/cocos/Android.mk b/cocos/Android.mk index bf6f09dc92..3888e6a025 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -83,9 +83,7 @@ cocos2d.cpp \ 2d/CCTransitionPageTurn.cpp \ 2d/CCTransitionProgress.cpp \ 2d/CCTweenFunction.cpp \ -2d/MarchingSquare.cpp \ -2d/SpritePolygon.cpp \ -2d/SpritePolygonCache.cpp \ +2d/CCAutoPolygon.cpp \ 3d/CCFrustum.cpp \ 3d/CCPlane.cpp \ platform/CCFileUtils.cpp \ @@ -221,7 +219,8 @@ navmesh/CCNavMeshUtils.cpp \ ../external/poly2tri/sweep/advancing_front.cc \ ../external/poly2tri/sweep/cdt.cc \ ../external/poly2tri/sweep/sweep_context.cc \ -../external/poly2tri/sweep/sweep.cc +../external/poly2tri/sweep/sweep.cc \ +../external/clipper/clipper.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ @@ -237,7 +236,8 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../external/nslog \ $(LOCAL_PATH)/../external/poly2tri \ $(LOCAL_PATH)/../external/poly2tri/common \ - $(LOCAL_PATH)/../external/poly2tri/sweep + $(LOCAL_PATH)/../external/poly2tri/sweep \ + $(LOCAL_PATH)/../external/clipper LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/platform \ @@ -251,7 +251,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../external/nslog \ $(LOCAL_PATH)/../external/poly2tri \ $(LOCAL_PATH)/../external/poly2tri/common \ - $(LOCAL_PATH)/../external/poly2tri/sweep + $(LOCAL_PATH)/../external/poly2tri/sweep \ + $(LOCAL_PATH)/../external/clipper LOCAL_EXPORT_LDLIBS := -lGLESv2 \ -llog \ diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index 53ea160c86..311fe2728d 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -84,6 +84,7 @@ set(COCOS_SRC cocos2d.cpp #todo: provide prebuild versions of the xx libs for all platforms include_directories(../external/xxtea) + include_directories(../external/clipper) add_library(cocos2d ${COCOS_SRC}) diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 1393b701b5..c63d321809 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -254,6 +254,7 @@ THE SOFTWARE. #include "2d/CCAnimation.h" #include "2d/CCAnimationCache.h" #include "2d/CCSprite.h" +#include "2d/CCAutoPolygon.h" #include "2d/CCSpriteBatchNode.h" #include "2d/CCSpriteFrame.h" #include "2d/CCSpriteFrameCache.h" diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h index 7ec93d211c..20efc81e2f 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h index 012ee837a6..f80a0dbfc7 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineNode.h b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineNode.h index c8c5b6023a..f225dd57a0 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineNode.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineNode.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h index ba2e2b5c06..3668667aa6 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCFrame.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCTimeLine.h b/cocos/editor-support/cocostudio/ActionTimeline/CCTimeLine.h index 8228baed89..753e60364a 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCTimeLine.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCTimeLine.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCTimelineMacro.h b/cocos/editor-support/cocostudio/ActionTimeline/CCTimelineMacro.h index 5a54856919..804e0ea87e 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCTimelineMacro.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCTimelineMacro.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2013-2014 Chukong Technologies diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h index 2169762fff..e2db19bb5c 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCActionFrame.h b/cocos/editor-support/cocostudio/CCActionFrame.h index a6f71c6172..7ca66da87c 100644 --- a/cocos/editor-support/cocostudio/CCActionFrame.h +++ b/cocos/editor-support/cocostudio/CCActionFrame.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -33,26 +33,26 @@ namespace cocostudio { enum FrameType { - kKeyframeMove = 0, - kKeyframeScale, - kKeyframeRotate, - kKeyframeTint, - kKeyframeFade, - kKeyframeMax + kKeyframeMove = 0, + kKeyframeScale, + kKeyframeRotate, + kKeyframeTint, + kKeyframeFade, + kKeyframeMax }; enum class FrameEaseType { - Custom = -1, + Custom = -1, - LINERAR = 0, + LINERAR = 0, SINE_EASEIN, - SINE_EASEOUT, - SINE_EASEINOUT, + SINE_EASEOUT, + SINE_EASEINOUT, QUAD_EASEIN, - QUAD_EASEOUT, + QUAD_EASEOUT, QUAD_EASEINOUT, CUBIC_EASEIN, @@ -64,7 +64,7 @@ enum class FrameEaseType QUART_EASEINOUT, QUINT_EASEIN, - QUINT_EASEOUT, + QUINT_EASEOUT, QUINT_EASEINOUT, EXPO_EASEIN, @@ -87,7 +87,7 @@ enum class FrameEaseType BOUNCE_EASEOUT, BOUNCE_EASEINOUT, - TWEEN_EASING_MAX = 10000 + TWEEN_EASING_MAX = 10000 }; /** * @js NA @@ -98,113 +98,113 @@ class CC_STUDIO_DLL ActionFrame: public cocos2d::Ref public: - /** - * Default constructor - */ - ActionFrame(); + /** + * Default constructor + */ + ActionFrame(); - /** - * Default destructor - */ - virtual ~ActionFrame(); + /** + * Default destructor + */ + virtual ~ActionFrame(); - /** - * Changes the index of action frame - * - * @param index the index of action frame - */ - void setFrameIndex(int index); + /** + * Changes the index of action frame + * + * @param index the index of action frame + */ + void setFrameIndex(int index); - /** - * Gets the index of action frame - * - * @return the index of action frame - */ - int getFrameIndex(); + /** + * Gets the index of action frame + * + * @return the index of action frame + */ + int getFrameIndex(); - /** - * Changes the time of action frame - * - * @param fTime the time of action frame - */ - void setFrameTime(float fTime); + /** + * Changes the time of action frame + * + * @param fTime the time of action frame + */ + void setFrameTime(float fTime); - /** - * Gets the time of action frame - * - * @return fTime the time of action frame - */ - float getFrameTime(); + /** + * Gets the time of action frame + * + * @return fTime the time of action frame + */ + float getFrameTime(); - /** - * Changes the type of action frame - * - * @param frameType the type of action frame - */ - void setFrameType(int frameType); + /** + * Changes the type of action frame + * + * @param frameType the type of action frame + */ + void setFrameType(int frameType); - /** - * Gets the type of action frame - * - * @return the type of action frame - */ - int getFrameType(); + /** + * Gets the type of action frame + * + * @return the type of action frame + */ + int getFrameType(); - /** - * Changes the easing type. - * - * @param easingType the easing type. - */ - void setEasingType(int easingType); + /** + * Changes the easing type. + * + * @param easingType the easing type. + */ + void setEasingType(int easingType); - /** - * Gets the easing type. - * - * @return the easing type. - */ - int getEasingType(); + /** + * Gets the easing type. + * + * @return the easing type. + */ + int getEasingType(); - /** - * Gets the ActionInterval of ActionFrame. - * - * @parame duration the duration time of ActionFrame - * - * @return ActionInterval - */ - virtual cocos2d::ActionInterval* getAction(float duration); - /** - * Gets the ActionInterval of ActionFrame. - * - * @parame duration the duration time of ActionFrame - * - * @parame duration the source ActionFrame - * - * @return ActionInterval - */ - virtual cocos2d::ActionInterval* getAction(float duration,ActionFrame* srcFrame); + /** + * Gets the ActionInterval of ActionFrame. + * + * @parame duration the duration time of ActionFrame + * + * @return ActionInterval + */ + virtual cocos2d::ActionInterval* getAction(float duration); + /** + * Gets the ActionInterval of ActionFrame. + * + * @parame duration the duration time of ActionFrame + * + * @parame duration the source ActionFrame + * + * @return ActionInterval + */ + virtual cocos2d::ActionInterval* getAction(float duration,ActionFrame* srcFrame); - /** - *Set the ActionInterval easing parameter. - * - *@parame parameter the parameter for frame ease - * - */ - virtual void setEasingParameter(std::vector& parameter); + /** + *Set the ActionInterval easing parameter. + * + *@parame parameter the parameter for frame ease + * + */ + virtual void setEasingParameter(std::vector& parameter); protected: - /** - * Gets the Easing Action of ActionFrame. - * - * @parame action the duration time of ActionFrame - * - * @return ActionInterval - */ - virtual cocos2d::ActionInterval* getEasingAction(cocos2d::ActionInterval* action); + /** + * Gets the Easing Action of ActionFrame. + * + * @parame action the duration time of ActionFrame + * + * @return ActionInterval + */ + virtual cocos2d::ActionInterval* getEasingAction(cocos2d::ActionInterval* action); protected: - int _frameType; - int _frameIndex; - float _fTime; - FrameEaseType _easingType; - std::vector _Parameter; + int _frameType; + int _frameIndex; + float _fTime; + FrameEaseType _easingType; + std::vector _Parameter; }; /** @@ -215,38 +215,38 @@ class CC_STUDIO_DLL ActionMoveFrame:public ActionFrame { public: - /** - * Default constructor - */ - ActionMoveFrame(); + /** + * Default constructor + */ + ActionMoveFrame(); - /** - * Default destructor - */ - virtual ~ActionMoveFrame(); + /** + * Default destructor + */ + virtual ~ActionMoveFrame(); - /** - * Changes the move action position. - * - * @param the move action position. - */ - void setPosition(cocos2d::Vec2 pos); + /** + * Changes the move action position. + * + * @param the move action position. + */ + void setPosition(cocos2d::Vec2 pos); - /** - * Gets the move action position. - * - * @return the move action position. - */ - cocos2d::Vec2 getPosition(); + /** + * Gets the move action position. + * + * @return the move action position. + */ + cocos2d::Vec2 getPosition(); - /** - * Gets the ActionInterval of ActionFrame. - * - * @parame duration the duration time of ActionFrame - * - * @return ActionInterval - */ - virtual cocos2d::ActionInterval* getAction(float duration); + /** + * Gets the ActionInterval of ActionFrame. + * + * @parame duration the duration time of ActionFrame + * + * @return ActionInterval + */ + virtual cocos2d::ActionInterval* getAction(float duration); protected: cocos2d::Vec2 _position; }; @@ -259,55 +259,55 @@ class CC_STUDIO_DLL ActionScaleFrame:public ActionFrame { public: - /** - * Default constructor - */ - ActionScaleFrame(); + /** + * Default constructor + */ + ActionScaleFrame(); - /** - * Default destructor - */ - virtual ~ActionScaleFrame(); + /** + * Default destructor + */ + virtual ~ActionScaleFrame(); - /** - * Changes the scale action scaleX. - * - * @param the scale action scaleX. - */ - void setScaleX(float scaleX); + /** + * Changes the scale action scaleX. + * + * @param the scale action scaleX. + */ + void setScaleX(float scaleX); - /** - * Gets the scale action scaleX. - * - * @return the scale action scaleX. - */ - float getScaleX(); + /** + * Gets the scale action scaleX. + * + * @return the scale action scaleX. + */ + float getScaleX(); - /** - * Changes the scale action scaleY. - * - * @param rotation the scale action scaleY. - */ - void setScaleY(float scaleY); + /** + * Changes the scale action scaleY. + * + * @param rotation the scale action scaleY. + */ + void setScaleY(float scaleY); - /** - * Gets the scale action scaleY. - * - * @return the the scale action scaleY. - */ - float getScaleY(); + /** + * Gets the scale action scaleY. + * + * @return the the scale action scaleY. + */ + float getScaleY(); - /** - * Gets the ActionInterval of ActionFrame. - * - * @parame duration the duration time of ActionFrame - * - * @return ActionInterval - */ - virtual cocos2d::ActionInterval* getAction(float duration); + /** + * Gets the ActionInterval of ActionFrame. + * + * @parame duration the duration time of ActionFrame + * + * @return ActionInterval + */ + virtual cocos2d::ActionInterval* getAction(float duration); protected: - float _scaleX; - float _scaleY; + float _scaleX; + float _scaleY; }; /** * @js NA @@ -317,50 +317,50 @@ class CC_STUDIO_DLL ActionRotationFrame:public ActionFrame { public: - /** - * Default constructor - */ - ActionRotationFrame(); + /** + * Default constructor + */ + ActionRotationFrame(); - /** - * Default destructor - */ - virtual ~ActionRotationFrame(); + /** + * Default destructor + */ + virtual ~ActionRotationFrame(); - /** - * Changes rotate action rotation. - * - * @param rotation rotate action rotation. - */ - void setRotation(float rotation); + /** + * Changes rotate action rotation. + * + * @param rotation rotate action rotation. + */ + void setRotation(float rotation); - /** - * Gets the rotate action rotation. - * - * @return the rotate action rotation. - */ - float getRotation(); + /** + * Gets the rotate action rotation. + * + * @return the rotate action rotation. + */ + float getRotation(); - /** - * Gets the ActionInterval of ActionFrame. - * - * @parame duration the duration time of ActionFrame - * - * @return ActionInterval - */ - virtual cocos2d::ActionInterval* getAction(float duration); - /** - * Gets the ActionInterval of ActionFrame. - * - * @parame duration the duration time of ActionFrame - * - * @parame duration the source ActionFrame - * - * @return ActionInterval - */ - virtual cocos2d::ActionInterval* getAction(float duration,ActionFrame* srcFrame); + /** + * Gets the ActionInterval of ActionFrame. + * + * @parame duration the duration time of ActionFrame + * + * @return ActionInterval + */ + virtual cocos2d::ActionInterval* getAction(float duration); + /** + * Gets the ActionInterval of ActionFrame. + * + * @parame duration the duration time of ActionFrame + * + * @parame duration the source ActionFrame + * + * @return ActionInterval + */ + virtual cocos2d::ActionInterval* getAction(float duration,ActionFrame* srcFrame); public: - float _rotation; + float _rotation; }; /** * @js NA @@ -370,40 +370,40 @@ class CC_STUDIO_DLL ActionFadeFrame:public ActionFrame { public: - /** - * Default constructor - */ - ActionFadeFrame(); + /** + * Default constructor + */ + ActionFadeFrame(); - /** - * Default destructor - */ - virtual ~ActionFadeFrame(); + /** + * Default destructor + */ + virtual ~ActionFadeFrame(); - /** - * Changes the fade action opacity. - * - * @param opacity the fade action opacity - */ - void setOpacity(int opacity); + /** + * Changes the fade action opacity. + * + * @param opacity the fade action opacity + */ + void setOpacity(int opacity); - /** - * Gets the fade action opacity. - * - * @return the fade action opacity. - */ - int getOpacity(); + /** + * Gets the fade action opacity. + * + * @return the fade action opacity. + */ + int getOpacity(); - /** - * Gets the ActionInterval of ActionFrame. - * - * @parame duration the duration time of ActionFrame - * - * @return ActionInterval - */ - virtual cocos2d::ActionInterval* getAction(float duration); + /** + * Gets the ActionInterval of ActionFrame. + * + * @parame duration the duration time of ActionFrame + * + * @return ActionInterval + */ + virtual cocos2d::ActionInterval* getAction(float duration); protected: - float _opacity; + float _opacity; }; /** * @js NA @@ -414,40 +414,40 @@ class CC_STUDIO_DLL ActionTintFrame:public ActionFrame public: - /** - * Default constructor - */ - ActionTintFrame(); + /** + * Default constructor + */ + ActionTintFrame(); - /** - * Default destructor - */ - virtual ~ActionTintFrame(); + /** + * Default destructor + */ + virtual ~ActionTintFrame(); - /** - * Changes the tint action color. - * - * @param ccolor the tint action color - */ - void setColor(cocos2d::Color3B ccolor); + /** + * Changes the tint action color. + * + * @param ccolor the tint action color + */ + void setColor(cocos2d::Color3B ccolor); - /** - * Gets the tint action color. - * - * @return the tint action color. - */ - cocos2d::Color3B getColor(); + /** + * Gets the tint action color. + * + * @return the tint action color. + */ + cocos2d::Color3B getColor(); - /** - * Gets the ActionInterval of ActionFrame. - * - * @parame duration the duration time of ActionFrame - * - * @return ActionInterval - */ - virtual cocos2d::ActionInterval* getAction(float duration); + /** + * Gets the ActionInterval of ActionFrame. + * + * @parame duration the duration time of ActionFrame + * + * @return ActionInterval + */ + virtual cocos2d::ActionInterval* getAction(float duration); protected: - cocos2d::Color3B _color; + cocos2d::Color3B _color; }; } diff --git a/cocos/editor-support/cocostudio/CCActionFrameEasing.h b/cocos/editor-support/cocostudio/CCActionFrameEasing.h index ea67bf0500..19fbf30ebd 100644 --- a/cocos/editor-support/cocostudio/CCActionFrameEasing.h +++ b/cocos/editor-support/cocostudio/CCActionFrameEasing.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -32,25 +32,25 @@ namespace cocostudio { enum FrameEasingType { - kframeEasingInstant, + kframeEasingInstant, - kframeEasingLinear, + kframeEasingLinear, - kframeEasingCubicIn, - kframeEasingCubicOut, - kframeEasingCubicInOut, + kframeEasingCubicIn, + kframeEasingCubicOut, + kframeEasingCubicInOut, - kframeEasingElasticIn, - kframeEasingElasticOut, - kframeEasingElasticInOut, + kframeEasingElasticIn, + kframeEasingElasticOut, + kframeEasingElasticInOut, - kframeEasingBounceIn, - kframeEasingBounceOut, - kframeEasingBounceInOut, + kframeEasingBounceIn, + kframeEasingBounceOut, + kframeEasingBounceInOut, - kframeEasingBackIn, - kframeEasingBackOut, - kframeEasingBackInOut, + kframeEasingBackIn, + kframeEasingBackOut, + kframeEasingBackInOut, }; /** @@ -60,15 +60,15 @@ enum FrameEasingType class CC_STUDIO_DLL ActionFrameEasing:public cocos2d::Ref { protected: - FrameEasingType _type; - float _fValue; + FrameEasingType _type; + float _fValue; public: - ActionFrameEasing(); - virtual ~ActionFrameEasing(); + ActionFrameEasing(); + virtual ~ActionFrameEasing(); - float bounceTime(float t); + float bounceTime(float t); - float easeValue(float t); + float easeValue(float t); }; } diff --git a/cocos/editor-support/cocostudio/CCActionManagerEx.h b/cocos/editor-support/cocostudio/CCActionManagerEx.h index bf2fde8b6c..9b98edbbd3 100644 --- a/cocos/editor-support/cocostudio/CCActionManagerEx.h +++ b/cocos/editor-support/cocostudio/CCActionManagerEx.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -38,89 +38,89 @@ class CC_STUDIO_DLL ActionManagerEx:public cocos2d::Ref { public: - /** - * Default constructor - * @js ctor - */ - ActionManagerEx(); + /** + * Default constructor + * @js ctor + */ + ActionManagerEx(); - /** - * Default destructor - * @js NA - * @lua NA - */ - virtual ~ActionManagerEx(); + /** + * Default destructor + * @js NA + * @lua NA + */ + virtual ~ActionManagerEx(); - /** - * Gets the static instance of ActionManager. - * @js getInstance - * @lua getInstance - */ - static ActionManagerEx* getInstance(); + /** + * Gets the static instance of ActionManager. + * @js getInstance + * @lua getInstance + */ + static ActionManagerEx* getInstance(); - /** - * Purges ActionManager point. - * @js purge - * @lua destroyActionManager - */ - static void destroyInstance(); + /** + * Purges ActionManager point. + * @js purge + * @lua destroyActionManager + */ + static void destroyInstance(); - /** - * Gets an ActionObject with a name. - * - * @param jsonName UI file name - * - * @param actionName action name in the UI file. - * - * @return ActionObject which named as the param name - */ - ActionObject* getActionByName(const char* jsonName,const char* actionName); + /** + * Gets an ActionObject with a name. + * + * @param jsonName UI file name + * + * @param actionName action name in the UI file. + * + * @return ActionObject which named as the param name + */ + ActionObject* getActionByName(const char* jsonName,const char* actionName); - /** - * Play an Action with a name. - * - * @param jsonName UI file name - * - * @param actionName action name in teh UIfile. - * - * @return ActionObject which named as the param name - */ - ActionObject* playActionByName(const char* jsonName,const char* actionName); + /** + * Play an Action with a name. + * + * @param jsonName UI file name + * + * @param actionName action name in teh UIfile. + * + * @return ActionObject which named as the param name + */ + ActionObject* playActionByName(const char* jsonName,const char* actionName); - /** - * Play an Action with a name. - * - * @param jsonName UI file name - * - * @param actionName action name in teh UIfile. - * - * @param func ui action call back - */ - ActionObject* playActionByName(const char* jsonName,const char* actionName, cocos2d::CallFunc* func); + /** + * Play an Action with a name. + * + * @param jsonName UI file name + * + * @param actionName action name in teh UIfile. + * + * @param func ui action call back + */ + ActionObject* playActionByName(const char* jsonName,const char* actionName, cocos2d::CallFunc* func); - /** - * Stop an Action with a name. - * - * @param jsonName UI file name - * - * @param actionName action name in teh UIfile. - * - * @return ActionObject which named as the param name - */ - ActionObject* stopActionByName(const char* jsonName,const char* actionName); + /** + * Stop an Action with a name. + * + * @param jsonName UI file name + * + * @param actionName action name in teh UIfile. + * + * @return ActionObject which named as the param name + */ + ActionObject* stopActionByName(const char* jsonName,const char* actionName); - /*init properties with json dictionay*/ - void initWithDictionary(const char* jsonName,const rapidjson::Value &dic, Ref* root); - void initWithBinary(const char* file, Ref* root, CocoLoader* cocoLoader, stExpCocoNode* pCocoNode); + /*init properties with json dictionay*/ + void initWithDictionary(const char* jsonName,const rapidjson::Value &dic, Ref* root); + void initWithBinary(const char* file, Ref* root, CocoLoader* cocoLoader, stExpCocoNode* pCocoNode); - /** - * Release all actions. - * - */ - void releaseActions(); + /** + * Release all actions. + * + */ + void releaseActions(); protected: - std::unordered_map> _actionDic; + std::unordered_map> _actionDic; }; } diff --git a/cocos/editor-support/cocostudio/CCActionNode.h b/cocos/editor-support/cocostudio/CCActionNode.h index f862bed64e..1ab08afdef 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.h +++ b/cocos/editor-support/cocostudio/CCActionNode.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -41,149 +41,149 @@ class CC_STUDIO_DLL ActionNode : public cocos2d::Ref { public: - /** - * Default constructor - */ - ActionNode(); + /** + * Default constructor + */ + ActionNode(); - /** - * Default destructor - */ - virtual ~ActionNode(); - /** - * Sets the time interval of frame. - * - * @param fTime the time interval of frame - */ - void setUnitTime(float fTime); + /** + * Default destructor + */ + virtual ~ActionNode(); + /** + * Sets the time interval of frame. + * + * @param fTime the time interval of frame + */ + void setUnitTime(float fTime); - /** - * Gets the time interval of frame. - * - * @return fTime the time interval of frame - */ - float getUnitTime(); - /** - * Sets tag for ActionNode - * - * @param tag tag of ActionNode - */ - void setActionTag(int tag); + /** + * Gets the time interval of frame. + * + * @return fTime the time interval of frame + */ + float getUnitTime(); + /** + * Sets tag for ActionNode + * + * @param tag tag of ActionNode + */ + void setActionTag(int tag); - /** - * Gets tag for ActionNode - * - * @return tag tag of ActionNode - */ - int getActionTag(); + /** + * Gets tag for ActionNode + * + * @return tag tag of ActionNode + */ + int getActionTag(); - /** - * Sets node which will run a action. - * - * @param node which will run a action - */ - void setObject(cocos2d::Ref* node); + /** + * Sets node which will run a action. + * + * @param node which will run a action + */ + void setObject(cocos2d::Ref* node); - /** - * Gets node which will run a action. - * - * @return node which will run a action - */ - cocos2d::Ref* getObject(); + /** + * Gets node which will run a action. + * + * @return node which will run a action + */ + cocos2d::Ref* getObject(); - /** - * Insets a ActionFrame to ActionNode. - * - * @param index the index of ActionFrame - * - * @param frame the ActionFrame which will be inserted - */ - void insertFrame(int index, ActionFrame* frame); + /** + * Insets a ActionFrame to ActionNode. + * + * @param index the index of ActionFrame + * + * @param frame the ActionFrame which will be inserted + */ + void insertFrame(int index, ActionFrame* frame); - /** - * Pushs back a ActionFrame to ActionNode. - * - * @param frame the ActionFrame which will be added - */ - void addFrame(ActionFrame* frame); + /** + * Pushs back a ActionFrame to ActionNode. + * + * @param frame the ActionFrame which will be added + */ + void addFrame(ActionFrame* frame); - /** - * Remove a ActionFrame from ActionNode. - * - * @param frame the ActionFrame which will be removed - */ - void deleteFrame(ActionFrame* frame ); + /** + * Remove a ActionFrame from ActionNode. + * + * @param frame the ActionFrame which will be removed + */ + void deleteFrame(ActionFrame* frame ); - /** - * Remove all ActionFrames from ActionNode. - */ - void clearAllFrame(); + /** + * Remove all ActionFrames from ActionNode. + */ + void clearAllFrame(); - /** - * Gets index of first ActionFrame. - * - * @return index of first ActionFrame - */ - int getFirstFrameIndex(); + /** + * Gets index of first ActionFrame. + * + * @return index of first ActionFrame + */ + int getFirstFrameIndex(); - /** - * Gets index of last ActionFrame. - * - * @return index of last ActionFrame - */ - int getLastFrameIndex(); + /** + * Gets index of last ActionFrame. + * + * @return index of last ActionFrame + */ + int getLastFrameIndex(); - /** - * Updates action states to some time. - * - * @param fTime the time when need to update - */ - virtual bool updateActionToTimeLine(float fTime); + /** + * Updates action states to some time. + * + * @param fTime the time when need to update + */ + virtual bool updateActionToTimeLine(float fTime); - /** - * Play the action. - */ - virtual void playAction(); + /** + * Play the action. + */ + virtual void playAction(); - /** - * Stop the action. - */ - virtual void stopAction(); + /** + * Stop the action. + */ + virtual void stopAction(); - /*init properties with a json dictionary*/ - virtual void initWithDictionary(const rapidjson::Value& dic, cocos2d::Ref* root); - virtual void initWithBinary(CocoLoader* cocoLoader, stExpCocoNode* pCocoNode, Ref* root); + /*init properties with a json dictionary*/ + virtual void initWithDictionary(const rapidjson::Value& dic, cocos2d::Ref* root); + virtual void initWithBinary(CocoLoader* cocoLoader, stExpCocoNode* pCocoNode, Ref* root); - /** - * Gets if the action is done once time. - * - * @return that if the action is done once time - */ - virtual bool isActionDoneOnce(); + /** + * Gets if the action is done once time. + * + * @return that if the action is done once time + */ + virtual bool isActionDoneOnce(); protected: int valueToInt(const std::string& value); bool valueToBool(const std::string& value); float valueToFloat(const std::string& value); - int _currentFrameIndex; - int _destFrameIndex; + int _currentFrameIndex; + int _destFrameIndex; - float _fUnitTime; + float _fUnitTime; - int _actionTag; - cocos2d::Spawn * _actionSpawn; - cocos2d::Action* _action; - cocos2d::Ref* _object; + int _actionTag; + cocos2d::Spawn * _actionSpawn; + cocos2d::Action* _action; + cocos2d::Ref* _object; - std::vector*> _frameArray; - int _frameArrayNum; + std::vector*> _frameArray; + int _frameArrayNum; protected: - virtual cocos2d::Node* getActionNode(); - virtual cocos2d::Spawn * refreshActionProperty(); - virtual void runAction(); - virtual void initActionNodeFromRoot(cocos2d::Ref* root); - virtual void easingToFrame(float duration,float delayTime,ActionFrame* srcFrame,ActionFrame* destFrame); + virtual cocos2d::Node* getActionNode(); + virtual cocos2d::Spawn * refreshActionProperty(); + virtual void runAction(); + virtual void initActionNodeFromRoot(cocos2d::Ref* root); + virtual void easingToFrame(float duration,float delayTime,ActionFrame* srcFrame,ActionFrame* destFrame); }; } diff --git a/cocos/editor-support/cocostudio/CCActionObject.h b/cocos/editor-support/cocostudio/CCActionObject.h index 045c5a403d..4a9b16baba 100644 --- a/cocos/editor-support/cocostudio/CCActionObject.h +++ b/cocos/editor-support/cocostudio/CCActionObject.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -43,148 +43,148 @@ class CC_STUDIO_DLL ActionObject : public cocos2d::Ref { public: - /** - * Default constructor - */ - ActionObject(); + /** + * Default constructor + */ + ActionObject(); - /** - * Default destructor - */ - virtual ~ActionObject(); + /** + * Default destructor + */ + virtual ~ActionObject(); - /** - * Sets name for object - * - * @param name name of object - */ - void setName(const char* name); + /** + * Sets name for object + * + * @param name name of object + */ + void setName(const char* name); - /** - * Gets name of object - * - * @return name of object - */ - const char* getName(); + /** + * Gets name of object + * + * @return name of object + */ + const char* getName(); - /** - * Sets if the action will loop play. - * - * @param bLoop that if the action will loop play - */ - void setLoop(bool bLoop); + /** + * Sets if the action will loop play. + * + * @param bLoop that if the action will loop play + */ + void setLoop(bool bLoop); - /** - * Gets if the action will loop play. - * - * @return that if the action will loop play - */ - bool getLoop(); + /** + * Gets if the action will loop play. + * + * @return that if the action will loop play + */ + bool getLoop(); - /** - * Sets the time interval of frame. - * - * @param fTime the time interval of frame - */ - void setUnitTime(float fTime); + /** + * Sets the time interval of frame. + * + * @param fTime the time interval of frame + */ + void setUnitTime(float fTime); - /** - * Gets the time interval of frame. - * - * @return the time interval of frame - */ - float getUnitTime(); + /** + * Gets the time interval of frame. + * + * @return the time interval of frame + */ + float getUnitTime(); - /** - * Sets the current time of frame. - * - * @param fTime the current time of frame - */ - void setCurrentTime(float fTime); + /** + * Sets the current time of frame. + * + * @param fTime the current time of frame + */ + void setCurrentTime(float fTime); - /** - * Gets the current time of frame. - * - * @return the current time of frame - */ - float getCurrentTime(); + /** + * Gets the current time of frame. + * + * @return the current time of frame + */ + float getCurrentTime(); - /** - * Gets the total time of frame. - * - * @return the total time of frame - */ - float getTotalTime(); + /** + * Gets the total time of frame. + * + * @return the total time of frame + */ + float getTotalTime(); - /** - * Return if the action is playing. - * - * @return true if the action is playing, false the otherwise - */ - bool isPlaying(); + /** + * Return if the action is playing. + * + * @return true if the action is playing, false the otherwise + */ + bool isPlaying(); - /** - * Play the action. - */ - void play(); + /** + * Play the action. + */ + void play(); - /** - * Play the action. - * - * @param func Action Call Back - */ - void play(cocos2d::CallFunc* func); + /** + * Play the action. + * + * @param func Action Call Back + */ + void play(cocos2d::CallFunc* func); - /** - * Pause the action. - */ - void pause(); + /** + * Pause the action. + */ + void pause(); - /** - * Stop the action. - */ - void stop(); + /** + * Stop the action. + */ + void stop(); - /** - * Adds a ActionNode to play the action. - * - * @param node the ActionNode which will play the action - */ - void addActionNode(ActionNode* node); + /** + * Adds a ActionNode to play the action. + * + * @param node the ActionNode which will play the action + */ + void addActionNode(ActionNode* node); - /** - * Removes a ActionNode which play the action. - * - * @param node the ActionNode which play the action - */ - void removeActionNode(ActionNode* node); + /** + * Removes a ActionNode which play the action. + * + * @param node the ActionNode which play the action + */ + void removeActionNode(ActionNode* node); - /*update frame method*/ - void updateToFrameByTime(float fTime); + /*update frame method*/ + void updateToFrameByTime(float fTime); - /*init properties with a json dictionary*/ - void initWithDictionary(const rapidjson::Value& dic, cocos2d::Ref* root); + /*init properties with a json dictionary*/ + void initWithDictionary(const rapidjson::Value& dic, cocos2d::Ref* root); - void initWithBinary(CocoLoader* cocoLoader, stExpCocoNode* pCocoNode, cocos2d::Ref* root); + void initWithBinary(CocoLoader* cocoLoader, stExpCocoNode* pCocoNode, cocos2d::Ref* root); - /*scheduler update function*/ - void simulationActionUpdate(float dt); + /*scheduler update function*/ + void simulationActionUpdate(float dt); protected: int valueToInt(const std::string& value); bool valueToBool(const std::string& value); float valueToFloat(const std::string& value); - cocos2d::Vector _actionNodeList; - std::string _name; - bool _loop; - bool _bPause; - bool _bPlaying; - float _fUnitTime; - float _currentTime; - cocos2d::Scheduler *_pScheduler; - cocos2d::CallFunc *_CallBack; - float _fTotalTime; + cocos2d::Vector _actionNodeList; + std::string _name; + bool _loop; + bool _bPause; + bool _bPlaying; + float _fUnitTime; + float _currentTime; + cocos2d::Scheduler *_pScheduler; + cocos2d::CallFunc *_CallBack; + float _fTotalTime; }; } diff --git a/cocos/editor-support/cocostudio/CCArmature.h b/cocos/editor-support/cocostudio/CCArmature.h index ff0de2f2da..43357449f3 100644 --- a/cocos/editor-support/cocostudio/CCArmature.h +++ b/cocos/editor-support/cocostudio/CCArmature.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -176,7 +176,7 @@ public: * @lua NA */ inline const cocos2d::BlendFunc &getBlendFunc(void) const override{ return _blendFunc; } - + /** * Set contentsize and Calculate anchor point. diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.h b/cocos/editor-support/cocostudio/CCArmatureAnimation.h index 62146793a1..28cc89a66f 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.h +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -75,7 +75,7 @@ public: */ static ArmatureAnimation *create(Armature *armature); public: - /** + /** * @js ctor */ ArmatureAnimation(); @@ -275,13 +275,13 @@ protected: //! Scale the animation speed float _speedScale; - MovementData *_movementData; //! MovementData save all MovementFrameDatas this animation used. + MovementData *_movementData; //! MovementData save all MovementFrameDatas this animation used. - Armature *_armature; //! A weak reference of armature + Armature *_armature; //! A weak reference of armature - std::string _movementID; //! Current movment's name + std::string _movementID; //! Current movment's name - int _toIndex; //! The frame index in MovementData->m_pMovFrameDataArr, it's different from m_iFrameIndex. + int _toIndex; //! The frame index in MovementData->m_pMovFrameDataArr, it's different from m_iFrameIndex. cocos2d::Vector _tweenList; diff --git a/cocos/editor-support/cocostudio/CCArmatureDataManager.h b/cocos/editor-support/cocostudio/CCArmatureDataManager.h index a42072528f..2f23c96f2f 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDataManager.h +++ b/cocos/editor-support/cocostudio/CCArmatureDataManager.h @@ -40,12 +40,12 @@ struct RelativeData }; /** - * @brief format and manage armature configuration and armature animation + * @brief format and manage armature configuration and armature animation */ class CC_STUDIO_DLL ArmatureDataManager : public cocos2d::Ref { public: - /** @deprecated Use getInstance() instead */ + /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static ArmatureDataManager *sharedArmatureDataManager() { return ArmatureDataManager::getInstance(); } /** @deprecated Use destoryInstance() instead */ @@ -55,7 +55,7 @@ public: static void destroyInstance(); private: - /** + /** * @js ctor */ ArmatureDataManager(void); @@ -80,82 +80,82 @@ public: void addArmatureData(const std::string& id, ArmatureData *armatureData, const std::string& configFilePath = ""); /** - * @brief get armature data - * @param id the id of the armature data you want to get - * @return ArmatureData * + * @brief get armature data + * @param id the id of the armature data you want to get + * @return ArmatureData * */ ArmatureData *getArmatureData(const std::string& id); /** - * @brief remove armature data - * @param id the id of the armature data you want to get + * @brief remove armature data + * @param id the id of the armature data you want to get */ void removeArmatureData(const std::string& id); /** - * @brief add animation data - * @param id the id of the animation data + * @brief add animation data + * @param id the id of the animation data * @return AnimationData * */ void addAnimationData(const std::string& id, AnimationData *animationData, const std::string& configFilePath = ""); /** - * @brief get animation data from _animationDatas(Dictionary) - * @param id the id of the animation data you want to get + * @brief get animation data from _animationDatas(Dictionary) + * @param id the id of the animation data you want to get * @return AnimationData * */ AnimationData *getAnimationData(const std::string& id); /** - * @brief remove animation data - * @param id the id of the animation data + * @brief remove animation data + * @param id the id of the animation data */ void removeAnimationData(const std::string& id); /** - * @brief add texture data - * @param id the id of the texture data + * @brief add texture data + * @param id the id of the texture data * @return TextureData * */ void addTextureData(const std::string& id, TextureData *textureData, const std::string& configFilePath = ""); /** - * @brief get texture data - * @param id the id of the texture data you want to get + * @brief get texture data + * @param id the id of the texture data you want to get * @return TextureData * */ TextureData *getTextureData(const std::string& id); /** - * @brief remove texture data - * @param id the id of the texture data you want to get + * @brief remove texture data + * @param id the id of the texture data you want to get */ void removeTextureData(const std::string& id); /** - * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. + * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. */ void addArmatureFileInfo(const std::string& configFilePath); /** - * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. - * It will load data in a new thread + * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. + * It will load data in a new thread */ void addArmatureFileInfoAsync(const std::string& configFilePath, cocos2d::Ref *target, cocos2d::SEL_SCHEDULE selector); /** - * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. + * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. */ void addArmatureFileInfo(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath); /** - * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. - * It will load data in a new thread + * @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager. + * It will load data in a new thread */ void addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, cocos2d::Ref *target, cocos2d::SEL_SCHEDULE selector); /** - * @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name + * @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name */ void addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath, const std::string& configFilePath = ""); @@ -163,7 +163,7 @@ public: /** - * @brief Juge whether or not need auto load sprite file + * @brief Juge whether or not need auto load sprite file */ bool isAutoLoadSpriteFile(); @@ -177,23 +177,23 @@ protected: RelativeData *getRelativeData(const std::string& configFilePath); private: /** - * @brief save amature datas - * @key std::string - * @value ArmatureData * + * @brief save amature datas + * @key std::string + * @value ArmatureData * */ cocos2d::Map _armarureDatas; /** - * @brief save animation datas - * @key std::string - * @value AnimationData * + * @brief save animation datas + * @key std::string + * @value AnimationData * */ cocos2d::Map _animationDatas; /** - * @brief save texture datas - * @key std::string - * @value TextureData * + * @brief save texture datas + * @key std::string + * @value TextureData * */ cocos2d::Map _textureDatas; diff --git a/cocos/editor-support/cocostudio/CCArmatureDefine.h b/cocos/editor-support/cocostudio/CCArmatureDefine.h index 8c8eca2608..eb0bad7530 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDefine.h +++ b/cocos/editor-support/cocostudio/CCArmatureDefine.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCBatchNode.h b/cocos/editor-support/cocostudio/CCBatchNode.h index bb52eba815..44cb4632a4 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.h +++ b/cocos/editor-support/cocostudio/CCBatchNode.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -40,7 +40,7 @@ class CC_STUDIO_DLL BatchNode : public cocos2d::Node public: static BatchNode *create(); public: - /** + /** * @js ctor */ BatchNode(); diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index ec7661b380..91c400fc76 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -101,7 +101,7 @@ public: /** * Add a child to this bone, and it will let this child call setParent(Bone *parent) function to set self to it's parent - * @param child the child you want to add + * @param child the child you want to add */ void addChildBone(Bone *child); @@ -130,7 +130,7 @@ public: /** * Removes a child Bone - * @param bone the bone you want to remove + * @param bone the bone you want to remove */ void removeChildBone(Bone *bone, bool recursion); @@ -227,20 +227,20 @@ protected: DisplayManager *_displayManager; /* - * When Armature play an animation, if there is not a MovementBoneData of this bone in this MovementData, this bone will be hidden. - * Set IgnoreMovementBoneData to true, then this bone will also be shown. + * When Armature play an animation, if there is not a MovementBoneData of this bone in this MovementData, this bone will be hidden. + * Set IgnoreMovementBoneData to true, then this bone will also be shown. */ bool _ignoreMovementBoneData; cocos2d::BlendFunc _blendFunc; bool _blendDirty; - Tween *_tween; //! Calculate tween effect + Tween *_tween; //! Calculate tween effect //! Used for making tween effect in every frame FrameData *_tweenData; - Bone *_parentBone; //! A weak reference to its parent + Bone *_parentBone; //! A weak reference to its parent bool _boneTransformDirty; //! Whether or not transform dirty //! self Transform, use this to change display's state diff --git a/cocos/editor-support/cocostudio/CCColliderDetector.h b/cocos/editor-support/cocostudio/CCColliderDetector.h index 3ddc289a6e..9ce91d55b1 100644 --- a/cocos/editor-support/cocostudio/CCColliderDetector.h +++ b/cocos/editor-support/cocostudio/CCColliderDetector.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -137,7 +137,7 @@ public: static ColliderDetector *create(); static ColliderDetector *create(Bone *bone); public: - /** + /** * @js ctor */ ColliderDetector(); diff --git a/cocos/editor-support/cocostudio/CCComAttribute.h b/cocos/editor-support/cocostudio/CCComAttribute.h index b97a000f73..0370af0d8d 100644 --- a/cocos/editor-support/cocostudio/CCComAttribute.h +++ b/cocos/editor-support/cocostudio/CCComAttribute.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCComAudio.h b/cocos/editor-support/cocostudio/CCComAudio.h index a5997aadeb..116fe4e71f 100644 --- a/cocos/editor-support/cocostudio/CCComAudio.h +++ b/cocos/editor-support/cocostudio/CCComAudio.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -59,16 +59,16 @@ public: * @lua NA */ virtual void onExit() override; - /** - * @js NA - * @lua NA - */ - virtual void onAdd() override; - /** - * @js NA - * @lua NA - */ - virtual void onRemove() override; + /** + * @js NA + * @lua NA + */ + virtual void onAdd() override; + /** + * @js NA + * @lua NA + */ + virtual void onRemove() override; virtual bool isEnabled() const override; virtual void setEnabled(bool b) override; virtual bool serialize(void* r) override; @@ -108,8 +108,8 @@ public: void setLoop(bool bLoop); bool isLoop(); private: - std::string _filePath; - bool _loop; + std::string _filePath; + bool _loop; }; } diff --git a/cocos/editor-support/cocostudio/CCComBase.h b/cocos/editor-support/cocostudio/CCComBase.h index 21750ab22b..744ab0aa79 100644 --- a/cocos/editor-support/cocostudio/CCComBase.h +++ b/cocos/editor-support/cocostudio/CCComBase.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCComController.h b/cocos/editor-support/cocostudio/CCComController.h index c3dda3fd1e..82742a74a3 100644 --- a/cocos/editor-support/cocostudio/CCComController.h +++ b/cocos/editor-support/cocostudio/CCComController.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCComRender.h b/cocos/editor-support/cocostudio/CCComRender.h index 2911359bd8..9abf5d7d77 100644 --- a/cocos/editor-support/cocostudio/CCComRender.h +++ b/cocos/editor-support/cocostudio/CCComRender.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.h b/cocos/editor-support/cocostudio/CCDataReaderHelper.h index eb0330af3c..ff3f1c2fc8 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.h +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.h @@ -56,44 +56,44 @@ class CC_STUDIO_DLL DataReaderHelper : cocos2d::Ref { protected: - enum ConfigType - { - DragonBone_XML, - CocoStudio_JSON, + enum ConfigType + { + DragonBone_XML, + CocoStudio_JSON, CocoStudio_Binary - }; + }; - typedef struct _AsyncStruct - { - std::string filename; - std::string fileContent; - ConfigType configType; - std::string baseFilePath; - cocos2d::Ref *target; - cocos2d::SEL_SCHEDULE selector; - bool autoLoadSpriteFile; + typedef struct _AsyncStruct + { + std::string filename; + std::string fileContent; + ConfigType configType; + std::string baseFilePath; + cocos2d::Ref *target; + cocos2d::SEL_SCHEDULE selector; + bool autoLoadSpriteFile; std::string imagePath; std::string plistPath; - } AsyncStruct; + } AsyncStruct; - typedef struct _DataInfo - { - AsyncStruct *asyncStruct; - std::queue configFileQueue; + typedef struct _DataInfo + { + AsyncStruct *asyncStruct; + std::queue configFileQueue; float contentScale; std::string filename; std::string baseFilePath; float flashToolVersion; float cocoStudioVersion; - } DataInfo; + } DataInfo; public: - /** @deprecated Use getInstance() instead */ - CC_DEPRECATED_ATTRIBUTE static DataReaderHelper *sharedDataReaderHelper() { return DataReaderHelper::getInstance(); } + /** @deprecated Use getInstance() instead */ + CC_DEPRECATED_ATTRIBUTE static DataReaderHelper *sharedDataReaderHelper() { return DataReaderHelper::getInstance(); } - static DataReaderHelper *getInstance(); + static DataReaderHelper *getInstance(); /** * Scale the position data, used for multiresolution adapter @@ -104,10 +104,10 @@ public: static void purge(); public: - /** + /** * @js ctor */ - DataReaderHelper(); + DataReaderHelper(); /** * @js NA * @lua NA @@ -179,48 +179,48 @@ public: // for binary decode public: - static void addDataFromBinaryCache(const char *fileContent, DataInfo *dataInfo = nullptr); - static ArmatureData *decodeArmature(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); - static BoneData *decodeBone(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); - static DisplayData *decodeBoneDisplay(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); - static AnimationData *decodeAnimation(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); - static MovementData *decodeMovement(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); + static void addDataFromBinaryCache(const char *fileContent, DataInfo *dataInfo = nullptr); + static ArmatureData *decodeArmature(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); + static BoneData *decodeBone(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); + static DisplayData *decodeBoneDisplay(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); + static AnimationData *decodeAnimation(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); + static MovementData *decodeMovement(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); - static MovementBoneData *decodeMovementBone(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); - static FrameData *decodeFrame(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); + static MovementBoneData *decodeMovementBone(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); + static FrameData *decodeFrame(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); - static TextureData *decodeTexture(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode); - static ContourData *decodeContour(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode); + static TextureData *decodeTexture(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode); + static ContourData *decodeContour(CocoLoader *cocoLoader, stExpCocoNode *pCocoNode); - static void decodeNode(BaseData *node, CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); + static void decodeNode(BaseData *node, CocoLoader *cocoLoader, stExpCocoNode *pCocoNode, DataInfo *dataInfo); protected: - void loadData(); + void loadData(); - std::condition_variable _sleepCondition; + std::condition_variable _sleepCondition; - std::thread *_loadingThread; + std::thread *_loadingThread; - std::mutex _sleepMutex; + std::mutex _sleepMutex; - std::mutex _asyncStructQueueMutex; - std::mutex _dataInfoMutex; + std::mutex _asyncStructQueueMutex; + std::mutex _dataInfoMutex; - std::mutex _addDataMutex; + std::mutex _addDataMutex; std::mutex _getFileMutex; - - unsigned long _asyncRefCount; - unsigned long _asyncRefTotalCount; + + unsigned long _asyncRefCount; + unsigned long _asyncRefTotalCount; - bool need_quit; + bool need_quit; - std::queue *_asyncStructQueue; - std::queue *_dataQueue; + std::queue *_asyncStructQueue; + std::queue *_dataQueue; static std::vector _configFileList; diff --git a/cocos/editor-support/cocostudio/CCDatas.h b/cocos/editor-support/cocostudio/CCDatas.h index 2eac5f9511..487638c025 100644 --- a/cocos/editor-support/cocostudio/CCDatas.h +++ b/cocos/editor-support/cocostudio/CCDatas.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -38,28 +38,28 @@ THE SOFTWARE. #define CC_CREATE_NO_PARAM_NO_INIT(varType)\ public: \ - static inline varType *create(void){ \ - varType *var = new varType();\ - if (var)\ + static inline varType *create(void){ \ + varType *var = new varType();\ + if (var)\ {\ - var->autorelease();\ - return var;\ + var->autorelease();\ + return var;\ }\ - CC_SAFE_DELETE(var);\ - return nullptr;\ + CC_SAFE_DELETE(var);\ + return nullptr;\ } #define CC_CREATE_NO_PARAM(varType)\ public: \ - static inline varType *create(void){ \ - varType *var = new varType();\ - if (var && var->init())\ + static inline varType *create(void){ \ + varType *var = new varType();\ + if (var && var->init())\ {\ - var->autorelease();\ - return var;\ + var->autorelease();\ + return var;\ }\ - CC_SAFE_DELETE(var);\ - return nullptr;\ + CC_SAFE_DELETE(var);\ + return nullptr;\ } namespace cocostudio { @@ -74,7 +74,7 @@ class CC_STUDIO_DLL BaseData : public cocos2d::Ref public: CC_CREATE_NO_PARAM_NO_INIT(BaseData) public: - /** + /** * @js ctor */ BaseData(); @@ -101,9 +101,9 @@ public: virtual void setColor(const cocos2d::Color4B &color); virtual cocos2d::Color4B getColor(); public: - float x; //! position x attribute - float y; //! position y attribute - int zOrder; //! zorder attribute, used to order the Bone's depth order + float x; //! position x attribute + float y; //! position y attribute + int zOrder; //! zorder attribute, used to order the Bone's depth order /** * x y skewX skewY scaleX scaleY used to calculate transform matrix @@ -145,7 +145,7 @@ public: static const std::string changeDisplayToTexture(const std::string& displayName); public: - /** + /** * @js ctor */ DisplayData(); @@ -157,7 +157,7 @@ public: virtual void copy(DisplayData *displayData); - DisplayType displayType; //! mark which type your display is + DisplayType displayType; //! mark which type your display is std::string displayName; }; @@ -171,7 +171,7 @@ class CC_STUDIO_DLL SpriteDisplayData : public DisplayData public: CC_CREATE_NO_PARAM_NO_INIT(SpriteDisplayData) public: - /** + /** * @js ctor */ SpriteDisplayData(); @@ -195,7 +195,7 @@ class CC_STUDIO_DLL ArmatureDisplayData : public DisplayData public: CC_CREATE_NO_PARAM_NO_INIT(ArmatureDisplayData) public: - /** + /** * @js ctor */ ArmatureDisplayData(); @@ -215,7 +215,7 @@ class CC_STUDIO_DLL ParticleDisplayData : public DisplayData public: CC_CREATE_NO_PARAM_NO_INIT(ParticleDisplayData) public: - /** + /** * @js ctor */ ParticleDisplayData(); @@ -240,7 +240,7 @@ class CC_STUDIO_DLL BoneData : public BaseData public: CC_CREATE_NO_PARAM(BoneData) public: - /** + /** * @js ctor */ BoneData(void); @@ -274,7 +274,7 @@ class CC_STUDIO_DLL ArmatureData : public cocos2d::Ref public: CC_CREATE_NO_PARAM(ArmatureData) public: - /** + /** * @js ctor */ ArmatureData(); @@ -320,7 +320,7 @@ class CC_STUDIO_DLL FrameData : public BaseData public: CC_CREATE_NO_PARAM_NO_INIT(FrameData) public: - /** + /** * @js ctor */ FrameData(); @@ -367,7 +367,7 @@ class CC_STUDIO_DLL MovementBoneData : public cocos2d::Ref public: CC_CREATE_NO_PARAM(MovementBoneData) public: - /** + /** * @js ctor */ MovementBoneData(); @@ -399,7 +399,7 @@ class CC_STUDIO_DLL MovementData : public cocos2d::Ref public: CC_CREATE_NO_PARAM_NO_INIT(MovementData) public: - /** + /** * @js ctor */ MovementData(void); @@ -414,7 +414,7 @@ public: public: std::string name; int duration; //! the frames this movement will last - float scale; //! scale this movement + float scale; //! scale this movement /** * Change to this movement will last durationTo frames. Use this effect can avoid too suddenly changing. @@ -441,9 +441,9 @@ public: cocos2d::tweenfunc::TweenType tweenEasing; /** - * @brief save movment bone data - * @key const std::string& - * @value MovementBoneData * + * @brief save movment bone data + * @key const std::string& + * @value MovementBoneData * */ cocos2d::Map movBoneDataDic; }; @@ -461,7 +461,7 @@ class CC_STUDIO_DLL AnimationData : public cocos2d::Ref public: CC_CREATE_NO_PARAM_NO_INIT(AnimationData) public: - /** + /** * @js ctor */ AnimationData(void); @@ -492,7 +492,7 @@ class CC_STUDIO_DLL ContourData : public cocos2d::Ref public: CC_CREATE_NO_PARAM(ContourData) public: - /** + /** * @js ctor */ ContourData(); @@ -505,7 +505,7 @@ public: virtual bool init(); virtual void addVertex(cocos2d::Vec2 &vertex); public: - std::vector vertexList; //! Save contour vertex info, vertex saved in a Vec2 + std::vector vertexList; //! Save contour vertex info, vertex saved in a Vec2 }; @@ -521,7 +521,7 @@ class CC_STUDIO_DLL TextureData : public cocos2d::Ref public: CC_CREATE_NO_PARAM(TextureData) public: - /** + /** * @js ctor */ TextureData(); @@ -537,13 +537,13 @@ public: ContourData *getContourData(int index); public: - float height; //! The texture's width, height + float height; //! The texture's width, height float width; - float pivotX; //! The texture's anchor point + float pivotX; //! The texture's anchor point float pivotY; - std::string name; //! The texture's name + std::string name; //! The texture's name cocos2d::Vector contourDataList; }; diff --git a/cocos/editor-support/cocostudio/CCDecorativeDisplay.h b/cocos/editor-support/cocostudio/CCDecorativeDisplay.h index 9a880b385f..0b89b343e4 100644 --- a/cocos/editor-support/cocostudio/CCDecorativeDisplay.h +++ b/cocos/editor-support/cocostudio/CCDecorativeDisplay.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCDisplayFactory.h b/cocos/editor-support/cocostudio/CCDisplayFactory.h index 037395bc31..adab8b5212 100644 --- a/cocos/editor-support/cocostudio/CCDisplayFactory.h +++ b/cocos/editor-support/cocostudio/CCDisplayFactory.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.h b/cocos/editor-support/cocostudio/CCDisplayManager.h index 2f7b5e0f60..777fb654cf 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.h +++ b/cocos/editor-support/cocostudio/CCDisplayManager.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -61,11 +61,11 @@ public: * If index already have a display, then replace it. * If index is current display index, then also change display to _index * - * @param displayData it include the display information, like DisplayType. - * If you want to create a sprite display, then create a SpriteDisplayData param + * @param displayData it include the display information, like DisplayType. + * If you want to create a sprite display, then create a SpriteDisplayData param * - * @param index the index of the display you want to replace or add to - * -1 : append display from back + * @param index the index of the display you want to replace or add to + * -1 : append display from back */ void addDisplay(DisplayData *displayData, int index); diff --git a/cocos/editor-support/cocostudio/CCInputDelegate.h b/cocos/editor-support/cocostudio/CCInputDelegate.h index a9f6f24a79..13dbd2df92 100644 --- a/cocos/editor-support/cocostudio/CCInputDelegate.h +++ b/cocos/editor-support/cocostudio/CCInputDelegate.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCObjectExtensionData.h b/cocos/editor-support/cocostudio/CCObjectExtensionData.h index aff8b6cb1a..7fad70f1c8 100644 --- a/cocos/editor-support/cocostudio/CCObjectExtensionData.h +++ b/cocos/editor-support/cocostudio/CCObjectExtensionData.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2015 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCProcessBase.h b/cocos/editor-support/cocostudio/CCProcessBase.h index b2acabee6b..ce0d5348e7 100644 --- a/cocos/editor-support/cocostudio/CCProcessBase.h +++ b/cocos/editor-support/cocostudio/CCProcessBase.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.h b/cocos/editor-support/cocostudio/CCSGUIReader.h index cafeae4043..b50cac9d63 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.h +++ b/cocos/editor-support/cocostudio/CCSGUIReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.h b/cocos/editor-support/cocostudio/CCSSceneReader.h index 1980b47ce0..84465641db 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.h +++ b/cocos/editor-support/cocostudio/CCSSceneReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCSkin.h b/cocos/editor-support/cocostudio/CCSkin.h index 1987eb968a..37753ab3c3 100644 --- a/cocos/editor-support/cocostudio/CCSkin.h +++ b/cocos/editor-support/cocostudio/CCSkin.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h index 43cf661dc8..adba6b087e 100644 --- a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h +++ b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -44,7 +44,7 @@ namespace cocostudio { class CC_STUDIO_DLL SpriteFrameCacheHelper { public: - /** @deprecated Use getInstance() instead */ + /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static SpriteFrameCacheHelper *sharedSpriteFrameCacheHelper(){ return SpriteFrameCacheHelper::getInstance(); } static SpriteFrameCacheHelper *getInstance(); @@ -53,7 +53,7 @@ public: public: /** - * @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name + * @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name */ void addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath); void removeSpriteFrameFromFile(const std::string& plistPath); diff --git a/cocos/editor-support/cocostudio/CCTransformHelp.h b/cocos/editor-support/cocostudio/CCTransformHelp.h index 452257fb3e..e0c9c0a086 100644 --- a/cocos/editor-support/cocostudio/CCTransformHelp.h +++ b/cocos/editor-support/cocostudio/CCTransformHelp.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCTween.h b/cocos/editor-support/cocostudio/CCTween.h index 1eeda5da47..a98ddc66bc 100644 --- a/cocos/editor-support/cocostudio/CCTween.h +++ b/cocos/editor-support/cocostudio/CCTween.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -140,7 +140,7 @@ protected: int _totalDuration; - int _fromIndex; //! The current frame index in FrameList of MovementBoneData, it's different from m_iFrameIndex + int _fromIndex; //! The current frame index in FrameList of MovementBoneData, it's different from m_iFrameIndex int _toIndex; //! The next frame index in FrameList of MovementBoneData, it's different from m_iFrameIndex ArmatureAnimation *_animation; diff --git a/cocos/editor-support/cocostudio/CCUtilMath.h b/cocos/editor-support/cocostudio/CCUtilMath.h index 46868313b5..a0ab0a5b92 100644 --- a/cocos/editor-support/cocostudio/CCUtilMath.h +++ b/cocos/editor-support/cocostudio/CCUtilMath.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CocoLoader.h b/cocos/editor-support/cocostudio/CocoLoader.h index ddee90ea02..44e34f5ac4 100644 --- a/cocos/editor-support/cocostudio/CocoLoader.h +++ b/cocos/editor-support/cocostudio/CocoLoader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CocoStudio.h b/cocos/editor-support/cocostudio/CocoStudio.h index f82c3eb09a..55c15653a4 100644 --- a/cocos/editor-support/cocostudio/CocoStudio.h +++ b/cocos/editor-support/cocostudio/CocoStudio.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CocosStudioExport.h b/cocos/editor-support/cocostudio/CocosStudioExport.h index 062566fb64..c22591f6b5 100644 --- a/cocos/editor-support/cocostudio/CocosStudioExport.h +++ b/cocos/editor-support/cocostudio/CocosStudioExport.h @@ -1,4 +1,4 @@ -#ifndef __CCCOCOSSTUDIO_H__ +#ifndef __CCCOCOSSTUDIO_H__ #define __CCCOCOSSTUDIO_H__ #if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8) diff --git a/cocos/editor-support/cocostudio/DictionaryHelper.h b/cocos/editor-support/cocostudio/DictionaryHelper.h index 2107008818..1ae1b8c588 100644 --- a/cocos/editor-support/cocostudio/DictionaryHelper.h +++ b/cocos/editor-support/cocostudio/DictionaryHelper.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/FlatBuffersSerialize.h b/cocos/editor-support/cocostudio/FlatBuffersSerialize.h index 9ea54c15b7..f4875179b9 100644 --- a/cocos/editor-support/cocostudio/FlatBuffersSerialize.h +++ b/cocos/editor-support/cocostudio/FlatBuffersSerialize.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/TriggerBase.h b/cocos/editor-support/cocostudio/TriggerBase.h index 6cce96776a..1498a098fb 100755 --- a/cocos/editor-support/cocostudio/TriggerBase.h +++ b/cocos/editor-support/cocostudio/TriggerBase.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/TriggerMng.h b/cocos/editor-support/cocostudio/TriggerMng.h index bb996cbe6d..4afb5dc4f3 100755 --- a/cocos/editor-support/cocostudio/TriggerMng.h +++ b/cocos/editor-support/cocostudio/TriggerMng.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/TriggerObj.h b/cocos/editor-support/cocostudio/TriggerObj.h index 2373786581..d52c80ee02 100755 --- a/cocos/editor-support/cocostudio/TriggerObj.h +++ b/cocos/editor-support/cocostudio/TriggerObj.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetCallBackHandlerProtocol.h b/cocos/editor-support/cocostudio/WidgetCallBackHandlerProtocol.h index 103f4341ef..94ca495cda 100755 --- a/cocos/editor-support/cocostudio/WidgetCallBackHandlerProtocol.h +++ b/cocos/editor-support/cocostudio/WidgetCallBackHandlerProtocol.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.h b/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.h index 1c0061505d..20967a5aaa 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.h b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.h index 6025e7e741..4dae566598 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.h b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.h index c6e9db2e8f..ff60ce0512 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/ComAudioReader/ComAudioReader.h b/cocos/editor-support/cocostudio/WidgetReader/ComAudioReader/ComAudioReader.h index 3296f90ca9..a3daa194e1 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ComAudioReader/ComAudioReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/ComAudioReader/ComAudioReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.h b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.h index c17227d446..55a011703a 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.h b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.h index 2539e57e5b..f76240d8d3 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.h b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.h index ba94695d8e..0cb05123c4 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.h b/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.h index a36e4ef1f4..4d4ef38d0b 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/ListViewReader/ListViewReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.h b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.h index f51256b082..da785b8de7 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.h b/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.h index b13d3307dd..948553d427 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/Node3DReader/Node3DReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.h b/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.h index a25df215cb..ee2d4c8a1c 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/NodeReader/NodeReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/NodeReaderDefine.h b/cocos/editor-support/cocostudio/WidgetReader/NodeReaderDefine.h index f2873bad69..df13c00ddb 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/NodeReaderDefine.h +++ b/cocos/editor-support/cocostudio/WidgetReader/NodeReaderDefine.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/NodeReaderProtocol.h b/cocos/editor-support/cocostudio/WidgetReader/NodeReaderProtocol.h index 7336fbbab0..c02bb3a51f 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/NodeReaderProtocol.h +++ b/cocos/editor-support/cocostudio/WidgetReader/NodeReaderProtocol.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.h b/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.h index 4801e11b03..6e78114a34 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/PageViewReader/PageViewReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.h b/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.h index 6be1e73589..3171195e76 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.h b/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.h index 435ca11877..0ca1b9d84b 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.h b/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.h index 73a3a50ca6..da240acc85 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/ProjectNodeReader/ProjectNodeReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.h b/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.h index fd91e23ea0..522e3ec087 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org @@ -44,7 +44,7 @@ namespace cocostudio static void destroyInstance(); virtual void setPropsFromJsonDictionary(cocos2d::ui::Widget* widget, const rapidjson::Value& options); - virtual void setPropsFromBinary(cocos2d::ui::Widget* widget, CocoLoader* cocoLoader, stExpCocoNode* pCocoNode) ; + virtual void setPropsFromBinary(cocos2d::ui::Widget* widget, CocoLoader* cocoLoader, stExpCocoNode* pCocoNode) ; flatbuffers::Offset createOptionsWithFlatBuffers(const tinyxml2::XMLElement* objectData, flatbuffers::FlatBufferBuilder* builder); void setPropsWithFlatBuffers(cocos2d::Node* node, const flatbuffers::Table* scrollViewOptions); diff --git a/cocos/editor-support/cocostudio/WidgetReader/SingleNodeReader/SingleNodeReader.h b/cocos/editor-support/cocostudio/WidgetReader/SingleNodeReader/SingleNodeReader.h index b8cf0dabdd..8b3d93d349 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/SingleNodeReader/SingleNodeReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/SingleNodeReader/SingleNodeReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.h b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.h index 042eac3480..042394a01f 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.h b/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.h index 1fc66e2116..b758195d7e 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/Sprite3DReader/Sprite3DReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.h b/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.h index 2882eb1d29..2e772dfc64 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.h b/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.h index 34a770b76a..c56f302d22 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.h b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.h index 4d003e203b..0d7932242b 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.h b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.h index de6e2da763..9fcd854b00 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.h b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.h index f1069bb5de..00f9208973 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/UserCameraReader/UserCameraReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h index b25d10566d..88b7b2afef 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReaderProtocol.h b/cocos/editor-support/cocostudio/WidgetReader/WidgetReaderProtocol.h index 9ffeea75c4..b266122e05 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReaderProtocol.h +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReaderProtocol.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/**************************************************************************** Copyright (c) 2014 cocos2d-x.org http://www.cocos2d-x.org diff --git a/cocos/math/CCGeometry.cpp b/cocos/math/CCGeometry.cpp index 83726a6a88..b257ab8520 100644 --- a/cocos/math/CCGeometry.cpp +++ b/cocos/math/CCGeometry.cpp @@ -107,6 +107,10 @@ Rect::Rect(float x, float y, float width, float height) { setRect(x, y, width, height); } +Rect::Rect(const Vec2& pos, const Size& dimension) +{ + setRect(pos.x, pos.y, dimension.width, dimension.height); +} Rect::Rect(const Rect& other) { diff --git a/cocos/math/CCGeometry.h b/cocos/math/CCGeometry.h index 7b421c16d4..bd928f849a 100644 --- a/cocos/math/CCGeometry.h +++ b/cocos/math/CCGeometry.h @@ -133,6 +133,11 @@ public: * @js NA */ Rect(float x, float y, float width, float height); + /** + Constructor a rect. + * @js NA + */ + Rect(const Vec2& pos, const Size& dimension); /** Copy constructor. * @js NA diff --git a/cocos/network/HttpClient-android.cpp b/cocos/network/HttpClient-android.cpp index 0eeec87b5a..8baa285112 100644 --- a/cocos/network/HttpClient-android.cpp +++ b/cocos/network/HttpClient-android.cpp @@ -92,7 +92,10 @@ public: ~HttpURLConnection() { - + if(_httpURLConnection != nullptr) + { + JniHelper::getEnv()->DeleteGlobalRef(_httpURLConnection); + } } void setRequestMethod(const char* method) diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index 5be72f1534..8b954cf62c 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -74,10 +74,10 @@ public class Cocos2dxHelper { private static Activity sActivity = null; private static Cocos2dxHelperListener sCocos2dxHelperListener; private static Set onActivityResultListeners = new LinkedHashSet(); - //Enhance API modification begin + //Enhance API modification begin private static IGameTuningService mGameServiceBinder = null; private static final int BOOST_TIME = 7; - //Enhance API modification end + //Enhance API modification end // =========================================================== // Constructors @@ -116,26 +116,26 @@ public class Cocos2dxHelper { sInited = true; //Enhance API modification begin - Intent serviceIntent = new Intent(IGameTuningService.class.getName()); - serviceIntent.setPackage("com.enhance.gameservice"); + Intent serviceIntent = new Intent(IGameTuningService.class.getName()); + serviceIntent.setPackage("com.enhance.gameservice"); boolean suc = activity.getApplicationContext().bindService(serviceIntent, connection, Context.BIND_AUTO_CREATE); //Enhance API modification end } } //Enhance API modification begin - private static ServiceConnection connection = new ServiceConnection() { - public void onServiceConnected(ComponentName name, IBinder service) { - mGameServiceBinder = IGameTuningService.Stub.asInterface(service); - fastLoading(BOOST_TIME); - } + private static ServiceConnection connection = new ServiceConnection() { + public void onServiceConnected(ComponentName name, IBinder service) { + mGameServiceBinder = IGameTuningService.Stub.asInterface(service); + fastLoading(BOOST_TIME); + } - public void onServiceDisconnected(ComponentName name) { - sActivity.getApplicationContext().unbindService(connection); - } - }; - //Enhance API modification end - + public void onServiceDisconnected(ComponentName name) { + sActivity.getApplicationContext().unbindService(connection); + } + }; + //Enhance API modification end + public static Activity getActivity() { return sActivity; } @@ -530,64 +530,64 @@ public class Cocos2dxHelper { } //Enhance API modification begin - public static int setResolutionPercent(int per) { - try { - if (mGameServiceBinder != null) { - return mGameServiceBinder.setPreferredResolution(per); - } - return -1; - } catch (Exception e) { - e.printStackTrace(); - return -1; - } - } + public static int setResolutionPercent(int per) { + try { + if (mGameServiceBinder != null) { + return mGameServiceBinder.setPreferredResolution(per); + } + return -1; + } catch (Exception e) { + e.printStackTrace(); + return -1; + } + } - public static int setFPS(int fps) { - try { - if (mGameServiceBinder != null) { - return mGameServiceBinder.setFramePerSecond(fps); - } - return -1; - } catch (Exception e) { - e.printStackTrace(); - return -1; - } - } + public static int setFPS(int fps) { + try { + if (mGameServiceBinder != null) { + return mGameServiceBinder.setFramePerSecond(fps); + } + return -1; + } catch (Exception e) { + e.printStackTrace(); + return -1; + } + } - public static int fastLoading(int sec) { - try { - if (mGameServiceBinder != null) { - return mGameServiceBinder.boostUp(sec); - } - return -1; - } catch (Exception e) { - e.printStackTrace(); - return -1; - } - } + public static int fastLoading(int sec) { + try { + if (mGameServiceBinder != null) { + return mGameServiceBinder.boostUp(sec); + } + return -1; + } catch (Exception e) { + e.printStackTrace(); + return -1; + } + } - public static int getTemperature() { - try { - if (mGameServiceBinder != null) { - return mGameServiceBinder.getAbstractTemperature(); - } - return -1; - } catch (Exception e) { - e.printStackTrace(); - return -1; - } - } + public static int getTemperature() { + try { + if (mGameServiceBinder != null) { + return mGameServiceBinder.getAbstractTemperature(); + } + return -1; + } catch (Exception e) { + e.printStackTrace(); + return -1; + } + } - public static int setLowPowerMode(boolean enable) { - try { - if (mGameServiceBinder != null) { - return mGameServiceBinder.setGamePowerSaving(enable); - } - return -1; - } catch (Exception e) { - e.printStackTrace(); - return -1; - } - } - //Enhance API modification end + public static int setLowPowerMode(boolean enable) { + try { + if (mGameServiceBinder != null) { + return mGameServiceBinder.setGamePowerSaving(enable); + } + return -1; + } catch (Exception e) { + e.printStackTrace(); + return -1; + } + } + //Enhance API modification end } diff --git a/cocos/scripting/js-bindings/CMakeLists.txt b/cocos/scripting/js-bindings/CMakeLists.txt index a233d6cf04..05b0b1ee35 100644 --- a/cocos/scripting/js-bindings/CMakeLists.txt +++ b/cocos/scripting/js-bindings/CMakeLists.txt @@ -42,7 +42,6 @@ set(JSBINDING_SRC auto/jsb_cocos2dx_ui_auto.cpp auto/jsb_cocos2dx_3d_auto.cpp auto/jsb_cocos2dx_3d_extension_auto.cpp - auto/jsb_cocos2dx_experimental.cpp auto/jsb_cocos2dx_physics3d_auto.cpp manual/ScriptingCore.cpp manual/cocos2d_specifics.cpp @@ -69,7 +68,6 @@ set(JSBINDING_SRC manual/spine/jsb_cocos2dx_spine_manual.cpp manual/ui/jsb_cocos2dx_ui_manual.cpp manual/3d/jsb_cocos2dx_3d_manual.cpp - manual/experimental/jsb_cocos2dx_experimental_manual.cpp manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp ${cocos_root}/cocos/storage/local-storage/LocalStorage.cpp ) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index ce2c4f7fe3..9897478966 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -16255,6 +16255,200 @@ ProtectedNode : function ( }; +/** + * @class Image + */ +cc.Image = { + +/** + * @method hasPremultipliedAlpha + * @return {bool} + */ +hasPremultipliedAlpha : function ( +) +{ + return false; +}, + +/** + * @method getDataLen + * @return {long} + */ +getDataLen : function ( +) +{ + return 0; +}, + +/** + * @method saveToFile + * @param {String} arg0 + * @param {bool} arg1 + * @return {bool} + */ +saveToFile : function ( +str, +bool +) +{ + return false; +}, + +/** + * @method hasAlpha + * @return {bool} + */ +hasAlpha : function ( +) +{ + return false; +}, + +/** + * @method isCompressed + * @return {bool} + */ +isCompressed : function ( +) +{ + return false; +}, + +/** + * @method getHeight + * @return {int} + */ +getHeight : function ( +) +{ + return 0; +}, + +/** + * @method initWithImageFile + * @param {String} arg0 + * @return {bool} + */ +initWithImageFile : function ( +str +) +{ + return false; +}, + +/** + * @method getWidth + * @return {int} + */ +getWidth : function ( +) +{ + return 0; +}, + +/** + * @method getBitPerPixel + * @return {int} + */ +getBitPerPixel : function ( +) +{ + return 0; +}, + +/** + * @method getFileType + * @return {cc.Image::Format} + */ +getFileType : function ( +) +{ + return 0; +}, + +/** + * @method getNumberOfMipmaps + * @return {int} + */ +getNumberOfMipmaps : function ( +) +{ + return 0; +}, + +/** + * @method getRenderFormat + * @return {cc.Texture2D::PixelFormat} + */ +getRenderFormat : function ( +) +{ + return 0; +}, + +/** + * @method getData + * @return {unsigned char} + */ +getData : function ( +) +{ + return 0; +}, + +/** + * @method getMipmaps + * @return {cc._MipmapInfo} + */ +getMipmaps : function ( +) +{ + return cc._MipmapInfo; +}, + +/** + * @method initWithRawData + * @param {unsigned char} arg0 + * @param {long} arg1 + * @param {int} arg2 + * @param {int} arg3 + * @param {int} arg4 + * @param {bool} arg5 + * @return {bool} + */ +initWithRawData : function ( +char, +long, +int, +int, +int, +bool +) +{ + return false; +}, + +/** + * @method setPVRImagesHavePremultipliedAlpha + * @param {bool} arg0 + */ +setPVRImagesHavePremultipliedAlpha : function ( +bool +) +{ +}, + +/** + * @method Image + * @constructor + */ +Image : function ( +) +{ +}, + +}; + /** * @class Sprite */ @@ -16526,6 +16720,16 @@ getTextureRect : function ( return cc.Rect; }, +/** + * @method debugDraw + * @param {bool} arg0 + */ +debugDraw : function ( +bool +) +{ +}, + /** * @method initWithFile * @param {String|String} str @@ -16602,60 +16806,6 @@ rect { }, -/** - * @method create -* @param {String|String} str -* @param {rect_object} rect -* @return {cc.Sprite|cc.Sprite|cc.Sprite} -*/ -create : function( -str, -rect -) -{ - return cc.Sprite; -}, - -/** - * @method createWithTexture -* @param {cc.Texture2D|cc.Texture2D} texture2d -* @param {rect_object} rect -* @param {bool} bool -* @return {cc.Sprite|cc.Sprite} -*/ -createWithTexture : function( -texture2d, -rect, -bool -) -{ - return cc.Sprite; -}, - -/** - * @method createWithSpriteFrameName - * @param {String} arg0 - * @return {cc.Sprite} - */ -createWithSpriteFrameName : function ( -str -) -{ - return cc.Sprite; -}, - -/** - * @method createWithSpriteFrame - * @param {cc.SpriteFrame} arg0 - * @return {cc.Sprite} - */ -createWithSpriteFrame : function ( -spriteframe -) -{ - return cc.Sprite; -}, - /** * @method Sprite * @constructor @@ -16667,200 +16817,6 @@ Sprite : function ( }; -/** - * @class Image - */ -cc.Image = { - -/** - * @method hasPremultipliedAlpha - * @return {bool} - */ -hasPremultipliedAlpha : function ( -) -{ - return false; -}, - -/** - * @method getDataLen - * @return {long} - */ -getDataLen : function ( -) -{ - return 0; -}, - -/** - * @method saveToFile - * @param {String} arg0 - * @param {bool} arg1 - * @return {bool} - */ -saveToFile : function ( -str, -bool -) -{ - return false; -}, - -/** - * @method hasAlpha - * @return {bool} - */ -hasAlpha : function ( -) -{ - return false; -}, - -/** - * @method isCompressed - * @return {bool} - */ -isCompressed : function ( -) -{ - return false; -}, - -/** - * @method getHeight - * @return {int} - */ -getHeight : function ( -) -{ - return 0; -}, - -/** - * @method initWithImageFile - * @param {String} arg0 - * @return {bool} - */ -initWithImageFile : function ( -str -) -{ - return false; -}, - -/** - * @method getWidth - * @return {int} - */ -getWidth : function ( -) -{ - return 0; -}, - -/** - * @method getBitPerPixel - * @return {int} - */ -getBitPerPixel : function ( -) -{ - return 0; -}, - -/** - * @method getFileType - * @return {cc.Image::Format} - */ -getFileType : function ( -) -{ - return 0; -}, - -/** - * @method getNumberOfMipmaps - * @return {int} - */ -getNumberOfMipmaps : function ( -) -{ - return 0; -}, - -/** - * @method getRenderFormat - * @return {cc.Texture2D::PixelFormat} - */ -getRenderFormat : function ( -) -{ - return 0; -}, - -/** - * @method getData - * @return {unsigned char} - */ -getData : function ( -) -{ - return 0; -}, - -/** - * @method getMipmaps - * @return {cc._MipmapInfo} - */ -getMipmaps : function ( -) -{ - return cc._MipmapInfo; -}, - -/** - * @method initWithRawData - * @param {unsigned char} arg0 - * @param {long} arg1 - * @param {int} arg2 - * @param {int} arg3 - * @param {int} arg4 - * @param {bool} arg5 - * @return {bool} - */ -initWithRawData : function ( -char, -long, -int, -int, -int, -bool -) -{ - return false; -}, - -/** - * @method setPVRImagesHavePremultipliedAlpha - * @param {bool} arg0 - */ -setPVRImagesHavePremultipliedAlpha : function ( -bool -) -{ -}, - -/** - * @method Image - * @constructor - */ -Image : function ( -) -{ -}, - -}; - /** * @class RenderTexture */ @@ -22651,72 +22607,3 @@ getInstance : function ( }, }; - -/** - * @class SpritePolygonCache - */ -cc.SpritePolygonCache = { - -/** - * @method isSpritePolygonCachExist - * @param {String} arg0 - * @param {rect_object} arg1 - * @return {bool} - */ -isSpritePolygonCachExist : function ( -str, -rect -) -{ - return false; -}, - -/** - * @method removeAllSpritePolygonCache - */ -removeAllSpritePolygonCache : function ( -) -{ -}, - -/** - * @method removeSpritePolygonCache - * @param {String} arg0 - * @param {rect_object} arg1 - */ -removeSpritePolygonCache : function ( -str, -rect -) -{ -}, - -/** - * @method destroyInstance - */ -destroyInstance : function ( -) -{ -}, - -/** - * @method printInfo - * @param {cc._SpritePolygonInfo} arg0 - */ -printInfo : function ( -_spritepolygoninfo -) -{ -}, - -/** - * @method getInstance - * @return {cc.SpritePolygonCache} - */ -getInstance : function ( -) -{ - return cc.SpritePolygonCache; -}, - -}; diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_experimental_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_experimental_api.js deleted file mode 100644 index 5ea1dd93d7..0000000000 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_experimental_api.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @module cocos2dx_experimental - */ -var ccexp = ccexp || {}; - -/** - * @class SpritePolygon - */ -ccexp.SpritePolygon = { - -/** - * @method setTexture -* @param {cc.Texture2D|String} texture2d -*/ -setTexture : function( -str -) -{ -}, - -/** - * @method initWithTexture - * @param {cc.Texture2D} arg0 - * @return {bool} - */ -initWithTexture : function ( -texture2d -) -{ - return false; -}, - -/** - * @method showDebug - * @param {bool} arg0 - */ -showDebug : function ( -bool -) -{ -}, - -/** - * @method getTexture - * @return {cc.Texture2D} - */ -getTexture : function ( -) -{ - return cc.Texture2D; -}, - -/** - * @method getArea - * @return {float} - */ -getArea : function ( -) -{ - return 0; -}, - -/** - * @method initWithMarching - * @param {String} arg0 - * @param {rect_object} arg1 - * @param {float} arg2 - * @return {bool} - */ -initWithMarching : function ( -str, -rect, -float -) -{ - return false; -}, - -/** - * @method getVertCount - * @return {long} - */ -getVertCount : function ( -) -{ - return 0; -}, - -/** - * @method getTrianglesCount - * @return {long} - */ -getTrianglesCount : function ( -) -{ - return 0; -}, - -}; diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index ac91701dc4..13ac0994ad 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -4,7 +4,6 @@ #include "SimpleAudioEngine.h" #include "CCProtectedNode.h" #include "CCAsyncTaskPool.h" -#include "SpritePolygonCache.h" template static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { @@ -49567,6 +49566,454 @@ void js_register_cocos2dx_ProtectedNode(JSContext *cx, JS::HandleObject global) } } +JSClass *jsb_cocos2d_Image_class; +JSObject *jsb_cocos2d_Image_prototype; + +bool js_cocos2dx_Image_hasPremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_hasPremultipliedAlpha : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->hasPremultipliedAlpha(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_hasPremultipliedAlpha : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getDataLen(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getDataLen : Invalid Native Object"); + if (argc == 0) { + ssize_t ret = cobj->getDataLen(); + jsval jsret = JSVAL_NULL; + jsret = ssize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getDataLen : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_saveToFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_saveToFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_saveToFile : Error processing arguments"); + bool ret = cobj->saveToFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + bool arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + arg1 = JS::ToBoolean(args.get(1)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_saveToFile : Error processing arguments"); + bool ret = cobj->saveToFile(arg0, arg1); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_saveToFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Image_hasAlpha(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_hasAlpha : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->hasAlpha(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_hasAlpha : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_isCompressed(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_isCompressed : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isCompressed(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_isCompressed : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getHeight(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getHeight : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getHeight(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getHeight : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_initWithImageFile(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_initWithImageFile : Invalid Native Object"); + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_initWithImageFile : Error processing arguments"); + bool ret = cobj->initWithImageFile(arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_initWithImageFile : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} +bool js_cocos2dx_Image_getWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getWidth : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getWidth(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getWidth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getBitPerPixel(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getBitPerPixel : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getBitPerPixel(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getBitPerPixel : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getFileType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getFileType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getFileType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getFileType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getNumberOfMipmaps(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getNumberOfMipmaps : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getNumberOfMipmaps(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getNumberOfMipmaps : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getRenderFormat(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getRenderFormat : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getRenderFormat(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getRenderFormat : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getData : Invalid Native Object"); + if (argc == 0) { + unsigned char* ret = cobj->getData(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR unsigned char*; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getData : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_getMipmaps(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getMipmaps : Invalid Native Object"); + if (argc == 0) { + cocos2d::_MipmapInfo* ret = cobj->getMipmaps(); + jsval jsret = JSVAL_NULL; + #pragma warning NO CONVERSION FROM NATIVE FOR _MipmapInfo*; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_getMipmaps : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Image_initWithRawData(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_initWithRawData : Invalid Native Object"); + if (argc == 5) { + const unsigned char* arg0; + ssize_t arg1; + int arg2; + int arg3; + int arg4; + #pragma warning NO CONVERSION TO NATIVE FOR unsigned char* + ok = false; + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_initWithRawData : Error processing arguments"); + bool ret = cobj->initWithRawData(arg0, arg1, arg2, arg3, arg4); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + if (argc == 6) { + const unsigned char* arg0; + ssize_t arg1; + int arg2; + int arg3; + int arg4; + bool arg5; + #pragma warning NO CONVERSION TO NATIVE FOR unsigned char* + ok = false; + ok &= jsval_to_ssize(cx, args.get(1), &arg1); + ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); + ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); + ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); + arg5 = JS::ToBoolean(args.get(5)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_initWithRawData : Error processing arguments"); + bool ret = cobj->initWithRawData(arg0, arg1, arg2, arg3, arg4, arg5); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Image_initWithRawData : wrong number of arguments: %d, was expecting %d", argc, 5); + return false; +} +bool js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha : Error processing arguments"); + cocos2d::Image::setPVRImagesHavePremultipliedAlpha(arg0); + args.rval().setUndefined(); + return true; + } + JS_ReportError(cx, "js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Image_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::Image* cobj = new (std::nothrow) cocos2d::Image(); + cocos2d::Ref *_ccobj = dynamic_cast(cobj); + if (_ccobj) { + _ccobj->autorelease(); + } + TypeTest t; + js_type_class_t *typeClass = nullptr; + std::string typeName = t.s_name(); + auto typeMapIter = _js_global_type_map.find(typeName); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + js_proxy_t* p = jsb_new_proxy(cobj, obj); + AddNamedObjectRoot(cx, &p->obj, "cocos2d::Image"); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + + + +void js_cocos2d_Image_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (Image)", obj); +} + +void js_register_cocos2dx_Image(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_Image_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_Image_class->name = "Image"; + jsb_cocos2d_Image_class->addProperty = JS_PropertyStub; + jsb_cocos2d_Image_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_Image_class->getProperty = JS_PropertyStub; + jsb_cocos2d_Image_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_Image_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_Image_class->resolve = JS_ResolveStub; + jsb_cocos2d_Image_class->convert = JS_ConvertStub; + jsb_cocos2d_Image_class->finalize = js_cocos2d_Image_finalize; + jsb_cocos2d_Image_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FN("hasPremultipliedAlpha", js_cocos2dx_Image_hasPremultipliedAlpha, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getDataLen", js_cocos2dx_Image_getDataLen, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("saveToFile", js_cocos2dx_Image_saveToFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("hasAlpha", js_cocos2dx_Image_hasAlpha, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isCompressed", js_cocos2dx_Image_isCompressed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getHeight", js_cocos2dx_Image_getHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithImageFile", js_cocos2dx_Image_initWithImageFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getWidth", js_cocos2dx_Image_getWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getBitPerPixel", js_cocos2dx_Image_getBitPerPixel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getFileType", js_cocos2dx_Image_getFileType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getNumberOfMipmaps", js_cocos2dx_Image_getNumberOfMipmaps, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRenderFormat", js_cocos2dx_Image_getRenderFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getData", js_cocos2dx_Image_getData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getMipmaps", js_cocos2dx_Image_getMipmaps, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithRawData", js_cocos2dx_Image_initWithRawData, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("setPVRImagesHavePremultipliedAlpha", js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_Image_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_Image_class, + js_cocos2dx_Image_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace +// bool found; +//FIXME: Removed in Firefox v27 +// JS_SetPropertyAttributes(cx, global, "Image", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_Image_class; + p->proto = jsb_cocos2d_Image_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + JSClass *jsb_cocos2d_Sprite_class; JSObject *jsb_cocos2d_Sprite_prototype; @@ -50237,6 +50684,26 @@ bool js_cocos2dx_Sprite_getTextureRect(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Sprite_getTextureRect : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Sprite_debugDraw(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_debugDraw : Invalid Native Object"); + if (argc == 1) { + bool arg0; + arg0 = JS::ToBoolean(args.get(0)); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_debugDraw : Error processing arguments"); + cobj->debugDraw(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_debugDraw : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -50411,230 +50878,6 @@ bool js_cocos2dx_Sprite_setVertexRect(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Sprite_setVertexRect : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Sprite_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - - do { - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - if (!ok) { ok = true; break; } - cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - } while (0); - - do { - if (argc == 0) { - cocos2d::Sprite* ret = cocos2d::Sprite::create(); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - } while (0); - - do { - if (argc == 2) { - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, args.get(1), &arg1); - if (!ok) { ok = true; break; } - cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0, arg1); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - } while (0); - JS_ReportError(cx, "js_cocos2dx_Sprite_create : wrong number of arguments"); - return false; -} -bool js_cocos2dx_Sprite_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - - do { - if (argc == 2) { - cocos2d::Texture2D* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, args.get(1), &arg1); - if (!ok) { ok = true; break; } - cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - } while (0); - do { - if (argc == 3) { - cocos2d::Texture2D* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocos2d::Rect arg1; - ok &= jsval_to_ccrect(cx, args.get(1), &arg1); - if (!ok) { ok = true; break; } - bool arg2; - arg2 = JS::ToBoolean(args.get(2)); - if (!ok) { ok = true; break; } - cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1, arg2); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - } while (0); - - do { - if (argc == 1) { - cocos2d::Texture2D* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - } while (0); - JS_ReportError(cx, "js_cocos2dx_Sprite_createWithTexture : wrong number of arguments"); - return false; -} -bool js_cocos2dx_Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_createWithSpriteFrameName : Error processing arguments"); - cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrameName(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - JS_ReportError(cx, "js_cocos2dx_Sprite_createWithSpriteFrameName : wrong number of arguments"); - return false; -} - -bool js_cocos2dx_Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - if (argc == 1) { - cocos2d::SpriteFrame* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::SpriteFrame*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_createWithSpriteFrame : Error processing arguments"); - cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrame(arg0); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - JS_ReportError(cx, "js_cocos2dx_Sprite_createWithSpriteFrame : wrong number of arguments"); - return false; -} - bool js_cocos2dx_Sprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -50731,6 +50974,7 @@ void js_register_cocos2dx_Sprite(JSContext *cx, JS::HandleObject global) { JS_FN("setDirty", js_cocos2dx_Sprite_setDirty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTextureRectRotated", js_cocos2dx_Sprite_isTextureRectRotated, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureRect", js_cocos2dx_Sprite_getTextureRect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("debugDraw", js_cocos2dx_Sprite_debugDraw, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithFile", js_cocos2dx_Sprite_initWithFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBlendFunc", js_cocos2dx_Sprite_setBlendFunc, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureAtlas", js_cocos2dx_Sprite_getTextureAtlas, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -50742,13 +50986,7 @@ void js_register_cocos2dx_Sprite(JSContext *cx, JS::HandleObject global) { JS_FS_END }; - static JSFunctionSpec st_funcs[] = { - JS_FN("create", js_cocos2dx_Sprite_create, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("createWithTexture", js_cocos2dx_Sprite_createWithTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("createWithSpriteFrameName", js_cocos2dx_Sprite_createWithSpriteFrameName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("createWithSpriteFrame", js_cocos2dx_Sprite_createWithSpriteFrame, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; + JSFunctionSpec *st_funcs = NULL; jsb_cocos2d_Sprite_prototype = JS_InitClass( cx, global, @@ -50778,454 +51016,6 @@ void js_register_cocos2dx_Sprite(JSContext *cx, JS::HandleObject global) { } } -JSClass *jsb_cocos2d_Image_class; -JSObject *jsb_cocos2d_Image_prototype; - -bool js_cocos2dx_Image_hasPremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_hasPremultipliedAlpha : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->hasPremultipliedAlpha(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_hasPremultipliedAlpha : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_getDataLen(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getDataLen : Invalid Native Object"); - if (argc == 0) { - ssize_t ret = cobj->getDataLen(); - jsval jsret = JSVAL_NULL; - jsret = ssize_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_getDataLen : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_saveToFile(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_saveToFile : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_saveToFile : Error processing arguments"); - bool ret = cobj->saveToFile(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - if (argc == 2) { - std::string arg0; - bool arg1; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - arg1 = JS::ToBoolean(args.get(1)); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_saveToFile : Error processing arguments"); - bool ret = cobj->saveToFile(arg0, arg1); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_saveToFile : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_Image_hasAlpha(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_hasAlpha : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->hasAlpha(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_hasAlpha : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_isCompressed(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_isCompressed : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isCompressed(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_isCompressed : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_getHeight(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getHeight : Invalid Native Object"); - if (argc == 0) { - int ret = cobj->getHeight(); - jsval jsret = JSVAL_NULL; - jsret = int32_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_getHeight : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_initWithImageFile(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_initWithImageFile : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_initWithImageFile : Error processing arguments"); - bool ret = cobj->initWithImageFile(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_initWithImageFile : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_Image_getWidth(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getWidth : Invalid Native Object"); - if (argc == 0) { - int ret = cobj->getWidth(); - jsval jsret = JSVAL_NULL; - jsret = int32_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_getWidth : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_getBitPerPixel(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getBitPerPixel : Invalid Native Object"); - if (argc == 0) { - int ret = cobj->getBitPerPixel(); - jsval jsret = JSVAL_NULL; - jsret = int32_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_getBitPerPixel : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_getFileType(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getFileType : Invalid Native Object"); - if (argc == 0) { - int ret = (int)cobj->getFileType(); - jsval jsret = JSVAL_NULL; - jsret = int32_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_getFileType : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_getNumberOfMipmaps(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getNumberOfMipmaps : Invalid Native Object"); - if (argc == 0) { - int ret = cobj->getNumberOfMipmaps(); - jsval jsret = JSVAL_NULL; - jsret = int32_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_getNumberOfMipmaps : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_getRenderFormat(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getRenderFormat : Invalid Native Object"); - if (argc == 0) { - int ret = (int)cobj->getRenderFormat(); - jsval jsret = JSVAL_NULL; - jsret = int32_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_getRenderFormat : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_getData(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getData : Invalid Native Object"); - if (argc == 0) { - unsigned char* ret = cobj->getData(); - jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR unsigned char*; - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_getData : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_getMipmaps(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_getMipmaps : Invalid Native Object"); - if (argc == 0) { - cocos2d::_MipmapInfo* ret = cobj->getMipmaps(); - jsval jsret = JSVAL_NULL; - #pragma warning NO CONVERSION FROM NATIVE FOR _MipmapInfo*; - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_getMipmaps : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_Image_initWithRawData(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Image* cobj = (cocos2d::Image *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Image_initWithRawData : Invalid Native Object"); - if (argc == 5) { - const unsigned char* arg0; - ssize_t arg1; - int arg2; - int arg3; - int arg4; - #pragma warning NO CONVERSION TO NATIVE FOR unsigned char* - ok = false; - ok &= jsval_to_ssize(cx, args.get(1), &arg1); - ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); - ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); - ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_initWithRawData : Error processing arguments"); - bool ret = cobj->initWithRawData(arg0, arg1, arg2, arg3, arg4); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - if (argc == 6) { - const unsigned char* arg0; - ssize_t arg1; - int arg2; - int arg3; - int arg4; - bool arg5; - #pragma warning NO CONVERSION TO NATIVE FOR unsigned char* - ok = false; - ok &= jsval_to_ssize(cx, args.get(1), &arg1); - ok &= jsval_to_int32(cx, args.get(2), (int32_t *)&arg2); - ok &= jsval_to_int32(cx, args.get(3), (int32_t *)&arg3); - ok &= jsval_to_int32(cx, args.get(4), (int32_t *)&arg4); - arg5 = JS::ToBoolean(args.get(5)); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_initWithRawData : Error processing arguments"); - bool ret = cobj->initWithRawData(arg0, arg1, arg2, arg3, arg4, arg5); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Image_initWithRawData : wrong number of arguments: %d, was expecting %d", argc, 5); - return false; -} -bool js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(args.get(0)); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha : Error processing arguments"); - cocos2d::Image::setPVRImagesHavePremultipliedAlpha(arg0); - args.rval().setUndefined(); - return true; - } - JS_ReportError(cx, "js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha : wrong number of arguments"); - return false; -} - -bool js_cocos2dx_Image_constructor(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - cocos2d::Image* cobj = new (std::nothrow) cocos2d::Image(); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); - JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); - args.rval().set(OBJECT_TO_JSVAL(obj)); - // link the native object with the javascript object - js_proxy_t* p = jsb_new_proxy(cobj, obj); - AddNamedObjectRoot(cx, &p->obj, "cocos2d::Image"); - if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); - return true; -} - - - -void js_cocos2d_Image_finalize(JSFreeOp *fop, JSObject *obj) { - CCLOGINFO("jsbindings: finalizing JS object %p (Image)", obj); -} - -void js_register_cocos2dx_Image(JSContext *cx, JS::HandleObject global) { - jsb_cocos2d_Image_class = (JSClass *)calloc(1, sizeof(JSClass)); - jsb_cocos2d_Image_class->name = "Image"; - jsb_cocos2d_Image_class->addProperty = JS_PropertyStub; - jsb_cocos2d_Image_class->delProperty = JS_DeletePropertyStub; - jsb_cocos2d_Image_class->getProperty = JS_PropertyStub; - jsb_cocos2d_Image_class->setProperty = JS_StrictPropertyStub; - jsb_cocos2d_Image_class->enumerate = JS_EnumerateStub; - jsb_cocos2d_Image_class->resolve = JS_ResolveStub; - jsb_cocos2d_Image_class->convert = JS_ConvertStub; - jsb_cocos2d_Image_class->finalize = js_cocos2d_Image_finalize; - jsb_cocos2d_Image_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); - - static JSPropertySpec properties[] = { - JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_PS_END - }; - - static JSFunctionSpec funcs[] = { - JS_FN("hasPremultipliedAlpha", js_cocos2dx_Image_hasPremultipliedAlpha, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getDataLen", js_cocos2dx_Image_getDataLen, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("saveToFile", js_cocos2dx_Image_saveToFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("hasAlpha", js_cocos2dx_Image_hasAlpha, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isCompressed", js_cocos2dx_Image_isCompressed, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getHeight", js_cocos2dx_Image_getHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("initWithImageFile", js_cocos2dx_Image_initWithImageFile, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getWidth", js_cocos2dx_Image_getWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getBitPerPixel", js_cocos2dx_Image_getBitPerPixel, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getFileType", js_cocos2dx_Image_getFileType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getNumberOfMipmaps", js_cocos2dx_Image_getNumberOfMipmaps, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getRenderFormat", js_cocos2dx_Image_getRenderFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getData", js_cocos2dx_Image_getData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getMipmaps", js_cocos2dx_Image_getMipmaps, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("initWithRawData", js_cocos2dx_Image_initWithRawData, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - static JSFunctionSpec st_funcs[] = { - JS_FN("setPVRImagesHavePremultipliedAlpha", js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - jsb_cocos2d_Image_prototype = JS_InitClass( - cx, global, - JS::NullPtr(), // parent proto - jsb_cocos2d_Image_class, - js_cocos2dx_Image_constructor, 0, // constructor - properties, - funcs, - NULL, // no static properties - st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "Image", JSPROP_ENUMERATE | JSPROP_READONLY, &found); - - // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_Image_class; - p->proto = jsb_cocos2d_Image_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } -} - JSClass *jsb_cocos2d_RenderTexture_class; JSObject *jsb_cocos2d_RenderTexture_prototype; @@ -69015,203 +68805,6 @@ void js_register_cocos2dx_SimpleAudioEngine(JSContext *cx, JS::HandleObject glob } } -JSClass *jsb_cocos2d_SpritePolygonCache_class; -JSObject *jsb_cocos2d_SpritePolygonCache_prototype; - -bool js_cocos2dx_SpritePolygonCache_isSpritePolygonCachExist(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::SpritePolygonCache* cobj = (cocos2d::SpritePolygonCache *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpritePolygonCache_isSpritePolygonCachExist : Invalid Native Object"); - if (argc == 2) { - std::string arg0; - cocos2d::Rect arg1; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - ok &= jsval_to_ccrect(cx, args.get(1), &arg1); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpritePolygonCache_isSpritePolygonCachExist : Error processing arguments"); - bool ret = cobj->isSpritePolygonCachExist(arg0, arg1); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_SpritePolygonCache_isSpritePolygonCachExist : wrong number of arguments: %d, was expecting %d", argc, 2); - return false; -} -bool js_cocos2dx_SpritePolygonCache_removeAllSpritePolygonCache(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::SpritePolygonCache* cobj = (cocos2d::SpritePolygonCache *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpritePolygonCache_removeAllSpritePolygonCache : Invalid Native Object"); - if (argc == 0) { - cobj->removeAllSpritePolygonCache(); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_SpritePolygonCache_removeAllSpritePolygonCache : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_SpritePolygonCache_removeSpritePolygonCache(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::SpritePolygonCache* cobj = (cocos2d::SpritePolygonCache *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_SpritePolygonCache_removeSpritePolygonCache : Invalid Native Object"); - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpritePolygonCache_removeSpritePolygonCache : Error processing arguments"); - cobj->removeSpritePolygonCache(arg0); - args.rval().setUndefined(); - return true; - } - if (argc == 2) { - std::string arg0; - const cocos2d::Rect* arg1; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - do { - if (args.get(1).isNull()) { arg1 = nullptr; break; } - if (!args.get(1).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(1).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg1 = (const cocos2d::Rect*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpritePolygonCache_removeSpritePolygonCache : Error processing arguments"); - cobj->removeSpritePolygonCache(arg0, arg1); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_SpritePolygonCache_removeSpritePolygonCache : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_SpritePolygonCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - if (argc == 0) { - cocos2d::SpritePolygonCache::destroyInstance(); - args.rval().setUndefined(); - return true; - } - JS_ReportError(cx, "js_cocos2dx_SpritePolygonCache_destroyInstance : wrong number of arguments"); - return false; -} - -bool js_cocos2dx_SpritePolygonCache_printInfo(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - if (argc == 1) { - cocos2d::_SpritePolygonInfo arg0; - #pragma warning NO CONVERSION TO NATIVE FOR _SpritePolygonInfo - ok = false; - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpritePolygonCache_printInfo : Error processing arguments"); - cocos2d::SpritePolygonCache::printInfo(arg0); - args.rval().setUndefined(); - return true; - } - JS_ReportError(cx, "js_cocos2dx_SpritePolygonCache_printInfo : wrong number of arguments"); - return false; -} - -bool js_cocos2dx_SpritePolygonCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - if (argc == 0) { - cocos2d::SpritePolygonCache* ret = cocos2d::SpritePolygonCache::getInstance(); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::SpritePolygonCache*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - JS_ReportError(cx, "js_cocos2dx_SpritePolygonCache_getInstance : wrong number of arguments"); - return false; -} - - - -void js_cocos2d_SpritePolygonCache_finalize(JSFreeOp *fop, JSObject *obj) { - CCLOGINFO("jsbindings: finalizing JS object %p (SpritePolygonCache)", obj); -} - -void js_register_cocos2dx_SpritePolygonCache(JSContext *cx, JS::HandleObject global) { - jsb_cocos2d_SpritePolygonCache_class = (JSClass *)calloc(1, sizeof(JSClass)); - jsb_cocos2d_SpritePolygonCache_class->name = "SpritePolygonCache"; - jsb_cocos2d_SpritePolygonCache_class->addProperty = JS_PropertyStub; - jsb_cocos2d_SpritePolygonCache_class->delProperty = JS_DeletePropertyStub; - jsb_cocos2d_SpritePolygonCache_class->getProperty = JS_PropertyStub; - jsb_cocos2d_SpritePolygonCache_class->setProperty = JS_StrictPropertyStub; - jsb_cocos2d_SpritePolygonCache_class->enumerate = JS_EnumerateStub; - jsb_cocos2d_SpritePolygonCache_class->resolve = JS_ResolveStub; - jsb_cocos2d_SpritePolygonCache_class->convert = JS_ConvertStub; - jsb_cocos2d_SpritePolygonCache_class->finalize = js_cocos2d_SpritePolygonCache_finalize; - jsb_cocos2d_SpritePolygonCache_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); - - static JSPropertySpec properties[] = { - JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_PS_END - }; - - static JSFunctionSpec funcs[] = { - JS_FN("isSpritePolygonCachExist", js_cocos2dx_SpritePolygonCache_isSpritePolygonCachExist, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeAllSpritePolygonCache", js_cocos2dx_SpritePolygonCache_removeAllSpritePolygonCache, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("removeSpritePolygonCache", js_cocos2dx_SpritePolygonCache_removeSpritePolygonCache, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - static JSFunctionSpec st_funcs[] = { - JS_FN("destroyInstance", js_cocos2dx_SpritePolygonCache_destroyInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("printInfo", js_cocos2dx_SpritePolygonCache_printInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getInstance", js_cocos2dx_SpritePolygonCache_getInstance, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - jsb_cocos2d_SpritePolygonCache_prototype = JS_InitClass( - cx, global, - JS::NullPtr(), // parent proto - jsb_cocos2d_SpritePolygonCache_class, - empty_constructor, 0, - properties, - funcs, - NULL, // no static properties - st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SpritePolygonCache", JSPROP_ENUMERATE | JSPROP_READONLY, &found); - - // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_SpritePolygonCache_class; - p->proto = jsb_cocos2d_SpritePolygonCache_prototype; - p->parentProto = NULL; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } -} - void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj) { // Get the ns JS::RootedObject ns(cx); @@ -69414,7 +69007,6 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj) { js_register_cocos2dx_TransitionSlideInL(cx, ns); js_register_cocos2dx_TransitionSlideInT(cx, ns); js_register_cocos2dx_Grid3D(cx, ns); - js_register_cocos2dx_SpritePolygonCache(cx, ns); js_register_cocos2dx_EaseCircleActionOut(cx, ns); js_register_cocos2dx_TransitionProgressInOut(cx, ns); js_register_cocos2dx_EaseCubicActionInOut(cx, ns); diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index d0ab4c9e94..dea55ec6d1 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -2861,6 +2861,31 @@ bool js_cocos2dx_ProtectedNode_removeAllProtectedChildren(JSContext *cx, uint32_ bool js_cocos2dx_ProtectedNode_create(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ProtectedNode_ProtectedNode(JSContext *cx, uint32_t argc, jsval *vp); +extern JSClass *jsb_cocos2d_Image_class; +extern JSObject *jsb_cocos2d_Image_prototype; + +bool js_cocos2dx_Image_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_cocos2dx_Image_finalize(JSContext *cx, JSObject *obj); +void js_register_cocos2dx_Image(JSContext *cx, JS::HandleObject global); +void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); +bool js_cocos2dx_Image_hasPremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getDataLen(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_saveToFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_hasAlpha(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_isCompressed(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_initWithImageFile(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getBitPerPixel(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getFileType(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getNumberOfMipmaps(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getRenderFormat(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_getMipmaps(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_initWithRawData(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Image_Image(JSContext *cx, uint32_t argc, jsval *vp); + extern JSClass *jsb_cocos2d_Sprite_class; extern JSObject *jsb_cocos2d_Sprite_prototype; @@ -2893,6 +2918,7 @@ bool js_cocos2dx_Sprite_setAtlasIndex(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Sprite_setDirty(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Sprite_isTextureRectRotated(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Sprite_getTextureRect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Sprite_debugDraw(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Sprite_initWithFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Sprite_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Sprite_getTextureAtlas(JSContext *cx, uint32_t argc, jsval *vp); @@ -2900,37 +2926,8 @@ bool js_cocos2dx_Sprite_initWithSpriteFrame(JSContext *cx, uint32_t argc, jsval bool js_cocos2dx_Sprite_isFlippedX(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Sprite_isFlippedY(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Sprite_setVertexRect(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Sprite_create(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Sprite_createWithTexture(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Sprite_createWithSpriteFrameName(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Sprite_createWithSpriteFrame(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Sprite_Sprite(JSContext *cx, uint32_t argc, jsval *vp); -extern JSClass *jsb_cocos2d_Image_class; -extern JSObject *jsb_cocos2d_Image_prototype; - -bool js_cocos2dx_Image_constructor(JSContext *cx, uint32_t argc, jsval *vp); -void js_cocos2dx_Image_finalize(JSContext *cx, JSObject *obj); -void js_register_cocos2dx_Image(JSContext *cx, JS::HandleObject global); -void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_Image_hasPremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_getDataLen(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_saveToFile(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_hasAlpha(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_isCompressed(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_getHeight(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_initWithImageFile(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_getWidth(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_getBitPerPixel(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_getFileType(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_getNumberOfMipmaps(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_getRenderFormat(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_getData(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_getMipmaps(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_initWithRawData(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Image_Image(JSContext *cx, uint32_t argc, jsval *vp); - extern JSClass *jsb_cocos2d_RenderTexture_class; extern JSObject *jsb_cocos2d_RenderTexture_prototype; @@ -3983,18 +3980,4 @@ bool js_cocos2dx_SimpleAudioEngine_resumeEffect(JSContext *cx, uint32_t argc, js bool js_cocos2dx_SimpleAudioEngine_end(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_SimpleAudioEngine_getInstance(JSContext *cx, uint32_t argc, jsval *vp); -extern JSClass *jsb_cocos2d_SpritePolygonCache_class; -extern JSObject *jsb_cocos2d_SpritePolygonCache_prototype; - -bool js_cocos2dx_SpritePolygonCache_constructor(JSContext *cx, uint32_t argc, jsval *vp); -void js_cocos2dx_SpritePolygonCache_finalize(JSContext *cx, JSObject *obj); -void js_register_cocos2dx_SpritePolygonCache(JSContext *cx, JS::HandleObject global); -void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_SpritePolygonCache_isSpritePolygonCachExist(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_SpritePolygonCache_removeAllSpritePolygonCache(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_SpritePolygonCache_removeSpritePolygonCache(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_SpritePolygonCache_destroyInstance(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_SpritePolygonCache_printInfo(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_SpritePolygonCache_getInstance(JSContext *cx, uint32_t argc, jsval *vp); - #endif // __cocos2dx_h__ diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental.cpp deleted file mode 100644 index 57802ed4b0..0000000000 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental.cpp +++ /dev/null @@ -1,320 +0,0 @@ -#include "jsb_cocos2dx_experimental.hpp" -#include "cocos2d_specifics.hpp" -#include "SpritePolygon.h" - -template -static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedValue initializing(cx); - bool isNewValid = true; - JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); - isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); - if (isNewValid) - { - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - - JS::RootedObject proto(cx, typeClass->proto.get()); - JS::RootedObject parent(cx, typeClass->parentProto.get()); - JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); - - args.rval().set(OBJECT_TO_JSVAL(_tmp)); - return true; - } - - JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); - return false; -} - -static bool empty_constructor(JSContext *cx, uint32_t argc, jsval *vp) { - return false; -} - -static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - args.rval().setBoolean(true); - return true; -} -JSClass *jsb_cocos2d_experimental_SpritePolygon_class; -JSObject *jsb_cocos2d_experimental_SpritePolygon_prototype; - -bool js_cocos2dx_experimental_SpritePolygon_setTexture(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - - JS::RootedObject obj(cx); - cocos2d::experimental::SpritePolygon* cobj = NULL; - obj = args.thisv().toObjectOrNull(); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cobj = (cocos2d::experimental::SpritePolygon *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_SpritePolygon_setTexture : Invalid Native Object"); - do { - if (argc == 1) { - cocos2d::Texture2D* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - if (!ok) { ok = true; break; } - cobj->setTexture(arg0); - args.rval().setUndefined(); - return true; - } - } while(0); - - do { - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - if (!ok) { ok = true; break; } - cobj->setTexture(arg0); - args.rval().setUndefined(); - return true; - } - } while(0); - - JS_ReportError(cx, "js_cocos2dx_experimental_SpritePolygon_setTexture : wrong number of arguments"); - return false; -} -bool js_cocos2dx_experimental_SpritePolygon_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::experimental::SpritePolygon* cobj = (cocos2d::experimental::SpritePolygon *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_SpritePolygon_initWithTexture : Invalid Native Object"); - if (argc == 1) { - cocos2d::Texture2D* arg0; - do { - if (args.get(0).isNull()) { arg0 = nullptr; break; } - if (!args.get(0).isObject()) { ok = false; break; } - js_proxy_t *jsProxy; - JSObject *tmpObj = args.get(0).toObjectOrNull(); - jsProxy = jsb_get_js_proxy(tmpObj); - arg0 = (cocos2d::Texture2D*)(jsProxy ? jsProxy->ptr : NULL); - JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); - } while (0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_experimental_SpritePolygon_initWithTexture : Error processing arguments"); - bool ret = cobj->initWithTexture(arg0); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_experimental_SpritePolygon_initWithTexture : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_experimental_SpritePolygon_showDebug(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::experimental::SpritePolygon* cobj = (cocos2d::experimental::SpritePolygon *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_SpritePolygon_showDebug : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(args.get(0)); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_experimental_SpritePolygon_showDebug : Error processing arguments"); - cobj->showDebug(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_experimental_SpritePolygon_showDebug : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} -bool js_cocos2dx_experimental_SpritePolygon_getTexture(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::experimental::SpritePolygon* cobj = (cocos2d::experimental::SpritePolygon *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_SpritePolygon_getTexture : Invalid Native Object"); - if (argc == 0) { - cocos2d::Texture2D* ret = cobj->getTexture(); - jsval jsret = JSVAL_NULL; - do { - if (ret) { - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Texture2D*)ret); - jsret = OBJECT_TO_JSVAL(jsProxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_experimental_SpritePolygon_getTexture : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_experimental_SpritePolygon_getArea(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::experimental::SpritePolygon* cobj = (cocos2d::experimental::SpritePolygon *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_SpritePolygon_getArea : Invalid Native Object"); - if (argc == 0) { - const float ret = cobj->getArea(); - jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_experimental_SpritePolygon_getArea : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_experimental_SpritePolygon_initWithMarching(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::experimental::SpritePolygon* cobj = (cocos2d::experimental::SpritePolygon *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_SpritePolygon_initWithMarching : Invalid Native Object"); - if (argc == 3) { - std::string arg0; - cocos2d::Rect arg1; - double arg2; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - ok &= jsval_to_ccrect(cx, args.get(1), &arg1); - ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_experimental_SpritePolygon_initWithMarching : Error processing arguments"); - bool ret = cobj->initWithMarching(arg0, arg1, arg2); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_experimental_SpritePolygon_initWithMarching : wrong number of arguments: %d, was expecting %d", argc, 3); - return false; -} -bool js_cocos2dx_experimental_SpritePolygon_getVertCount(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::experimental::SpritePolygon* cobj = (cocos2d::experimental::SpritePolygon *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_SpritePolygon_getVertCount : Invalid Native Object"); - if (argc == 0) { - const ssize_t ret = cobj->getVertCount(); - jsval jsret = JSVAL_NULL; - jsret = ssize_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_experimental_SpritePolygon_getVertCount : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} -bool js_cocos2dx_experimental_SpritePolygon_getTrianglesCount(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::experimental::SpritePolygon* cobj = (cocos2d::experimental::SpritePolygon *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_experimental_SpritePolygon_getTrianglesCount : Invalid Native Object"); - if (argc == 0) { - const ssize_t ret = cobj->getTrianglesCount(); - jsval jsret = JSVAL_NULL; - jsret = ssize_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_experimental_SpritePolygon_getTrianglesCount : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} - -extern JSObject *jsb_cocos2d_Node_prototype; - -void js_cocos2d_experimental_SpritePolygon_finalize(JSFreeOp *fop, JSObject *obj) { - CCLOGINFO("jsbindings: finalizing JS object %p (SpritePolygon)", obj); -} - -void js_register_cocos2dx_experimental_SpritePolygon(JSContext *cx, JS::HandleObject global) { - jsb_cocos2d_experimental_SpritePolygon_class = (JSClass *)calloc(1, sizeof(JSClass)); - jsb_cocos2d_experimental_SpritePolygon_class->name = "SpritePolygon"; - jsb_cocos2d_experimental_SpritePolygon_class->addProperty = JS_PropertyStub; - jsb_cocos2d_experimental_SpritePolygon_class->delProperty = JS_DeletePropertyStub; - jsb_cocos2d_experimental_SpritePolygon_class->getProperty = JS_PropertyStub; - jsb_cocos2d_experimental_SpritePolygon_class->setProperty = JS_StrictPropertyStub; - jsb_cocos2d_experimental_SpritePolygon_class->enumerate = JS_EnumerateStub; - jsb_cocos2d_experimental_SpritePolygon_class->resolve = JS_ResolveStub; - jsb_cocos2d_experimental_SpritePolygon_class->convert = JS_ConvertStub; - jsb_cocos2d_experimental_SpritePolygon_class->finalize = js_cocos2d_experimental_SpritePolygon_finalize; - jsb_cocos2d_experimental_SpritePolygon_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); - - static JSPropertySpec properties[] = { - JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_PS_END - }; - - static JSFunctionSpec funcs[] = { - JS_FN("setTexture", js_cocos2dx_experimental_SpritePolygon_setTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("initWithTexture", js_cocos2dx_experimental_SpritePolygon_initWithTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("showDebug", js_cocos2dx_experimental_SpritePolygon_showDebug, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getTexture", js_cocos2dx_experimental_SpritePolygon_getTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getArea", js_cocos2dx_experimental_SpritePolygon_getArea, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("initWithMarching", js_cocos2dx_experimental_SpritePolygon_initWithMarching, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getVertCount", js_cocos2dx_experimental_SpritePolygon_getVertCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getTrianglesCount", js_cocos2dx_experimental_SpritePolygon_getTrianglesCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; - - JSFunctionSpec *st_funcs = NULL; - - jsb_cocos2d_experimental_SpritePolygon_prototype = JS_InitClass( - cx, global, - JS::RootedObject(cx, jsb_cocos2d_Node_prototype), - jsb_cocos2d_experimental_SpritePolygon_class, - dummy_constructor, 0, // no constructor - properties, - funcs, - NULL, // no static properties - st_funcs); - // make the class enumerable in the registered namespace -// bool found; -//FIXME: Removed in Firefox v27 -// JS_SetPropertyAttributes(cx, global, "SpritePolygon", JSPROP_ENUMERATE | JSPROP_READONLY, &found); - - // add the proto and JSClass to the type->js info hash table - TypeTest t; - js_type_class_t *p; - std::string typeName = t.s_name(); - if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) - { - p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); - p->jsclass = jsb_cocos2d_experimental_SpritePolygon_class; - p->proto = jsb_cocos2d_experimental_SpritePolygon_prototype; - p->parentProto = jsb_cocos2d_Node_prototype; - _js_global_type_map.insert(std::make_pair(typeName, p)); - } -} - -void register_all_cocos2dx_experimental(JSContext* cx, JS::HandleObject obj) { - // Get the ns - JS::RootedObject ns(cx); - get_or_create_js_obj(cx, obj, "ccexp", &ns); - - js_register_cocos2dx_experimental_SpritePolygon(cx, ns); -} - diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental.hpp deleted file mode 100644 index cc1fa9e695..0000000000 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "base/ccConfig.h" -#ifndef __cocos2dx_experimental_h__ -#define __cocos2dx_experimental_h__ - -#include "jsapi.h" -#include "jsfriendapi.h" - - -extern JSClass *jsb_cocos2d_experimental_SpritePolygon_class; -extern JSObject *jsb_cocos2d_experimental_SpritePolygon_prototype; - -bool js_cocos2dx_experimental_SpritePolygon_constructor(JSContext *cx, uint32_t argc, jsval *vp); -void js_cocos2dx_experimental_SpritePolygon_finalize(JSContext *cx, JSObject *obj); -void js_register_cocos2dx_experimental_SpritePolygon(JSContext *cx, JS::HandleObject global); -void register_all_cocos2dx_experimental(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_experimental_SpritePolygon_setTexture(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_experimental_SpritePolygon_initWithTexture(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_experimental_SpritePolygon_showDebug(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_experimental_SpritePolygon_getTexture(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_experimental_SpritePolygon_getArea(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_experimental_SpritePolygon_initWithMarching(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_experimental_SpritePolygon_getVertCount(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_experimental_SpritePolygon_getTrianglesCount(JSContext *cx, uint32_t argc, jsval *vp); - -#endif // __cocos2dx_experimental_h__ diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 6b3b584b62..72eda51986 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -3913,7 +3913,135 @@ bool js_cocos2dx_ccquatMultiply(JSContext *cx, uint32_t argc, jsval *vp) return false; } -bool js_cocos2dx_CCSprite_textureLoaded(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Sprite_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + + do { + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 0) { + cocos2d::Sprite* ret = cocos2d::Sprite::create(); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + + do { + if (argc == 2) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + if (!ok) { ok = true; break; } + cocos2d::Rect arg1; + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + if (!ok) { ok = true; break; } + cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0, arg1); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, (cocos2d::Sprite*)ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + } while (0); + JS_ReportError(cx, "js_cocos2dx_Sprite_create : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_Sprite_initWithPolygon(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_initWithPolygon : Invalid Native Object"); + if (argc == 1) { + cocos2d::PolygonInfo *arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::PolygonInfo*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_initWithPolygon : Error processing arguments"); + bool ret = cobj->initWithPolygon(*arg0); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_initWithPolygon : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_Sprite_setPolygonInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Sprite* cobj = (cocos2d::Sprite *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Sprite_setPolygonInfo : Invalid Native Object"); + if (argc == 1) { + cocos2d::PolygonInfo *arg0; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JSObject *tmpObj = args.get(0).toObjectOrNull(); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::PolygonInfo*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Sprite_setPolygonInfo : Error processing arguments"); + cobj->setPolygonInfo(*arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Sprite_setPolygonInfo : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} + +bool js_cocos2dx_Sprite_textureLoaded(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); @@ -5392,12 +5520,440 @@ bool js_cocos2dx_Scene_getPhysics3DWorld(JSContext *cx, uint32_t argc, jsval *vp } #endif //CC_ENABLE_BULLET_INTEGRATION && CC_USE_3D_PHYSICS +JSClass *jsb_cocos2d_PolygonInfo_class; +JSObject *jsb_cocos2d_PolygonInfo_prototype; + +bool js_cocos2dx_PolygonInfo_getArea(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_PolygonInfo_getArea : Invalid Native Object"); + if (argc == 0) + { + const float ret = cobj->getArea(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_PolygonInfo_getArea : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_PolygonInfo_getTriaglesCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_PolygonInfo_getTriaglesCount : Invalid Native Object"); + if (argc == 0) + { + const unsigned int ret = cobj->getTriaglesCount(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_PolygonInfo_getTriaglesCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_PolygonInfo_getVertCount(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_PolygonInfo_getVertCount : Invalid Native Object"); + if (argc == 0) + { + const unsigned int ret = cobj->getVertCount(); + jsval jsret = JSVAL_NULL; + jsret = uint32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_PolygonInfo_getVertCount : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} + +// PolygonInfo.rect +bool js_get_PolygonInfo_rect(JSContext* cx, uint32_t argc, jsval* vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL); + if (cobj) + { + jsval ret = ccrect_to_jsval(cx, cobj->rect); + + if (ret != JSVAL_NULL) + { + args.rval().set(ret); + return true; + } + CCLOGERROR("js_get_PolygonInfo_rect : Fail to retrieve property from PolygonInfo."); + return false; + } + JS_ReportError(cx, "js_get_PolygonInfo_rect : Invalid native object."); + return false; +} +bool js_set_PolygonInfo_rect(JSContext* cx, uint32_t argc, jsval* vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL); + if (cobj) + { + JS::RootedValue jsrect(cx, args.get(0)); + jsval_to_ccrect(cx, jsrect, &cobj->rect); + return true; + } + JS_ReportError(cx, "js_set_PolygonInfo_rect : Invalid native object."); + return false; +} + +// PolygonInfo.filename +bool js_get_PolygonInfo_filename(JSContext* cx, uint32_t argc, jsval* vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL); + if (cobj) + { + jsval ret = std_string_to_jsval(cx, cobj->filename); + + if (ret != JSVAL_NULL) + { + args.rval().set(ret); + return true; + } + CCLOGERROR("js_get_PolygonInfo_filename : Fail to retrieve property from PolygonInfo."); + return false; + } + JS_ReportError(cx, "js_get_PolygonInfo_filename : Invalid native object."); + return false; +} +bool js_set_PolygonInfo_filename(JSContext* cx, uint32_t argc, jsval* vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::PolygonInfo* cobj = (cocos2d::PolygonInfo *)(proxy ? proxy->ptr : NULL); + if (cobj) + { + JS::RootedValue jsstr(cx, args.get(0)); + jsval_to_std_string(cx, jsstr, &cobj->filename); + return true; + } + JS_ReportError(cx, "js_set_PolygonInfo_filename : Invalid native object."); + return false; +} + +bool js_cocos2dx_PolygonInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + cocos2d::PolygonInfo* cobj = new (std::nothrow) cocos2d::PolygonInfo(); + TypeTest t; + js_type_class_t *typeClass = nullptr; + std::string typeName = t.s_name(); + auto typeMapIter = _js_global_type_map.find(typeName); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + jsb_new_proxy(cobj, obj); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +void js_cocos2d_PolygonInfo_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (PolygonInfo)", obj); + js_proxy_t* nproxy; + js_proxy_t* jsproxy; + jsproxy = jsb_get_js_proxy(obj); + if (jsproxy) + { + nproxy = jsb_get_native_proxy(jsproxy->ptr); + + cocos2d::PolygonInfo *nobj = static_cast(nproxy->ptr); + if (nobj) + delete nobj; + + jsb_remove_proxy(nproxy, jsproxy); + } +} + +void js_register_cocos2dx_PolygonInfo(JSContext *cx, JS::HandleObject global) +{ + jsb_cocos2d_PolygonInfo_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_PolygonInfo_class->name = "PolygonInfo"; + jsb_cocos2d_PolygonInfo_class->addProperty = JS_PropertyStub; + jsb_cocos2d_PolygonInfo_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_PolygonInfo_class->getProperty = JS_PropertyStub; + jsb_cocos2d_PolygonInfo_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_PolygonInfo_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_PolygonInfo_class->resolve = JS_ResolveStub; + jsb_cocos2d_PolygonInfo_class->convert = JS_ConvertStub; + jsb_cocos2d_PolygonInfo_class->finalize = js_cocos2d_PolygonInfo_finalize; + jsb_cocos2d_PolygonInfo_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = + { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PSGS("rect", js_get_PolygonInfo_rect, js_set_PolygonInfo_rect, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PSGS("filename", js_get_PolygonInfo_filename, js_set_PolygonInfo_filename, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = + { + JS_FN("getArea", js_cocos2dx_PolygonInfo_getArea, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getTriaglesCount", js_cocos2dx_PolygonInfo_getTriaglesCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getVertCount", js_cocos2dx_PolygonInfo_getVertCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_cocos2d_PolygonInfo_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_PolygonInfo_class, + js_cocos2dx_PolygonInfo_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_PolygonInfo_class; + p->proto = jsb_cocos2d_PolygonInfo_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + +JSClass *jsb_cocos2d_AutoPolygon_class; +JSObject *jsb_cocos2d_AutoPolygon_prototype; + +bool js_cocos2dx_AutoPolygon_generatePolygon(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments"); + cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0)); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 2) { + std::string arg0; + cocos2d::Rect arg1; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments"); + cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1)); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 3) { + std::string arg0; + cocos2d::Rect arg1; + double arg2; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments"); + cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2)); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + if (argc == 4) { + std::string arg0; + cocos2d::Rect arg1; + double arg2; + double arg3; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + ok &= jsval_to_ccrect(cx, args.get(1), &arg1); + ok &= JS::ToNumber( cx, args.get(2), &arg2) && !isnan(arg2); + ok &= JS::ToNumber( cx, args.get(3), &arg3) && !isnan(arg3); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_generatePolygon : Error processing arguments"); + cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2, arg3)); + jsval jsret = JSVAL_NULL; + do { + if (ret) { + js_proxy_t *jsProxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(jsProxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + args.rval().set(jsret); + return true; + } + JS_ReportError(cx, "js_cocos2dx_AutoPolygon_generatePolygon : wrong number of arguments"); + return false; +} + +bool js_cocos2dx_AutoPolygon_constructor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_AutoPolygon_constructor : Error processing arguments"); + cocos2d::AutoPolygon* cobj = new (std::nothrow) cocos2d::AutoPolygon(arg0); + TypeTest t; + js_type_class_t *typeClass = nullptr; + std::string typeName = t.s_name(); + auto typeMapIter = _js_global_type_map.find(typeName); + CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); + typeClass = typeMapIter->second; + CCASSERT(typeClass, "The value is null."); + // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); + JS::RootedObject proto(cx, typeClass->proto.get()); + JS::RootedObject parent(cx, typeClass->parentProto.get()); + JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); + args.rval().set(OBJECT_TO_JSVAL(obj)); + // link the native object with the javascript object + jsb_new_proxy(cobj, obj); + if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + return true; +} + +void js_cocos2d_AutoPolygon_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (AutoPolygon)", obj); + js_proxy_t* nproxy; + js_proxy_t* jsproxy; + jsproxy = jsb_get_js_proxy(obj); + if (jsproxy) { + nproxy = jsb_get_native_proxy(jsproxy->ptr); + + cocos2d::AutoPolygon *nobj = static_cast(nproxy->ptr); + if (nobj) + delete nobj; + + jsb_remove_proxy(nproxy, jsproxy); + } +} + +void js_register_cocos2dx_AutoPolygon(JSContext *cx, JS::HandleObject global) { + jsb_cocos2d_AutoPolygon_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_cocos2d_AutoPolygon_class->name = "AutoPolygon"; + jsb_cocos2d_AutoPolygon_class->addProperty = JS_PropertyStub; + jsb_cocos2d_AutoPolygon_class->delProperty = JS_DeletePropertyStub; + jsb_cocos2d_AutoPolygon_class->getProperty = JS_PropertyStub; + jsb_cocos2d_AutoPolygon_class->setProperty = JS_StrictPropertyStub; + jsb_cocos2d_AutoPolygon_class->enumerate = JS_EnumerateStub; + jsb_cocos2d_AutoPolygon_class->resolve = JS_ResolveStub; + jsb_cocos2d_AutoPolygon_class->convert = JS_ConvertStub; + jsb_cocos2d_AutoPolygon_class->finalize = js_cocos2d_AutoPolygon_finalize; + jsb_cocos2d_AutoPolygon_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + JS_PSG("__nativeObj", js_is_native_obj, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_PS_END + }; + + static JSFunctionSpec funcs[] = { + JS_FS_END + }; + + static JSFunctionSpec st_funcs[] = { + JS_FN("generatePolygon", js_cocos2dx_AutoPolygon_generatePolygon, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + jsb_cocos2d_AutoPolygon_prototype = JS_InitClass( + cx, global, + JS::NullPtr(), // parent proto + jsb_cocos2d_AutoPolygon_class, + js_cocos2dx_AutoPolygon_constructor, 0, // constructor + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace + // bool found; + //FIXME: Removed in Firefox v27 + // JS_SetPropertyAttributes(cx, global, "AutoPolygon", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + std::string typeName = t.s_name(); + if (_js_global_type_map.find(typeName) == _js_global_type_map.end()) + { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->jsclass = jsb_cocos2d_AutoPolygon_class; + p->proto = jsb_cocos2d_AutoPolygon_prototype; + p->parentProto = NULL; + _js_global_type_map.insert(std::make_pair(typeName, p)); + } +} + void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject global) { JS::RootedObject ccObj(cx); + JS::RootedObject jsbObj(cx); JS::RootedValue tmpVal(cx); JS::RootedObject tmpObj(cx); get_or_create_js_obj(cx, global, "cc", &ccObj); + get_or_create_js_obj(cx, global, "jsb", &jsbObj); + + js_register_cocos2dx_PolygonInfo(cx, jsbObj); + js_register_cocos2dx_AutoPolygon(cx, jsbObj); JS_GetProperty(cx, ccObj, "PlistParser", &tmpVal); tmpObj = tmpVal.toObjectOrNull(); @@ -5559,8 +6115,13 @@ void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject global) tmpObj.set(jsb_cocos2d_CatmullRomTo_prototype); JS_DefineFunction(cx, tmpObj, "initWithDuration", JSB_CatmullRomBy_initWithDuration, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_GetProperty(cx, ccObj, "Sprite", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_Sprite_create, 0, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj.set(jsb_cocos2d_Sprite_prototype); - JS_DefineFunction(cx, tmpObj, "textureLoaded", js_cocos2dx_CCSprite_textureLoaded, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "initWithPolygon", js_cocos2dx_Sprite_initWithPolygon, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "setPolygonInfo", js_cocos2dx_Sprite_setPolygonInfo, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "textureLoaded", js_cocos2dx_Sprite_textureLoaded, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); tmpObj.set(jsb_cocos2d_SpriteBatchNode_prototype); JS_DefineFunction(cx, tmpObj, "getDescendants", js_cocos2dx_SpriteBatchNode_getDescendants, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); diff --git a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_manual.cpp b/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_manual.cpp deleted file mode 100644 index eba2af0574..0000000000 --- a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_manual.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2011 Zynga Inc. - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "jsb_cocos2dx_experimental_manual.h" -#include "cocos2d_specifics.hpp" -#include "2d/SpritePolygon.h" - -bool jsval_to_vector_vec2(JSContext* cx, JS::HandleValue v, std::vector* ret) -{ - JS::RootedObject jsArr(cx); - bool ok = v.isObject() && JS_ValueToObject( cx, v, &jsArr ); - JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); - JSB_PRECONDITION3( jsArr && JS_IsArrayObject( cx, jsArr), cx, false, "Object must be an array"); - - uint32_t len = 0; - JS_GetArrayLength(cx, jsArr, &len); - ret->reserve(len); - - for (uint32_t i=0; i < len; i++) - { - JS::RootedValue value(cx); - if (JS_GetElement(cx, jsArr, i, &value)) - { - cocos2d::Vec2 vec2; - ok &= jsval_to_vector2(cx, value, &vec2); - ret->push_back(vec2); - } - } - return ok; -} - -bool jsval_to_vector_unsigned_short(JSContext* cx, JS::HandleValue v, std::vector* ret) -{ - JS::RootedObject jsArr(cx); - bool ok = v.isObject() && JS_ValueToObject( cx, v, &jsArr ); - JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); - JSB_PRECONDITION3( jsArr && JS_IsArrayObject( cx, jsArr), cx, false, "Object must be an array"); - - uint32_t len = 0; - JS_GetArrayLength(cx, jsArr, &len); - ret->reserve(len); - - for (uint32_t i=0; i < len; i++) - { - JS::RootedValue value(cx); - if (JS_GetElement(cx, jsArr, i, &value)) - { - unsigned short index; - ok &= jsval_to_uint16(cx, value, &index); - ret->push_back(index); - } - } - return ok; -} - -bool jsval_to_cctex2f(JSContext* cx, JS::HandleValue vp, cocos2d::Tex2F* ret) -{ - JS::RootedObject tmp(cx); - JS::RootedValue jsx(cx); - JS::RootedValue jsy(cx); - double x, y; - bool ok = vp.isObject() && - JS_ValueToObject(cx, vp, &tmp) && - JS_GetProperty(cx, tmp, "x", &jsx) && - JS_GetProperty(cx, tmp, "y", &jsy) && - JS::ToNumber(cx, jsx, &x) && - JS::ToNumber(cx, jsy, &y) && - !isnan(x) && !isnan(y); - - JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); - - ret->u = (GLfloat)x; - ret->v = (GLfloat)y; - return true; -} - -bool jsval_to_v3fc4bt2f(JSContext* cx, JS::HandleValue v, cocos2d::V3F_C4B_T2F* ret) -{ - JS::RootedObject object(cx, v.toObjectOrNull()); - - cocos2d::Vec3 v3; - cocos2d::Color4B color; - cocos2d::Tex2F t2; - - JS::RootedValue jsv3(cx); - JS::RootedValue jscolor(cx); - JS::RootedValue jst2(cx); - - bool ok = JS_GetProperty(cx, object, "v3f", &jsv3) && - JS_GetProperty(cx, object, "c4b", &jscolor) && - JS_GetProperty(cx, object, "t2f", &jst2) && - jsval_to_vector3(cx, jsv3, &v3) && - jsval_to_cccolor4b(cx, jscolor, &color) && - jsval_to_cctex2f(cx, jst2, &t2); - - JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); - - ret->vertices = v3; - ret->colors = color; - ret->texCoords = t2; - return true; -} - -bool jsval_to_vector_v3fc4bt2f(JSContext* cx, JS::HandleValue v, std::vector* ret) -{ - JS::RootedObject jsArr(cx); - bool ok = v.isObject() && JS_ValueToObject( cx, v, &jsArr ); - JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); - JSB_PRECONDITION3( jsArr && JS_IsArrayObject( cx, jsArr), cx, false, "Object must be an array"); - - uint32_t len = 0; - JS_GetArrayLength(cx, jsArr, &len); - ret->reserve(len); - - for (uint32_t i=0; i < len; i++) - { - JS::RootedValue value(cx); - if (JS_GetElement(cx, jsArr, i, &value)) - { - cocos2d::V3F_C4B_T2F vert; - ok &= jsval_to_v3fc4bt2f(cx, value, &vert); - ret->push_back(vert); - } - } - return ok; -} - -bool js_cocos2dx_SpritePolygon_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - if(argc == 1) - { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::string file; - bool ok = jsval_to_std_string(cx, args.get(0), &file); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpritePolygon_create : Error processing arguments"); - - auto sprite = cocos2d::experimental::SpritePolygon::create(file); - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, sprite); - JS::RootedValue ret(cx, OBJECT_TO_JSVAL(jsProxy->obj)); - - args.rval().set(ret); - return true; - } - - - if(argc == 2) - { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::string file; - std::vector verts; - bool ok = jsval_to_std_string(cx, args.get(0), &file); - ok &= jsval_to_vector_vec2(cx, args.get(1), &verts); - - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_SpritePolygon_create : Error processing arguments"); - - auto sprite = cocos2d::experimental::SpritePolygon::create(file, verts); - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, sprite); - JS::RootedValue ret(cx, OBJECT_TO_JSVAL(jsProxy->obj)); - - args.rval().set(ret); - return true; - - } - - if(argc == 3) - { - do - { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::string file; - std::vector verts; - std::vector indices; - - bool ok = jsval_to_std_string(cx, args.get(0), &file); - ok &= jsval_to_vector_vec2(cx, args.get(1), &verts); - ok &= jsval_to_vector_unsigned_short(cx, args.get(2), &indices); - - if(!ok) - break; - - auto sprite = cocos2d::experimental::SpritePolygon::create(file, verts, indices); - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, sprite); - JS::RootedValue ret(cx, OBJECT_TO_JSVAL(jsProxy->obj)); - - args.rval().set(ret); - return true; - }while (0); - - do - { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - std::string file; - std::vector verts; - std::vector indices; - - bool ok = jsval_to_std_string(cx, args.get(0), &file); - ok &= jsval_to_vector_v3fc4bt2f(cx, args.get(1), &verts); - ok &= jsval_to_vector_unsigned_short(cx, args.get(2), &indices); - - if(!ok) - break; - - auto sprite = cocos2d::experimental::SpritePolygon::create(file, verts, indices); - js_proxy_t *jsProxy = js_get_or_create_proxy(cx, sprite); - JS::RootedValue ret(cx, OBJECT_TO_JSVAL(jsProxy->obj)); - - args.rval().set(ret); - return true; - }while(0); - - JS_ReportError(cx, "js_cocos2dx_SpritePolygon_create : Error processing arguments"); - } - - JS_ReportError(cx, "js_cocos2dx_SpritePolygon_create : wrong number of arguments: %d", argc); - return false; -} - -void register_all_cocos2dx_experimental_manual(JSContext *cx, JS::HandleObject global) -{ - - JS::RootedObject ccObj(cx); - get_or_create_js_obj(cx, global, "ccexp", &ccObj); - - JS::RootedValue tmpVal(cx); - JS_GetProperty(cx, ccObj, "SpritePolygon", &tmpVal); - JS::RootedObject tmpObj(cx, tmpVal.toObjectOrNull()); - JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_SpritePolygon_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); - -} \ No newline at end of file diff --git a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_manual.h b/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_manual.h deleted file mode 100644 index d75484d697..0000000000 --- a/cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_manual.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2011 Zynga Inc. - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ -#ifndef __jsb_cococs2dx_experimental_h__ -#define __jsb_cococs2dx_experimental_h__ - - -#include "jsapi.h" - -void register_all_cocos2dx_experimental_manual(JSContext *cx, JS::HandleObject global); - -#endif \ No newline at end of file diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp index 6b85f98ced..8a6abab752 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.cpp @@ -1565,6 +1565,134 @@ bool jsval_to_blendfunc(JSContext *cx, JS::HandleValue vp, cocos2d::BlendFunc* r return true; } +bool jsval_to_vector_vec2(JSContext* cx, JS::HandleValue v, std::vector* ret) +{ + JS::RootedObject jsArr(cx); + bool ok = v.isObject() && JS_ValueToObject( cx, v, &jsArr ); + JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION3( jsArr && JS_IsArrayObject( cx, jsArr), cx, false, "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, jsArr, &len); + ret->reserve(len); + + for (uint32_t i=0; i < len; i++) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsArr, i, &value)) + { + cocos2d::Vec2 vec2; + ok &= jsval_to_vector2(cx, value, &vec2); + ret->push_back(vec2); + } + } + return ok; +} + +bool jsval_to_cctex2f(JSContext* cx, JS::HandleValue vp, cocos2d::Tex2F* ret) +{ + JS::RootedObject tmp(cx); + JS::RootedValue jsx(cx); + JS::RootedValue jsy(cx); + double x, y; + bool ok = vp.isObject() && + JS_ValueToObject(cx, vp, &tmp) && + JS_GetProperty(cx, tmp, "x", &jsx) && + JS_GetProperty(cx, tmp, "y", &jsy) && + JS::ToNumber(cx, jsx, &x) && + JS::ToNumber(cx, jsy, &y) && + !isnan(x) && !isnan(y); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->u = (GLfloat)x; + ret->v = (GLfloat)y; + return true; +} + +bool jsval_to_v3fc4bt2f(JSContext* cx, JS::HandleValue v, cocos2d::V3F_C4B_T2F* ret) +{ + JS::RootedObject object(cx, v.toObjectOrNull()); + + cocos2d::Vec3 v3; + cocos2d::Color4B color; + cocos2d::Tex2F t2; + + JS::RootedValue jsv3(cx); + JS::RootedValue jscolor(cx); + JS::RootedValue jst2(cx); + + bool ok = JS_GetProperty(cx, object, "v3f", &jsv3) && + JS_GetProperty(cx, object, "c4b", &jscolor) && + JS_GetProperty(cx, object, "t2f", &jst2) && + jsval_to_vector3(cx, jsv3, &v3) && + jsval_to_cccolor4b(cx, jscolor, &color) && + jsval_to_cctex2f(cx, jst2, &t2); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->vertices = v3; + ret->colors = color; + ret->texCoords = t2; + return true; +} + +bool jsval_to_v3fc4bt2f_quad(JSContext* cx, JS::HandleValue v, cocos2d::V3F_C4B_T2F_Quad* ret) +{ + JS::RootedObject object(cx, v.toObjectOrNull()); + + cocos2d::V3F_C4B_T2F tl; + cocos2d::V3F_C4B_T2F bl; + cocos2d::V3F_C4B_T2F tr; + cocos2d::V3F_C4B_T2F br; + + JS::RootedValue jstl(cx); + JS::RootedValue jsbl(cx); + JS::RootedValue jstr(cx); + JS::RootedValue jsbr(cx); + + bool ok = JS_GetProperty(cx, object, "tl", &jstl) && + JS_GetProperty(cx, object, "bl", &jsbl) && + JS_GetProperty(cx, object, "tr", &jstr) && + JS_GetProperty(cx, object, "br", &jsbr) && + jsval_to_v3fc4bt2f(cx, jstl, &tl) && + jsval_to_v3fc4bt2f(cx, jsbl, &bl) && + jsval_to_v3fc4bt2f(cx, jstr, &tr) && + jsval_to_v3fc4bt2f(cx, jsbr, &br); + + JSB_PRECONDITION3(ok, cx, false, "Error processing arguments"); + + ret->tl = tl; + ret->bl = bl; + ret->tr = tr; + ret->br = br; + return true; +} + +bool jsval_to_vector_v3fc4bt2f(JSContext* cx, JS::HandleValue v, std::vector* ret) +{ + JS::RootedObject jsArr(cx); + bool ok = v.isObject() && JS_ValueToObject( cx, v, &jsArr ); + JSB_PRECONDITION3( ok, cx, false, "Error converting value to object"); + JSB_PRECONDITION3( jsArr && JS_IsArrayObject( cx, jsArr), cx, false, "Object must be an array"); + + uint32_t len = 0; + JS_GetArrayLength(cx, jsArr, &len); + ret->reserve(len); + + for (uint32_t i=0; i < len; i++) + { + JS::RootedValue value(cx); + if (JS_GetElement(cx, jsArr, i, &value)) + { + cocos2d::V3F_C4B_T2F vert; + ok &= jsval_to_v3fc4bt2f(cx, value, &vert); + ret->push_back(vert); + } + } + return ok; +} + // native --> jsval jsval ccarray_to_jsval(JSContext* cx, __Array *arr) @@ -2603,3 +2731,21 @@ jsval blendfunc_to_jsval(JSContext *cx, const cocos2d::BlendFunc& v) } return JSVAL_NULL; } + +jsval vector_vec2_to_jsval(JSContext *cx, const std::vector& v) +{ + JS::RootedObject jsretArr(cx, JS_NewArrayObject(cx, v.size())); + + int i = 0; + for (const cocos2d::Vec2 obj : v) + { + JS::RootedValue arrElement(cx); + arrElement = vector2_to_jsval(cx, obj); + + if (!JS_SetElement(cx, jsretArr, i, arrElement)) { + break; + } + ++i; + } + return OBJECT_TO_JSVAL(jsretArr); +} \ No newline at end of file diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index 9d9b1b8538..9627ca4679 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -187,6 +187,11 @@ bool jsval_to_vector2(JSContext *cx, JS::HandleValue vp, cocos2d::Vec2* ret); bool jsval_to_vector3(JSContext *cx, JS::HandleValue vp, cocos2d::Vec3* ret); bool jsval_to_vector4(JSContext *cx, JS::HandleValue vp, cocos2d::Vec4* ret); bool jsval_to_blendfunc(JSContext *cx, JS::HandleValue vp, cocos2d::BlendFunc* ret); +bool jsval_to_vector_vec2(JSContext* cx, JS::HandleValue v, std::vector* ret); +bool jsval_to_cctex2f(JSContext* cx, JS::HandleValue vp, cocos2d::Tex2F* ret); +bool jsval_to_v3fc4bt2f(JSContext* cx, JS::HandleValue v, cocos2d::V3F_C4B_T2F* ret); +bool jsval_to_v3fc4bt2f_quad(JSContext* cx, JS::HandleValue v, cocos2d::V3F_C4B_T2F_Quad* ret); +bool jsval_to_vector_v3fc4bt2f(JSContext* cx, JS::HandleValue v, std::vector* ret); template bool jsval_to_ccmap_string_key(JSContext *cx, JS::HandleValue v, cocos2d::Map* ret) @@ -333,6 +338,7 @@ jsval matrix_to_jsval(JSContext *cx, const cocos2d::Mat4& v); jsval vector2_to_jsval(JSContext *cx, const cocos2d::Vec2& v); jsval vector3_to_jsval(JSContext *cx, const cocos2d::Vec3& v); jsval blendfunc_to_jsval(JSContext *cx, const cocos2d::BlendFunc& v); +jsval vector_vec2_to_jsval(JSContext *cx, const std::vector& v); #endif /* __JS_MANUAL_CONVERSIONS_H__ */ diff --git a/cocos/scripting/js-bindings/proj.android/Android.mk b/cocos/scripting/js-bindings/proj.android/Android.mk index 0cd74cfb2e..4c9507b609 100755 --- a/cocos/scripting/js-bindings/proj.android/Android.mk +++ b/cocos/scripting/js-bindings/proj.android/Android.mk @@ -45,7 +45,6 @@ LOCAL_SRC_FILES := ../auto/jsb_cocos2dx_3d_auto.cpp \ ../auto/jsb_cocos2dx_studio_auto.cpp \ ../auto/jsb_cocos2dx_builder_auto.cpp \ ../auto/jsb_cocos2dx_ui_auto.cpp \ - ../auto/jsb_cocos2dx_experimental.cpp \ ../auto/jsb_cocos2dx_physics3d_auto.cpp \ ../manual/ScriptingCore.cpp \ \ ../manual/cocos2d_specifics.cpp \ @@ -74,7 +73,6 @@ LOCAL_SRC_FILES := ../auto/jsb_cocos2dx_3d_auto.cpp \ ../manual/network/XMLHTTPRequest.cpp \ ../manual/spine/jsb_cocos2dx_spine_manual.cpp \ ../manual/ui/jsb_cocos2dx_ui_manual.cpp \ - ../manual/experimental/jsb_cocos2dx_experimental_manual.cpp \ ../manual/physics3d/jsb_cocos2dx_physics3d_manual.cpp diff --git a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj index 6955ee04c3..0d5d366619 100644 --- a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj @@ -154,14 +154,6 @@ 426390051B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 426390021B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp */; }; 426390061B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 426390031B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h */; }; 426390071B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 426390031B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h */; }; - 42AD256C1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42AD256A1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp */; }; - 42AD256D1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42AD256A1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp */; }; - 42AD256E1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 42AD256B1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp */; }; - 42AD256F1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 42AD256B1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp */; }; - 42AD25731AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42AD25711AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.cpp */; }; - 42AD25741AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42AD25711AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.cpp */; }; - 42AD25751AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 42AD25721AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.h */; }; - 42AD25761AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 42AD25721AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.h */; }; 4B22F4AA1B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B22F4A71B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.cpp */; }; 4B22F4AB1B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B22F4A81B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.h */; }; 4B22F4AC1B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B22F4A81B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.h */; }; @@ -285,10 +277,6 @@ 42638FFC1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_physics3d_auto.hpp; sourceTree = ""; }; 426390021B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_physics3d_manual.cpp; sourceTree = ""; }; 426390031B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_physics3d_manual.h; sourceTree = ""; }; - 42AD256A1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_experimental.cpp; sourceTree = ""; }; - 42AD256B1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_experimental.hpp; sourceTree = ""; }; - 42AD25711AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_cocos2dx_experimental_manual.cpp; path = experimental/jsb_cocos2dx_experimental_manual.cpp; sourceTree = ""; }; - 42AD25721AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_cocos2dx_experimental_manual.h; path = experimental/jsb_cocos2dx_experimental_manual.h; sourceTree = ""; }; 4B22F4A71B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_cocos2dx_experimental_webView_manual.cpp; path = experimental/jsb_cocos2dx_experimental_webView_manual.cpp; sourceTree = ""; }; 4B22F4A81B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_cocos2dx_experimental_webView_manual.h; path = experimental/jsb_cocos2dx_experimental_webView_manual.h; sourceTree = ""; }; 4BE089E01ADF965E00D65D4B /* jsb_cocos2dx_experimental_webView_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_experimental_webView_auto.cpp; sourceTree = ""; }; @@ -371,8 +359,6 @@ 4BE089E11ADF965E00D65D4B /* jsb_cocos2dx_experimental_webView_auto.hpp */, 42638FFB1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.cpp */, 42638FFC1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp */, - 42AD256A1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp */, - 42AD256B1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp */, 420BBCEE1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.cpp */, 420BBCEF1AA48EDE00493976 /* jsb_cocos2dx_3d_auto.hpp */, BAEE4D6F1AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp */, @@ -592,8 +578,6 @@ B38AD5691B1D384A0057DD7F /* jsb_cocos2dx_experimental_video_manual.h */, 4B22F4A71B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.cpp */, 4B22F4A81B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.h */, - 42AD25711AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.cpp */, - 42AD25721AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.h */, ); name = experimental; sourceTree = ""; @@ -651,10 +635,8 @@ 1A119EEF18BDF19200352BAA /* js_bindings_system_functions.h in Headers */, 1A119EDD18BDF19200352BAA /* js_manual_conversions.h in Headers */, 1A119EFD18BDF19200352BAA /* XMLHTTPRequest.h in Headers */, - 42AD25751AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.h in Headers */, 1AB5E63518D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h in Headers */, 1A119EE318BDF19200352BAA /* jsb_opengl_functions.h in Headers */, - 42AD256E1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp in Headers */, 42638FFF1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp in Headers */, 0541A74F1973876100E45470 /* JavaScriptObjCBridge.h in Headers */, 426390061B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h in Headers */, @@ -693,7 +675,6 @@ 1A119EB618BDF19200352BAA /* js_bindings_chipmunk_manual.h in Headers */, 1A119EFA18BDF19200352BAA /* jsb_websocket.h in Headers */, 1A119E9218BDF19200352BAA /* jsb_cocos2dx_extension_auto.hpp in Headers */, - 42AD25761AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.h in Headers */, 4B22F4AC1B159A7A0044C14E /* jsb_cocos2dx_experimental_webView_manual.h in Headers */, 1A119E8C18BDF19200352BAA /* jsb_cocos2dx_builder_auto.hpp in Headers */, 4BE089E51ADF965E00D65D4B /* jsb_cocos2dx_experimental_webView_auto.hpp in Headers */, @@ -710,7 +691,6 @@ 1A119ECC18BDF19200352BAA /* jsb_cocos2dx_extension_manual.h in Headers */, 1A119EF018BDF19200352BAA /* js_bindings_system_functions.h in Headers */, 1A119EDE18BDF19200352BAA /* js_manual_conversions.h in Headers */, - 42AD256F1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.hpp in Headers */, 1A119EFE18BDF19200352BAA /* XMLHTTPRequest.h in Headers */, 1AB5E63618D05BF30088DAA4 /* jsb_cocos2dx_ui_manual.h in Headers */, 1A119EE418BDF19200352BAA /* jsb_opengl_functions.h in Headers */, @@ -814,13 +794,11 @@ 0541A7501973876100E45470 /* JavaScriptObjCBridge.mm in Sources */, 1A119EB318BDF19200352BAA /* js_bindings_chipmunk_manual.cpp in Sources */, 1A119EE918BDF19200352BAA /* jsb_opengl_registration.cpp in Sources */, - 42AD25731AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.cpp in Sources */, 1A119EF718BDF19200352BAA /* jsb_websocket.cpp in Sources */, 1A119ED318BDF19200352BAA /* js_bindings_core.cpp in Sources */, 1A119EC118BDF19200352BAA /* js_bindings_ccbreader.cpp in Sources */, 1A119EFB18BDF19200352BAA /* XMLHTTPRequest.cpp in Sources */, BAEE4D711AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp in Sources */, - 42AD256C1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp in Sources */, 1A119EC518BDF19200352BAA /* jsb_cocos2dx_studio_manual.cpp in Sources */, 1A119E8F18BDF19200352BAA /* jsb_cocos2dx_extension_auto.cpp in Sources */, 1A119ED718BDF19200352BAA /* js_bindings_opengl.cpp in Sources */, @@ -871,7 +849,6 @@ 1A119E9C18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp in Sources */, 4BE089E41ADF965E00D65D4B /* jsb_cocos2dx_experimental_webView_auto.cpp in Sources */, 1A119EF418BDF19200352BAA /* js_bindings_system_registration.cpp in Sources */, - 42AD256D1AFF9D1A000176E2 /* jsb_cocos2dx_experimental.cpp in Sources */, B38AD56E1B1D38700057DD7F /* jsb_cocos2dx_experimental_video_auto.cpp in Sources */, 1A119EBC18BDF19200352BAA /* cocos2d_specifics.cpp in Sources */, 426390051B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.cpp in Sources */, @@ -879,7 +856,6 @@ 1A119EE618BDF19200352BAA /* jsb_opengl_manual.cpp in Sources */, 1A119F0618BDF19200352BAA /* jsb_cocos2dx_spine_manual.cpp in Sources */, BA623E0F191A195F00761F37 /* jsb_pluginx_manual_protocols.cpp in Sources */, - 42AD25741AFF9E17000176E2 /* jsb_cocos2dx_experimental_manual.cpp in Sources */, BA623E13191A195F00761F37 /* pluginxUTF8.cpp in Sources */, BAEE4D721AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp in Sources */, 1A119EB818BDF19200352BAA /* js_bindings_chipmunk_registration.cpp in Sources */, diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj index 4eb40ed7af..8f3c4eda7f 100644 --- a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj @@ -15,7 +15,6 @@ - @@ -30,7 +29,6 @@ - @@ -54,7 +52,6 @@ - @@ -72,7 +69,6 @@ - diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters index c4e49936c6..12ff8fee64 100644 --- a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters @@ -143,12 +143,6 @@ manual\3d - - auto - - - manual\experimental - auto @@ -277,12 +271,6 @@ manual\3d - - auto - - - manual\experimental - auto diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems index 409eb85c05..bdd571d505 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems @@ -18,7 +18,6 @@ - @@ -36,7 +35,6 @@ - @@ -65,7 +63,6 @@ - @@ -80,7 +77,6 @@ - diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters index 6824d69c63..8daf02c36d 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Shared/libjscocos2d.Shared.vcxitems.filters @@ -122,12 +122,6 @@ auto - - auto - - - manual\experimental - auto @@ -235,12 +229,6 @@ auto - - auto - - - manual\experimental - auto diff --git a/cocos/scripting/lua-bindings/auto/api/ArmatureDataManager.lua b/cocos/scripting/lua-bindings/auto/api/ArmatureDataManager.lua index 801ce69a0e..0b81d627ca 100644 --- a/cocos/scripting/lua-bindings/auto/api/ArmatureDataManager.lua +++ b/cocos/scripting/lua-bindings/auto/api/ArmatureDataManager.lua @@ -11,8 +11,8 @@ -- @return map_table#map_table ret (return value: map_table) -------------------------------- --- brief remove animation data
--- param id the id of the animation data +-- brief remove animation data
+-- param id the id of the animation data -- @function [parent=#ArmatureDataManager] removeAnimationData -- @param self -- @param #string id @@ -53,8 +53,8 @@ -- @return map_table#map_table ret (return value: map_table) -------------------------------- --- brief get texture data
--- param id the id of the texture data you want to get
+-- brief get texture data
+-- param id the id of the texture data you want to get
-- return TextureData * -- @function [parent=#ArmatureDataManager] getTextureData -- @param self @@ -62,17 +62,17 @@ -- @return TextureData#TextureData ret (return value: ccs.TextureData) -------------------------------- --- brief get armature data
--- param id the id of the armature data you want to get
--- return ArmatureData * +-- brief get armature data
+-- param id the id of the armature data you want to get
+-- return ArmatureData * -- @function [parent=#ArmatureDataManager] getArmatureData -- @param self -- @param #string id -- @return ArmatureData#ArmatureData ret (return value: ccs.ArmatureData) -------------------------------- --- brief get animation data from _animationDatas(Dictionary)
--- param id the id of the animation data you want to get
+-- brief get animation data from _animationDatas(Dictionary)
+-- param id the id of the animation data you want to get
-- return AnimationData * -- @function [parent=#ArmatureDataManager] getAnimationData -- @param self @@ -80,8 +80,8 @@ -- @return AnimationData#AnimationData ret (return value: ccs.AnimationData) -------------------------------- --- brief add animation data
--- param id the id of the animation data
+-- brief add animation data
+-- param id the id of the animation data
-- return AnimationData * -- @function [parent=#ArmatureDataManager] addAnimationData -- @param self @@ -97,8 +97,8 @@ -- @return bool#bool ret (return value: bool) -------------------------------- --- brief remove armature data
--- param id the id of the armature data you want to get +-- brief remove armature data
+-- param id the id of the armature data you want to get -- @function [parent=#ArmatureDataManager] removeArmatureData -- @param self -- @param #string id @@ -111,16 +111,16 @@ -- @return map_table#map_table ret (return value: map_table) -------------------------------- --- brief remove texture data
--- param id the id of the texture data you want to get +-- brief remove texture data
+-- param id the id of the texture data you want to get -- @function [parent=#ArmatureDataManager] removeTextureData -- @param self -- @param #string id -- @return ArmatureDataManager#ArmatureDataManager self (return value: ccs.ArmatureDataManager) -------------------------------- --- brief add texture data
--- param id the id of the texture data
+-- brief add texture data
+-- param id the id of the texture data
-- return TextureData * -- @function [parent=#ArmatureDataManager] addTextureData -- @param self @@ -130,13 +130,13 @@ -- @return ArmatureDataManager#ArmatureDataManager self (return value: ccs.ArmatureDataManager) -------------------------------- --- brief Juge whether or not need auto load sprite file +-- brief Juge whether or not need auto load sprite file -- @function [parent=#ArmatureDataManager] isAutoLoadSpriteFile -- @param self -- @return bool#bool ret (return value: bool) -------------------------------- --- brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name +-- brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name -- @function [parent=#ArmatureDataManager] addSpriteFrameFromFile -- @param self -- @param #string plistPath diff --git a/cocos/scripting/lua-bindings/auto/api/AutoPolygon.lua b/cocos/scripting/lua-bindings/auto/api/AutoPolygon.lua new file mode 100644 index 0000000000..c7750adf8a --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/AutoPolygon.lua @@ -0,0 +1,16 @@ + +-------------------------------- +-- @module AutoPolygon +-- @parent_module cc + +-------------------------------- +-- create an AutoPolygon and initialize it with an image file
+-- the image must be a 32bit PNG for current version 3.7
+-- param filename a path to image file, e.g., "scene1/monster.png".
+-- return an AutoPolygon object; +-- @function [parent=#AutoPolygon] AutoPolygon +-- @param self +-- @param #string filename +-- @return AutoPolygon#AutoPolygon self (return value: cc.AutoPolygon) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/Bone.lua b/cocos/scripting/lua-bindings/auto/api/Bone.lua index 9987c6c34c..49e23a6906 100644 --- a/cocos/scripting/lua-bindings/auto/api/Bone.lua +++ b/cocos/scripting/lua-bindings/auto/api/Bone.lua @@ -43,7 +43,7 @@ -------------------------------- -- Add a child to this bone, and it will let this child call setParent(Bone *parent) function to set self to it's parent
--- param child the child you want to add +-- param child the child you want to add -- @function [parent=#Bone] addChildBone -- @param self -- @param #ccs.Bone child @@ -193,7 +193,7 @@ -------------------------------- -- Removes a child Bone
--- param bone the bone you want to remove +-- param bone the bone you want to remove -- @function [parent=#Bone] removeChildBone -- @param self -- @param #ccs.Bone bone diff --git a/cocos/scripting/lua-bindings/auto/api/PolygonInfo.lua b/cocos/scripting/lua-bindings/auto/api/PolygonInfo.lua new file mode 100644 index 0000000000..58a9a285fe --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/PolygonInfo.lua @@ -0,0 +1,46 @@ + +-------------------------------- +-- @module PolygonInfo +-- @parent_module cc + +-------------------------------- +-- get sum of all triangle area size
+-- return sum of all triangle area size +-- @function [parent=#PolygonInfo] getArea +-- @param self +-- @return float#float ret (return value: float) + +-------------------------------- +-- get triangles count
+-- return number of triangles +-- @function [parent=#PolygonInfo] getTriaglesCount +-- @param self +-- @return unsigned int#unsigned int ret (return value: unsigned int) + +-------------------------------- +-- get vertex count
+-- return number of vertices +-- @function [parent=#PolygonInfo] getVertCount +-- @param self +-- @return unsigned int#unsigned int ret (return value: unsigned int) + +-------------------------------- +-- set the data to be a pointer to a quad
+-- the member verts will not be released when this PolygonInfo destructs
+-- as the verts memory are managed by other objects
+-- param quad a pointer to the V3F_C4B_T2F_Quad obje +-- @function [parent=#PolygonInfo] setQuad +-- @param self +-- @param #cc.V3F_C4B_T2F_Quad quad +-- @return PolygonInfo#PolygonInfo self (return value: cc.PolygonInfo) + +-------------------------------- +-- / @name Creators/ @{
+-- Creates an empty Polygon info
+-- memberof PolygonInfo
+-- return PolygonInfo object +-- @function [parent=#PolygonInfo] PolygonInfo +-- @param self +-- @return PolygonInfo#PolygonInfo self (return value: cc.PolygonInfo) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/Sprite.lua b/cocos/scripting/lua-bindings/auto/api/Sprite.lua index 8bf0536e3d..92bab73b70 100644 --- a/cocos/scripting/lua-bindings/auto/api/Sprite.lua +++ b/cocos/scripting/lua-bindings/auto/api/Sprite.lua @@ -186,6 +186,13 @@ -- @param self -- @return rect_table#rect_table ret (return value: rect_table) +-------------------------------- +-- +-- @function [parent=#Sprite] debugDraw +-- @param self +-- @param #bool on +-- @return Sprite#Sprite self (return value: cc.Sprite) + -------------------------------- -- @overload self, string, rect_table -- @overload self, string @@ -254,46 +261,6 @@ -- @param #rect_table rect -- @return Sprite#Sprite self (return value: cc.Sprite) --------------------------------- --- @overload self, string --- @overload self --- @overload self, string, rect_table --- @function [parent=#Sprite] create --- @param self --- @param #string filename --- @param #rect_table rect --- @return Sprite#Sprite ret (return value: cc.Sprite) - --------------------------------- --- @overload self, cc.Texture2D, rect_table, bool --- @overload self, cc.Texture2D --- @function [parent=#Sprite] createWithTexture --- @param self --- @param #cc.Texture2D texture --- @param #rect_table rect --- @param #bool rotated --- @return Sprite#Sprite ret (return value: cc.Sprite) - --------------------------------- --- Creates a sprite with an sprite frame name.
--- A SpriteFrame will be fetched from the SpriteFrameCache by spriteFrameName param.
--- If the SpriteFrame doesn't exist it will raise an exception.
--- param spriteFrameName A null terminated string which indicates the sprite frame name.
--- return An autoreleased sprite object. --- @function [parent=#Sprite] createWithSpriteFrameName --- @param self --- @param #string spriteFrameName --- @return Sprite#Sprite ret (return value: cc.Sprite) - --------------------------------- --- Creates a sprite with an sprite frame.
--- param spriteFrame A sprite frame which involves a texture and a rect.
--- return An autoreleased sprite object. --- @function [parent=#Sprite] createWithSpriteFrame --- @param self --- @param #cc.SpriteFrame spriteFrame --- @return Sprite#Sprite ret (return value: cc.Sprite) - -------------------------------- -- @overload self, cc.Node, int, string -- @overload self, cc.Node, int, int diff --git a/cocos/scripting/lua-bindings/auto/api/SpritePolygon.lua b/cocos/scripting/lua-bindings/auto/api/SpritePolygon.lua deleted file mode 100644 index d932cae710..0000000000 --- a/cocos/scripting/lua-bindings/auto/api/SpritePolygon.lua +++ /dev/null @@ -1,61 +0,0 @@ - --------------------------------- --- @module SpritePolygon --- @extend Node --- @parent_module ccexp - --------------------------------- --- @overload self, cc.Texture2D --- @overload self, string --- @function [parent=#SpritePolygon] setTexture --- @param self --- @param #string filename --- @return experimental::SpritePolygon#experimental::SpritePolygon self (return value: cc.experimental::SpritePolygon) - --------------------------------- --- --- @function [parent=#SpritePolygon] initWithTexture --- @param self --- @param #cc.Texture2D texture --- @return bool#bool ret (return value: bool) - --------------------------------- --- --- @function [parent=#SpritePolygon] showDebug --- @param self --- @param #bool val --- @return experimental::SpritePolygon#experimental::SpritePolygon self (return value: cc.experimental::SpritePolygon) - --------------------------------- --- returns the Texture2D object used by the sprite --- @function [parent=#SpritePolygon] getTexture --- @param self --- @return Texture2D#Texture2D ret (return value: cc.Texture2D) - --------------------------------- --- --- @function [parent=#SpritePolygon] getArea --- @param self --- @return float#float ret (return value: float) - --------------------------------- --- --- @function [parent=#SpritePolygon] initWithCache --- @param self --- @param #string file --- @param #cc._SpritePolygonInfo info --- @return bool#bool ret (return value: bool) - --------------------------------- --- --- @function [parent=#SpritePolygon] getVertCount --- @param self --- @return long#long ret (return value: long) - --------------------------------- --- --- @function [parent=#SpritePolygon] getTrianglesCount --- @param self --- @return long#long ret (return value: long) - -return nil diff --git a/cocos/scripting/lua-bindings/auto/api/SpritePolygonCache.lua b/cocos/scripting/lua-bindings/auto/api/SpritePolygonCache.lua deleted file mode 100644 index ffd1851189..0000000000 --- a/cocos/scripting/lua-bindings/auto/api/SpritePolygonCache.lua +++ /dev/null @@ -1,48 +0,0 @@ - --------------------------------- --- @module SpritePolygonCache --- @extend Ref --- @parent_module cc - --------------------------------- --- --- @function [parent=#SpritePolygonCache] isSpritePolygonCachExist --- @param self --- @param #string filePath --- @param #rect_table rect --- @return bool#bool ret (return value: bool) - --------------------------------- --- --- @function [parent=#SpritePolygonCache] removeAllSpritePolygonCache --- @param self --- @return SpritePolygonCache#SpritePolygonCache self (return value: cc.SpritePolygonCache) - --------------------------------- --- --- @function [parent=#SpritePolygonCache] removeSpritePolygonCache --- @param self --- @param #string filePath --- @param #rect_table rect --- @return SpritePolygonCache#SpritePolygonCache self (return value: cc.SpritePolygonCache) - --------------------------------- --- --- @function [parent=#SpritePolygonCache] destroyInstance --- @param self --- @return SpritePolygonCache#SpritePolygonCache self (return value: cc.SpritePolygonCache) - --------------------------------- --- --- @function [parent=#SpritePolygonCache] printInfo --- @param self --- @param #cc._SpritePolygonInfo info --- @return SpritePolygonCache#SpritePolygonCache self (return value: cc.SpritePolygonCache) - --------------------------------- --- --- @function [parent=#SpritePolygonCache] getInstance --- @param self --- @return SpritePolygonCache#SpritePolygonCache ret (return value: cc.SpritePolygonCache) - -return nil diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua index 892bf26e99..e59c3ca80f 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua @@ -932,13 +932,23 @@ -------------------------------------------------------- --- the cc Sprite --- @field [parent=#cc] Sprite#Sprite Sprite preloaded module +-- the cc Image +-- @field [parent=#cc] Image#Image Image preloaded module -------------------------------------------------------- --- the cc Image --- @field [parent=#cc] Image#Image Image preloaded module +-- the cc PolygonInfo +-- @field [parent=#cc] PolygonInfo#PolygonInfo PolygonInfo preloaded module + + +-------------------------------------------------------- +-- the cc AutoPolygon +-- @field [parent=#cc] AutoPolygon#AutoPolygon AutoPolygon preloaded module + + +-------------------------------------------------------- +-- the cc Sprite +-- @field [parent=#cc] Sprite#Sprite Sprite preloaded module -------------------------------------------------------- @@ -1281,9 +1291,4 @@ -- @field [parent=#cc] Component#Component Component preloaded module --------------------------------------------------------- --- the cc SpritePolygonCache --- @field [parent=#cc] SpritePolygonCache#SpritePolygonCache SpritePolygonCache preloaded module - - return nil diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_experimental_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_experimental_auto_api.lua index d78658478a..56a40c50ac 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_experimental_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_experimental_auto_api.lua @@ -11,9 +11,4 @@ -- @field [parent=#ccexp] TMXTiledMap#TMXTiledMap TMXTiledMap preloaded module --------------------------------------------------------- --- the ccexp SpritePolygon --- @field [parent=#ccexp] SpritePolygon#SpritePolygon SpritePolygon preloaded module - - return nil diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index aeb7908cc3..54a1af7a02 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -2,7 +2,6 @@ #include "cocos2d.h" #include "CCProtectedNode.h" #include "CCAsyncTaskPool.h" -#include "SpritePolygonCache.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" @@ -67675,6 +67674,960 @@ int lua_register_cocos2dx_ProtectedNode(lua_State* tolua_S) return 1; } +int lua_cocos2dx_Image_hasPremultipliedAlpha(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_hasPremultipliedAlpha'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_hasPremultipliedAlpha'", nullptr); + return 0; + } + bool ret = cobj->hasPremultipliedAlpha(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:hasPremultipliedAlpha",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_hasPremultipliedAlpha'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Image_saveToFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_saveToFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Image:saveToFile"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_saveToFile'", nullptr); + return 0; + } + bool ret = cobj->saveToFile(arg0); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + if (argc == 2) + { + std::string arg0; + bool arg1; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Image:saveToFile"); + + ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.Image:saveToFile"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_saveToFile'", nullptr); + return 0; + } + bool ret = cobj->saveToFile(arg0, arg1); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:saveToFile",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_saveToFile'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Image_hasAlpha(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_hasAlpha'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_hasAlpha'", nullptr); + return 0; + } + bool ret = cobj->hasAlpha(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:hasAlpha",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_hasAlpha'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Image_isCompressed(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_isCompressed'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_isCompressed'", nullptr); + return 0; + } + bool ret = cobj->isCompressed(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:isCompressed",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_isCompressed'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Image_getHeight(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getHeight'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getHeight'", nullptr); + return 0; + } + int ret = cobj->getHeight(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getHeight",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getHeight'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Image_initWithImageFile(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_initWithImageFile'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Image:initWithImageFile"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_initWithImageFile'", nullptr); + return 0; + } + bool ret = cobj->initWithImageFile(arg0); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:initWithImageFile",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_initWithImageFile'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Image_getWidth(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getWidth'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getWidth'", nullptr); + return 0; + } + int ret = cobj->getWidth(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getWidth",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getWidth'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Image_getBitPerPixel(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getBitPerPixel'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getBitPerPixel'", nullptr); + return 0; + } + int ret = cobj->getBitPerPixel(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getBitPerPixel",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getBitPerPixel'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Image_getFileType(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getFileType'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getFileType'", nullptr); + return 0; + } + int ret = (int)cobj->getFileType(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getFileType",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getFileType'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Image_getNumberOfMipmaps(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getNumberOfMipmaps'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getNumberOfMipmaps'", nullptr); + return 0; + } + int ret = cobj->getNumberOfMipmaps(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getNumberOfMipmaps",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getNumberOfMipmaps'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Image_getRenderFormat(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getRenderFormat'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getRenderFormat'", nullptr); + return 0; + } + int ret = (int)cobj->getRenderFormat(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getRenderFormat",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getRenderFormat'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + bool arg0; + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Image:setPVRImagesHavePremultipliedAlpha"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha'", nullptr); + return 0; + } + cocos2d::Image::setPVRImagesHavePremultipliedAlpha(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Image:setPVRImagesHavePremultipliedAlpha",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_Image_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Image* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::Image(); + cobj->autorelease(); + int ID = (int)cobj->_ID ; + int* luaID = &cobj->_luaID ; + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Image"); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:Image",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_Image_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (Image)"); + return 0; +} + +int lua_register_cocos2dx_Image(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.Image"); + tolua_cclass(tolua_S,"Image","cc.Image","cc.Ref",nullptr); + + tolua_beginmodule(tolua_S,"Image"); + tolua_function(tolua_S,"new",lua_cocos2dx_Image_constructor); + tolua_function(tolua_S,"hasPremultipliedAlpha",lua_cocos2dx_Image_hasPremultipliedAlpha); + tolua_function(tolua_S,"saveToFile",lua_cocos2dx_Image_saveToFile); + tolua_function(tolua_S,"hasAlpha",lua_cocos2dx_Image_hasAlpha); + tolua_function(tolua_S,"isCompressed",lua_cocos2dx_Image_isCompressed); + tolua_function(tolua_S,"getHeight",lua_cocos2dx_Image_getHeight); + tolua_function(tolua_S,"initWithImageFile",lua_cocos2dx_Image_initWithImageFile); + tolua_function(tolua_S,"getWidth",lua_cocos2dx_Image_getWidth); + tolua_function(tolua_S,"getBitPerPixel",lua_cocos2dx_Image_getBitPerPixel); + tolua_function(tolua_S,"getFileType",lua_cocos2dx_Image_getFileType); + tolua_function(tolua_S,"getNumberOfMipmaps",lua_cocos2dx_Image_getNumberOfMipmaps); + tolua_function(tolua_S,"getRenderFormat",lua_cocos2dx_Image_getRenderFormat); + tolua_function(tolua_S,"setPVRImagesHavePremultipliedAlpha", lua_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::Image).name(); + g_luaType[typeName] = "cc.Image"; + g_typeCast["Image"] = "cc.Image"; + return 1; +} + +int lua_cocos2dx_PolygonInfo_getArea(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PolygonInfo* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.PolygonInfo",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PolygonInfo*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_PolygonInfo_getArea'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_PolygonInfo_getArea'", nullptr); + return 0; + } + const float ret = cobj->getArea(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PolygonInfo:getArea",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_PolygonInfo_getArea'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_PolygonInfo_getTriaglesCount(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PolygonInfo* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.PolygonInfo",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PolygonInfo*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_PolygonInfo_getTriaglesCount'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_PolygonInfo_getTriaglesCount'", nullptr); + return 0; + } + const unsigned int ret = cobj->getTriaglesCount(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PolygonInfo:getTriaglesCount",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_PolygonInfo_getTriaglesCount'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_PolygonInfo_getVertCount(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PolygonInfo* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.PolygonInfo",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PolygonInfo*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_PolygonInfo_getVertCount'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_PolygonInfo_getVertCount'", nullptr); + return 0; + } + const unsigned int ret = cobj->getVertCount(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PolygonInfo:getVertCount",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_PolygonInfo_getVertCount'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_PolygonInfo_setQuad(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PolygonInfo* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.PolygonInfo",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PolygonInfo*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_PolygonInfo_setQuad'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::V3F_C4B_T2F_Quad* arg0; + + #pragma warning NO CONVERSION TO NATIVE FOR V3F_C4B_T2F_Quad* + ok = false; + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_PolygonInfo_setQuad'", nullptr); + return 0; + } + cobj->setQuad(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PolygonInfo:setQuad",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_PolygonInfo_setQuad'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_PolygonInfo_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PolygonInfo* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_PolygonInfo_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::PolygonInfo(); + tolua_pushusertype(tolua_S,(void*)cobj,"cc.PolygonInfo"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.PolygonInfo:PolygonInfo",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_PolygonInfo_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_PolygonInfo_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (PolygonInfo)"); + return 0; +} + +int lua_register_cocos2dx_PolygonInfo(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.PolygonInfo"); + tolua_cclass(tolua_S,"PolygonInfo","cc.PolygonInfo","",nullptr); + + tolua_beginmodule(tolua_S,"PolygonInfo"); + tolua_function(tolua_S,"new",lua_cocos2dx_PolygonInfo_constructor); + tolua_function(tolua_S,"getArea",lua_cocos2dx_PolygonInfo_getArea); + tolua_function(tolua_S,"getTriaglesCount",lua_cocos2dx_PolygonInfo_getTriaglesCount); + tolua_function(tolua_S,"getVertCount",lua_cocos2dx_PolygonInfo_getVertCount); + tolua_function(tolua_S,"setQuad",lua_cocos2dx_PolygonInfo_setQuad); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::PolygonInfo).name(); + g_luaType[typeName] = "cc.PolygonInfo"; + g_typeCast["PolygonInfo"] = "cc.PolygonInfo"; + return 1; +} + +int lua_cocos2dx_AutoPolygon_constructor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::AutoPolygon* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AutoPolygon:AutoPolygon"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AutoPolygon_constructor'", nullptr); + return 0; + } + cobj = new cocos2d::AutoPolygon(arg0); + tolua_pushusertype(tolua_S,(void*)cobj,"cc.AutoPolygon"); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AutoPolygon:AutoPolygon",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AutoPolygon_constructor'.",&tolua_err); +#endif + + return 0; +} + +static int lua_cocos2dx_AutoPolygon_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (AutoPolygon)"); + return 0; +} + +int lua_register_cocos2dx_AutoPolygon(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.AutoPolygon"); + tolua_cclass(tolua_S,"AutoPolygon","cc.AutoPolygon","",nullptr); + + tolua_beginmodule(tolua_S,"AutoPolygon"); + tolua_function(tolua_S,"new",lua_cocos2dx_AutoPolygon_constructor); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::AutoPolygon).name(); + g_luaType[typeName] = "cc.AutoPolygon"; + g_typeCast["AutoPolygon"] = "cc.AutoPolygon"; + return 1; +} + int lua_cocos2dx_Sprite_setSpriteFrame(lua_State* tolua_S) { int argc = 0; @@ -68853,6 +69806,56 @@ int lua_cocos2dx_Sprite_getTextureRect(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Sprite_debugDraw(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_debugDraw'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + bool arg0; + + ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Sprite:debugDraw"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Sprite_debugDraw'", nullptr); + return 0; + } + cobj->debugDraw(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite:debugDraw",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_debugDraw'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Sprite_initWithFile(lua_State* tolua_S) { int argc = 0; @@ -69203,209 +70206,6 @@ int lua_cocos2dx_Sprite_setVertexRect(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Sprite_create(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S)-1; - - do - { - if (argc == 1) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite:create"); - if (!ok) { break; } - cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0); - object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 0) - { - cocos2d::Sprite* ret = cocos2d::Sprite::create(); - object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 2) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite:create"); - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Sprite:create"); - if (!ok) { break; } - cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0, arg1); - object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); - return 1; - } - } while (0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite:create",argc, 2); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_create'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_Sprite_createWithTexture(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S)-1; - - do - { - if (argc == 2) - { - cocos2d::Texture2D* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.Sprite:createWithTexture"); - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Sprite:createWithTexture"); - if (!ok) { break; } - cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1); - object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 3) - { - cocos2d::Texture2D* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.Sprite:createWithTexture"); - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Sprite:createWithTexture"); - if (!ok) { break; } - bool arg2; - ok &= luaval_to_boolean(tolua_S, 4,&arg2, "cc.Sprite:createWithTexture"); - if (!ok) { break; } - cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0, arg1, arg2); - object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 1) - { - cocos2d::Texture2D* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "cc.Sprite:createWithTexture"); - if (!ok) { break; } - cocos2d::Sprite* ret = cocos2d::Sprite::createWithTexture(arg0); - object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); - return 1; - } - } while (0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite:createWithTexture",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_createWithTexture'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_Sprite_createWithSpriteFrameName(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 1) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite:createWithSpriteFrameName"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Sprite_createWithSpriteFrameName'", nullptr); - return 0; - } - cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrameName(arg0); - object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite:createWithSpriteFrameName",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_createWithSpriteFrameName'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_Sprite_createWithSpriteFrame(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 1) - { - cocos2d::SpriteFrame* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.SpriteFrame",&arg0, "cc.Sprite:createWithSpriteFrame"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Sprite_createWithSpriteFrame'", nullptr); - return 0; - } - cocos2d::Sprite* ret = cocos2d::Sprite::createWithSpriteFrame(arg0); - object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite:createWithSpriteFrame",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_createWithSpriteFrame'.",&tolua_err); -#endif - return 0; -} int lua_cocos2dx_Sprite_constructor(lua_State* tolua_S) { int argc = 0; @@ -69479,6 +70279,7 @@ int lua_register_cocos2dx_Sprite(lua_State* tolua_S) tolua_function(tolua_S,"setDirty",lua_cocos2dx_Sprite_setDirty); tolua_function(tolua_S,"isTextureRectRotated",lua_cocos2dx_Sprite_isTextureRectRotated); tolua_function(tolua_S,"getTextureRect",lua_cocos2dx_Sprite_getTextureRect); + tolua_function(tolua_S,"debugDraw",lua_cocos2dx_Sprite_debugDraw); tolua_function(tolua_S,"initWithFile",lua_cocos2dx_Sprite_initWithFile); tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_Sprite_setBlendFunc); tolua_function(tolua_S,"getTextureAtlas",lua_cocos2dx_Sprite_getTextureAtlas); @@ -69486,10 +70287,6 @@ int lua_register_cocos2dx_Sprite(lua_State* tolua_S) tolua_function(tolua_S,"isFlippedX",lua_cocos2dx_Sprite_isFlippedX); tolua_function(tolua_S,"isFlippedY",lua_cocos2dx_Sprite_isFlippedY); tolua_function(tolua_S,"setVertexRect",lua_cocos2dx_Sprite_setVertexRect); - tolua_function(tolua_S,"create", lua_cocos2dx_Sprite_create); - tolua_function(tolua_S,"createWithTexture", lua_cocos2dx_Sprite_createWithTexture); - tolua_function(tolua_S,"createWithSpriteFrameName", lua_cocos2dx_Sprite_createWithSpriteFrameName); - tolua_function(tolua_S,"createWithSpriteFrame", lua_cocos2dx_Sprite_createWithSpriteFrame); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Sprite).name(); g_luaType[typeName] = "cc.Sprite"; @@ -69497,651 +70294,6 @@ int lua_register_cocos2dx_Sprite(lua_State* tolua_S) return 1; } -int lua_cocos2dx_Image_hasPremultipliedAlpha(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_hasPremultipliedAlpha'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_hasPremultipliedAlpha'", nullptr); - return 0; - } - bool ret = cobj->hasPremultipliedAlpha(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:hasPremultipliedAlpha",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_hasPremultipliedAlpha'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Image_saveToFile(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_saveToFile'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Image:saveToFile"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_saveToFile'", nullptr); - return 0; - } - bool ret = cobj->saveToFile(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - if (argc == 2) - { - std::string arg0; - bool arg1; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Image:saveToFile"); - - ok &= luaval_to_boolean(tolua_S, 3,&arg1, "cc.Image:saveToFile"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_saveToFile'", nullptr); - return 0; - } - bool ret = cobj->saveToFile(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:saveToFile",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_saveToFile'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Image_hasAlpha(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_hasAlpha'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_hasAlpha'", nullptr); - return 0; - } - bool ret = cobj->hasAlpha(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:hasAlpha",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_hasAlpha'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Image_isCompressed(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_isCompressed'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_isCompressed'", nullptr); - return 0; - } - bool ret = cobj->isCompressed(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:isCompressed",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_isCompressed'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Image_getHeight(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getHeight'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getHeight'", nullptr); - return 0; - } - int ret = cobj->getHeight(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getHeight",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getHeight'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Image_initWithImageFile(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_initWithImageFile'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Image:initWithImageFile"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_initWithImageFile'", nullptr); - return 0; - } - bool ret = cobj->initWithImageFile(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:initWithImageFile",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_initWithImageFile'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Image_getWidth(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getWidth'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getWidth'", nullptr); - return 0; - } - int ret = cobj->getWidth(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getWidth",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getWidth'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Image_getBitPerPixel(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getBitPerPixel'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getBitPerPixel'", nullptr); - return 0; - } - int ret = cobj->getBitPerPixel(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getBitPerPixel",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getBitPerPixel'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Image_getFileType(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getFileType'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getFileType'", nullptr); - return 0; - } - int ret = (int)cobj->getFileType(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getFileType",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getFileType'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Image_getNumberOfMipmaps(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getNumberOfMipmaps'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getNumberOfMipmaps'", nullptr); - return 0; - } - int ret = cobj->getNumberOfMipmaps(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getNumberOfMipmaps",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getNumberOfMipmaps'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Image_getRenderFormat(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Image*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Image_getRenderFormat'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_getRenderFormat'", nullptr); - return 0; - } - int ret = (int)cobj->getRenderFormat(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:getRenderFormat",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_getRenderFormat'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Image",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 1) - { - bool arg0; - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Image:setPVRImagesHavePremultipliedAlpha"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha'", nullptr); - return 0; - } - cocos2d::Image::setPVRImagesHavePremultipliedAlpha(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Image:setPVRImagesHavePremultipliedAlpha",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_Image_constructor(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Image* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Image_constructor'", nullptr); - return 0; - } - cobj = new cocos2d::Image(); - cobj->autorelease(); - int ID = (int)cobj->_ID ; - int* luaID = &cobj->_luaID ; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.Image"); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Image:Image",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Image_constructor'.",&tolua_err); -#endif - - return 0; -} - -static int lua_cocos2dx_Image_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (Image)"); - return 0; -} - -int lua_register_cocos2dx_Image(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.Image"); - tolua_cclass(tolua_S,"Image","cc.Image","cc.Ref",nullptr); - - tolua_beginmodule(tolua_S,"Image"); - tolua_function(tolua_S,"new",lua_cocos2dx_Image_constructor); - tolua_function(tolua_S,"hasPremultipliedAlpha",lua_cocos2dx_Image_hasPremultipliedAlpha); - tolua_function(tolua_S,"saveToFile",lua_cocos2dx_Image_saveToFile); - tolua_function(tolua_S,"hasAlpha",lua_cocos2dx_Image_hasAlpha); - tolua_function(tolua_S,"isCompressed",lua_cocos2dx_Image_isCompressed); - tolua_function(tolua_S,"getHeight",lua_cocos2dx_Image_getHeight); - tolua_function(tolua_S,"initWithImageFile",lua_cocos2dx_Image_initWithImageFile); - tolua_function(tolua_S,"getWidth",lua_cocos2dx_Image_getWidth); - tolua_function(tolua_S,"getBitPerPixel",lua_cocos2dx_Image_getBitPerPixel); - tolua_function(tolua_S,"getFileType",lua_cocos2dx_Image_getFileType); - tolua_function(tolua_S,"getNumberOfMipmaps",lua_cocos2dx_Image_getNumberOfMipmaps); - tolua_function(tolua_S,"getRenderFormat",lua_cocos2dx_Image_getRenderFormat); - tolua_function(tolua_S,"setPVRImagesHavePremultipliedAlpha", lua_cocos2dx_Image_setPVRImagesHavePremultipliedAlpha); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::Image).name(); - g_luaType[typeName] = "cc.Image"; - g_typeCast["Image"] = "cc.Image"; - return 1; -} - int lua_cocos2dx_RenderTexture_setVirtualViewport(lua_State* tolua_S) { int argc = 0; @@ -91952,303 +92104,6 @@ int lua_register_cocos2dx_Component(lua_State* tolua_S) g_typeCast["Component"] = "cc.Component"; return 1; } - -int lua_cocos2dx_SpritePolygonCache_isSpritePolygonCachExist(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::SpritePolygonCache* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.SpritePolygonCache",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::SpritePolygonCache*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpritePolygonCache_isSpritePolygonCachExist'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - std::string arg0; - cocos2d::Rect arg1; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.SpritePolygonCache:isSpritePolygonCachExist"); - - ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.SpritePolygonCache:isSpritePolygonCachExist"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_SpritePolygonCache_isSpritePolygonCachExist'", nullptr); - return 0; - } - bool ret = cobj->isSpritePolygonCachExist(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.SpritePolygonCache:isSpritePolygonCachExist",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpritePolygonCache_isSpritePolygonCachExist'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_SpritePolygonCache_removeAllSpritePolygonCache(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::SpritePolygonCache* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.SpritePolygonCache",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::SpritePolygonCache*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpritePolygonCache_removeAllSpritePolygonCache'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_SpritePolygonCache_removeAllSpritePolygonCache'", nullptr); - return 0; - } - cobj->removeAllSpritePolygonCache(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.SpritePolygonCache:removeAllSpritePolygonCache",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpritePolygonCache_removeAllSpritePolygonCache'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_SpritePolygonCache_removeSpritePolygonCache(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::SpritePolygonCache* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.SpritePolygonCache",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::SpritePolygonCache*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_SpritePolygonCache_removeSpritePolygonCache'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - std::string arg0; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.SpritePolygonCache:removeSpritePolygonCache"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_SpritePolygonCache_removeSpritePolygonCache'", nullptr); - return 0; - } - cobj->removeSpritePolygonCache(arg0); - lua_settop(tolua_S, 1); - return 1; - } - if (argc == 2) - { - std::string arg0; - const cocos2d::Rect* arg1; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.SpritePolygonCache:removeSpritePolygonCache"); - - ok &= luaval_to_object(tolua_S, 3, "cc.Rect",&arg1, "cc.SpritePolygonCache:removeSpritePolygonCache"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_SpritePolygonCache_removeSpritePolygonCache'", nullptr); - return 0; - } - cobj->removeSpritePolygonCache(arg0, arg1); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.SpritePolygonCache:removeSpritePolygonCache",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpritePolygonCache_removeSpritePolygonCache'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_SpritePolygonCache_destroyInstance(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.SpritePolygonCache",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_SpritePolygonCache_destroyInstance'", nullptr); - return 0; - } - cocos2d::SpritePolygonCache::destroyInstance(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.SpritePolygonCache:destroyInstance",argc, 0); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpritePolygonCache_destroyInstance'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_SpritePolygonCache_printInfo(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.SpritePolygonCache",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 1) - { - cocos2d::_SpritePolygonInfo arg0; - #pragma warning NO CONVERSION TO NATIVE FOR _SpritePolygonInfo - ok = false; - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_SpritePolygonCache_printInfo'", nullptr); - return 0; - } - cocos2d::SpritePolygonCache::printInfo(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.SpritePolygonCache:printInfo",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpritePolygonCache_printInfo'.",&tolua_err); -#endif - return 0; -} -int lua_cocos2dx_SpritePolygonCache_getInstance(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.SpritePolygonCache",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_SpritePolygonCache_getInstance'", nullptr); - return 0; - } - cocos2d::SpritePolygonCache* ret = cocos2d::SpritePolygonCache::getInstance(); - object_to_luaval(tolua_S, "cc.SpritePolygonCache",(cocos2d::SpritePolygonCache*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.SpritePolygonCache:getInstance",argc, 0); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpritePolygonCache_getInstance'.",&tolua_err); -#endif - return 0; -} -static int lua_cocos2dx_SpritePolygonCache_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (SpritePolygonCache)"); - return 0; -} - -int lua_register_cocos2dx_SpritePolygonCache(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"cc.SpritePolygonCache"); - tolua_cclass(tolua_S,"SpritePolygonCache","cc.SpritePolygonCache","cc.Ref",nullptr); - - tolua_beginmodule(tolua_S,"SpritePolygonCache"); - tolua_function(tolua_S,"isSpritePolygonCachExist",lua_cocos2dx_SpritePolygonCache_isSpritePolygonCachExist); - tolua_function(tolua_S,"removeAllSpritePolygonCache",lua_cocos2dx_SpritePolygonCache_removeAllSpritePolygonCache); - tolua_function(tolua_S,"removeSpritePolygonCache",lua_cocos2dx_SpritePolygonCache_removeSpritePolygonCache); - tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_SpritePolygonCache_destroyInstance); - tolua_function(tolua_S,"printInfo", lua_cocos2dx_SpritePolygonCache_printInfo); - tolua_function(tolua_S,"getInstance", lua_cocos2dx_SpritePolygonCache_getInstance); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::SpritePolygonCache).name(); - g_luaType[typeName] = "cc.SpritePolygonCache"; - g_typeCast["SpritePolygonCache"] = "cc.SpritePolygonCache"; - return 1; -} TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) { tolua_open(tolua_S); @@ -92354,6 +92209,7 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_Application(tolua_S); lua_register_cocos2dx_DelayTime(tolua_S); lua_register_cocos2dx_LabelAtlas(tolua_S); + lua_register_cocos2dx_TMXLayer(tolua_S); lua_register_cocos2dx_AsyncTaskPool(tolua_S); lua_register_cocos2dx_ParticleSnow(tolua_S); lua_register_cocos2dx_EaseElasticIn(tolua_S); @@ -92368,7 +92224,7 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_ParticleSun(tolua_S); lua_register_cocos2dx_TransitionProgressHorizontal(tolua_S); lua_register_cocos2dx_TMXObjectGroup(tolua_S); - lua_register_cocos2dx_TMXLayer(tolua_S); + lua_register_cocos2dx_AutoPolygon(tolua_S); lua_register_cocos2dx_FlipX(tolua_S); lua_register_cocos2dx_FlipY(tolua_S); lua_register_cocos2dx_EventKeyboard(tolua_S); @@ -92448,10 +92304,10 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_EaseQuarticActionInOut(tolua_S); lua_register_cocos2dx_ShakyTiles3D(tolua_S); lua_register_cocos2dx_PageTurn3D(tolua_S); + lua_register_cocos2dx_PolygonInfo(tolua_S); lua_register_cocos2dx_TransitionSlideInL(tolua_S); lua_register_cocos2dx_TransitionSlideInT(tolua_S); lua_register_cocos2dx_Grid3D(tolua_S); - lua_register_cocos2dx_SpritePolygonCache(tolua_S); lua_register_cocos2dx_EaseCircleActionOut(tolua_S); lua_register_cocos2dx_TransitionProgressInOut(tolua_S); lua_register_cocos2dx_EaseCubicActionInOut(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 1e4d4890e0..5bf82ddefb 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2056,8 +2056,6 @@ int register_all_cocos2dx(lua_State* tolua_S); - - diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.cpp index 0a80669d0e..5645e1fef7 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.cpp @@ -1,7 +1,6 @@ #include "lua_cocos2dx_experimental_auto.hpp" #include "CCFastTMXLayer.h" #include "CCFastTMXTiledMap.h" -#include "SpritePolygon.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" @@ -1869,430 +1868,6 @@ int lua_register_cocos2dx_experimental_TMXTiledMap(lua_State* tolua_S) g_typeCast["TMXTiledMap"] = "ccexp.TMXTiledMap"; return 1; } - -int lua_cocos2dx_experimental_SpritePolygon_setTexture(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::SpritePolygon* cobj = nullptr; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.SpritePolygon",0,&tolua_err)) goto tolua_lerror; -#endif - cobj = (cocos2d::experimental::SpritePolygon*)tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_SpritePolygon_setTexture'", nullptr); - return 0; - } -#endif - argc = lua_gettop(tolua_S)-1; - do{ - if (argc == 1) { - cocos2d::Texture2D* arg0; - ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "ccexp.SpritePolygon:setTexture"); - - if (!ok) { break; } - cobj->setTexture(arg0); - lua_settop(tolua_S, 1); - return 1; - } - }while(0); - ok = true; - do{ - if (argc == 1) { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.SpritePolygon:setTexture"); - - if (!ok) { break; } - cobj->setTexture(arg0); - lua_settop(tolua_S, 1); - return 1; - } - }while(0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.SpritePolygon:setTexture",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_SpritePolygon_setTexture'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_SpritePolygon_initWithTexture(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::SpritePolygon* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.SpritePolygon",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::SpritePolygon*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_SpritePolygon_initWithTexture'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Texture2D* arg0; - - ok &= luaval_to_object(tolua_S, 2, "cc.Texture2D",&arg0, "ccexp.SpritePolygon:initWithTexture"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_SpritePolygon_initWithTexture'", nullptr); - return 0; - } - bool ret = cobj->initWithTexture(arg0); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.SpritePolygon:initWithTexture",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_SpritePolygon_initWithTexture'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_SpritePolygon_showDebug(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::SpritePolygon* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.SpritePolygon",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::SpritePolygon*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_SpritePolygon_showDebug'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccexp.SpritePolygon:showDebug"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_SpritePolygon_showDebug'", nullptr); - return 0; - } - cobj->showDebug(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.SpritePolygon:showDebug",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_SpritePolygon_showDebug'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_SpritePolygon_getTexture(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::SpritePolygon* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.SpritePolygon",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::SpritePolygon*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_SpritePolygon_getTexture'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_SpritePolygon_getTexture'", nullptr); - return 0; - } - cocos2d::Texture2D* ret = cobj->getTexture(); - object_to_luaval(tolua_S, "cc.Texture2D",(cocos2d::Texture2D*)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.SpritePolygon:getTexture",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_SpritePolygon_getTexture'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_SpritePolygon_getArea(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::SpritePolygon* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.SpritePolygon",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::SpritePolygon*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_SpritePolygon_getArea'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_SpritePolygon_getArea'", nullptr); - return 0; - } - const float ret = cobj->getArea(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.SpritePolygon:getArea",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_SpritePolygon_getArea'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_SpritePolygon_initWithCache(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::SpritePolygon* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.SpritePolygon",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::SpritePolygon*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_SpritePolygon_initWithCache'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 2) - { - std::string arg0; - cocos2d::_SpritePolygonInfo* arg1; - - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.SpritePolygon:initWithCache"); - - #pragma warning NO CONVERSION TO NATIVE FOR _SpritePolygonInfo* - ok = false; - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_SpritePolygon_initWithCache'", nullptr); - return 0; - } - bool ret = cobj->initWithCache(arg0, arg1); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.SpritePolygon:initWithCache",argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_SpritePolygon_initWithCache'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_SpritePolygon_getVertCount(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::SpritePolygon* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.SpritePolygon",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::SpritePolygon*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_SpritePolygon_getVertCount'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_SpritePolygon_getVertCount'", nullptr); - return 0; - } - const ssize_t ret = cobj->getVertCount(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.SpritePolygon:getVertCount",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_SpritePolygon_getVertCount'.",&tolua_err); -#endif - - return 0; -} -int lua_cocos2dx_experimental_SpritePolygon_getTrianglesCount(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::experimental::SpritePolygon* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccexp.SpritePolygon",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::experimental::SpritePolygon*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_SpritePolygon_getTrianglesCount'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_SpritePolygon_getTrianglesCount'", nullptr); - return 0; - } - const ssize_t ret = cobj->getTrianglesCount(); - tolua_pushnumber(tolua_S,(lua_Number)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.SpritePolygon:getTrianglesCount",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_SpritePolygon_getTrianglesCount'.",&tolua_err); -#endif - - return 0; -} -static int lua_cocos2dx_experimental_SpritePolygon_finalize(lua_State* tolua_S) -{ - printf("luabindings: finalizing LUA object (SpritePolygon)"); - return 0; -} - -int lua_register_cocos2dx_experimental_SpritePolygon(lua_State* tolua_S) -{ - tolua_usertype(tolua_S,"ccexp.SpritePolygon"); - tolua_cclass(tolua_S,"SpritePolygon","ccexp.SpritePolygon","cc.Node",nullptr); - - tolua_beginmodule(tolua_S,"SpritePolygon"); - tolua_function(tolua_S,"setTexture",lua_cocos2dx_experimental_SpritePolygon_setTexture); - tolua_function(tolua_S,"initWithTexture",lua_cocos2dx_experimental_SpritePolygon_initWithTexture); - tolua_function(tolua_S,"showDebug",lua_cocos2dx_experimental_SpritePolygon_showDebug); - tolua_function(tolua_S,"getTexture",lua_cocos2dx_experimental_SpritePolygon_getTexture); - tolua_function(tolua_S,"getArea",lua_cocos2dx_experimental_SpritePolygon_getArea); - tolua_function(tolua_S,"initWithCache",lua_cocos2dx_experimental_SpritePolygon_initWithCache); - tolua_function(tolua_S,"getVertCount",lua_cocos2dx_experimental_SpritePolygon_getVertCount); - tolua_function(tolua_S,"getTrianglesCount",lua_cocos2dx_experimental_SpritePolygon_getTrianglesCount); - tolua_endmodule(tolua_S); - std::string typeName = typeid(cocos2d::experimental::SpritePolygon).name(); - g_luaType[typeName] = "ccexp.SpritePolygon"; - g_typeCast["SpritePolygon"] = "ccexp.SpritePolygon"; - return 1; -} TOLUA_API int register_all_cocos2dx_experimental(lua_State* tolua_S) { tolua_open(tolua_S); @@ -2301,7 +1876,6 @@ TOLUA_API int register_all_cocos2dx_experimental(lua_State* tolua_S) tolua_beginmodule(tolua_S,"ccexp"); lua_register_cocos2dx_experimental_TMXTiledMap(tolua_S); - lua_register_cocos2dx_experimental_SpritePolygon(tolua_S); lua_register_cocos2dx_experimental_TMXLayer(tolua_S); tolua_endmodule(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.hpp index 1043d5d1dc..1510f395f7 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.hpp @@ -41,15 +41,6 @@ int register_all_cocos2dx_experimental(lua_State* tolua_S); - - - - - - - - - diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.cpp index 61fa4a9fdd..166d969ab2 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.cpp @@ -3,7 +3,6 @@ #include "LuaBasicConversions.h" #include "CCLuaValue.h" #include "CCLuaEngine.h" -#include "2d/SpritePolygon.h" static int lua_cocos2dx_experimental_TMXLayer_getTileGIDAt(lua_State* tolua_S) { @@ -112,206 +111,12 @@ bool isVectorV3FC4BT2F(lua_State* tolua_S, int lo) return true; } -int lua_cocos2dx_experimental_SpritePolygon_create(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"ccexp.SpritePolygon",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S)-1; - - do - { - if (argc == 3) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - - std::vector arg1; - if (isVectorV3FC4BT2F(tolua_S, 3)) - break; - ok &= luaval_to_std_vector_vec2(tolua_S, 3, &arg1); - if (!ok) { break; } - - std::vector arg2; - ok &= luaval_to_std_vector_ushort(tolua_S, 4, &arg2, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - cocos2d::experimental::SpritePolygon* ret = cocos2d::experimental::SpritePolygon::create(arg0, arg1, arg2); - object_to_luaval(tolua_S, "ccexp.SpritePolygon",(cocos2d::experimental::SpritePolygon*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 4) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - - std::vector arg1; - ok &= luaval_to_std_vector_vec2(tolua_S, 3, &arg1); - if (!ok) { break; } - - std::vector arg2; - ok &= luaval_to_std_vector_ushort(tolua_S, 4, &arg2, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - cocos2d::Rect arg3; - ok &= luaval_to_rect(tolua_S, 5, &arg3, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - cocos2d::experimental::SpritePolygon* ret = cocos2d::experimental::SpritePolygon::create(arg0, arg1, arg2, arg3); - object_to_luaval(tolua_S, "ccexp.SpritePolygon",(cocos2d::experimental::SpritePolygon*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 3) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - - std::vector arg1; - if (!isVectorV3FC4BT2F(tolua_S, 3)) - break; - ok &= luaval_to_std_vector_v3f_c4b_t2f(tolua_S, 3, &arg1); - if (!ok) { break; } - - std::vector arg2; - ok &= luaval_to_std_vector_ushort(tolua_S, 4, &arg2, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - cocos2d::experimental::SpritePolygon* ret = cocos2d::experimental::SpritePolygon::create(arg0, arg1, arg2); - object_to_luaval(tolua_S, "ccexp.SpritePolygon",(cocos2d::experimental::SpritePolygon*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 2) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - - std::vector arg1; - ok &= luaval_to_std_vector_vec2(tolua_S, 3, &arg1); - if (!ok) { break; } - - cocos2d::experimental::SpritePolygon* ret = cocos2d::experimental::SpritePolygon::create(arg0, arg1); - object_to_luaval(tolua_S, "ccexp.SpritePolygon",(cocos2d::experimental::SpritePolygon*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 3) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - - std::vector arg1; - if (isVectorV3FC4BT2F(tolua_S, 3)) - break; - ok &= luaval_to_std_vector_vec2(tolua_S, 3, &arg1); - if (!ok) { break; } - - cocos2d::Rect arg2; - ok &= luaval_to_rect(tolua_S, 4, &arg2, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - cocos2d::experimental::SpritePolygon* ret = cocos2d::experimental::SpritePolygon::create(arg0, arg1, arg2); - object_to_luaval(tolua_S, "ccexp.SpritePolygon",(cocos2d::experimental::SpritePolygon*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 1) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - cocos2d::experimental::SpritePolygon* ret = cocos2d::experimental::SpritePolygon::create(arg0); - object_to_luaval(tolua_S, "ccexp.SpritePolygon",(cocos2d::experimental::SpritePolygon*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 2) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - cocos2d::experimental::SpritePolygon* ret = cocos2d::experimental::SpritePolygon::create(arg0, arg1); - object_to_luaval(tolua_S, "ccexp.SpritePolygon",(cocos2d::experimental::SpritePolygon*)ret); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 3) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - cocos2d::Rect arg1; - ok &= luaval_to_rect(tolua_S, 3, &arg1, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - double arg2; - ok &= luaval_to_number(tolua_S, 4,&arg2, "ccexp.SpritePolygon:create"); - if (!ok) { break; } - cocos2d::experimental::SpritePolygon* ret = cocos2d::experimental::SpritePolygon::create(arg0, arg1, arg2); - object_to_luaval(tolua_S, "ccexp.SpritePolygon",(cocos2d::experimental::SpritePolygon*)ret); - return 1; - } - } while (0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "ccexp.SpritePolygon:create",argc, 1); - return 0; -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_SpritePolygon_create'.",&tolua_err); -#endif - return 0; -} - -static void extendExperimentalSpritePolygon(lua_State* tolua_S) -{ - lua_pushstring(tolua_S, "ccexp.SpritePolygon"); - lua_rawget(tolua_S, LUA_REGISTRYINDEX); - if (lua_istable(tolua_S,-1)) - { - tolua_function(tolua_S, "create", lua_cocos2dx_experimental_SpritePolygon_create); - } - lua_pop(tolua_S, 1); -} - int register_all_cocos2dx_experimental_manual(lua_State* L) { if (nullptr == L) return 0; extendExperimentalTMXLayer(L); - extendExperimentalSpritePolygon(L); return 0; } diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp index abf67858bd..96ade969f9 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -5296,15 +5296,191 @@ static void extendDrawNode(lua_State* tolua_S) lua_pop(tolua_S, 1); } +int lua_cocos2dx_Sprite_initWithPolygon(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_initWithPolygon'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::PolygonInfo* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.PolygonInfo",&arg0, "cc.Sprite:initWithPolygon"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Sprite_initWithPolygon'", nullptr); + return 0; + } + bool ret = cobj->initWithPolygon(*arg0); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite:initWithPolygon",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_initWithPolygon'.",&tolua_err); +#endif + return 0; +} + +int lua_cocos2dx_Sprite_setPolygonInfo(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Sprite_setPolygonInfo'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::PolygonInfo* arg0; + + ok &= luaval_to_object(tolua_S, 2, "cc.PolygonInfo",&arg0, "cc.Sprite:setPolygonInfo"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Sprite_setPolygonInfo'", nullptr); + return 0; + } + cobj->setPolygonInfo(*arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite:setPolygonInfo",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_setPolygonInfo'.",&tolua_err); +#endif + return 0; +} + +int lua_cocos2dx_Sprite_create(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Sprite",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S)-1; + + do + { + if (argc == 1) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite:create"); + if (!ok) { break; } + cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 0) + { + cocos2d::Sprite* ret = cocos2d::Sprite::create(); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 1) + { + cocos2d::PolygonInfo* arg0; + ok &= luaval_to_object(tolua_S, 2, "cc.PolygonInfo",&arg0, "cc.Sprite:create"); + if (!ok) { break; } + cocos2d::Sprite* ret = cocos2d::Sprite::create(*arg0); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 2) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite:create"); + if (!ok) { break; } + cocos2d::Rect arg1; + ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.Sprite:create"); + if (!ok) { break; } + cocos2d::Sprite* ret = cocos2d::Sprite::create(arg0, arg1); + object_to_luaval(tolua_S, "cc.Sprite",(cocos2d::Sprite*)ret); + return 1; + } + } while (0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite:create",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Sprite_create'.",&tolua_err); +#endif + return 0; +} + static void extendSprite(lua_State* tolua_S) { lua_pushstring(tolua_S,"cc.Sprite"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { - lua_pushstring(tolua_S,"setBlendFunc"); - lua_pushcfunction(tolua_S,tolua_cocos2dx_Sprite_setBlendFunc01); - lua_rawset(tolua_S,-3); + tolua_function(tolua_S, "setBlendFunc", tolua_cocos2dx_Sprite_setBlendFunc01); + tolua_function(tolua_S, "initWithPolygon", lua_cocos2dx_Sprite_initWithPolygon); + tolua_function(tolua_S, "setPolygonInfo", lua_cocos2dx_Sprite_setPolygonInfo); + tolua_function(tolua_S, "create", lua_cocos2dx_Sprite_create); } lua_pop(tolua_S, 1); } @@ -7733,6 +7909,279 @@ static void extendProperties(lua_State* tolua_S) lua_pop(tolua_S, 1); } +int lua_cocos2dx_get_PolygonInfo_rect(lua_State* tolua_S) +{ + cocos2d::PolygonInfo* cobj = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"cc.PolygonInfo",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PolygonInfo*) tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == cobj) + { + tolua_error(tolua_S,"invalid 'self' in function 'lua_cocos2dx_get_PolygonInfo_rect'\n", nullptr); + return 0; + } +#endif + rect_to_luaval(tolua_S, cobj->rect); + return 1; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_get_PolygonInfo_rect'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_set_PolygonInfo_rect(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PolygonInfo* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"cc.PolygonInfo",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::PolygonInfo*) tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'lua_cocos2dx_set_PolygonInfo_rect'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(tolua_S, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + luaval_to_rect(tolua_S, 2, &self->rect); + return 0; + } + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_set_PolygonInfo_rect'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_get_PolygonInfo_filename(lua_State* tolua_S) +{ + cocos2d::PolygonInfo* cobj = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"cc.PolygonInfo",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PolygonInfo*) tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == cobj) + { + tolua_error(tolua_S,"invalid 'self' in function 'lua_cocos2dx_get_PolygonInfo_filename'\n", nullptr); + return 0; + } +#endif + tolua_pushcppstring(tolua_S, cobj->filename); + return 1; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_get_PolygonInfo_filename'.",&tolua_err); + return 0; +#endif +} + +int lua_cocos2dx_set_PolygonInfo_filename(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PolygonInfo* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"cc.PolygonInfo",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (cocos2d::PolygonInfo*) tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'lua_cocos2dx_set_PolygonInfo_filename'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (1 == argc) + { + luaval_to_std_string(tolua_S, 2, &self->filename); + return 0; + } + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_set_PolygonInfo_filename'.",&tolua_err); + return 0; +#endif +} + +static int lua_collect_PolygonInfo (lua_State* tolua_S) +{ + cocos2d::PolygonInfo* self = (cocos2d::PolygonInfo*) tolua_tousertype(tolua_S,1,0); + CC_SAFE_DELETE(self); + return 0; +} + +static void extendPolygonInfo(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "cc.PolygonInfo"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + tolua_variable(tolua_S, "rect", lua_cocos2dx_get_PolygonInfo_rect, lua_cocos2dx_set_PolygonInfo_rect); + tolua_variable(tolua_S, "filename", lua_cocos2dx_get_PolygonInfo_filename, lua_cocos2dx_set_PolygonInfo_filename); + } + lua_pop(tolua_S, 1); + + luaL_getmetatable(tolua_S, "cc.PolygonInfo"); + if (lua_istable(tolua_S, -1)) + { + tolua_function(tolua_S, ".collector", lua_collect_PolygonInfo); + } + lua_pop(tolua_S, 1); +} + +int lua_cocos2dx_AutoPolygon_generatePolygon(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.AutoPolygon",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AutoPolygon:generatePolygon"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AutoPolygon_generatePolygon'", nullptr); + return 0; + } + cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0)); + object_to_luaval(tolua_S, "cc.PolygonInfo",(cocos2d::PolygonInfo*)ret); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + return 1; + } + if (argc == 2) + { + std::string arg0; + cocos2d::Rect arg1; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AutoPolygon:generatePolygon"); + ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.AutoPolygon:generatePolygon"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AutoPolygon_generatePolygon'", nullptr); + return 0; + } + cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1)); + object_to_luaval(tolua_S, "cc.PolygonInfo",(cocos2d::PolygonInfo*)ret); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + return 1; + } + if (argc == 3) + { + std::string arg0; + cocos2d::Rect arg1; + double arg2; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AutoPolygon:generatePolygon"); + ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.AutoPolygon:generatePolygon"); + ok &= luaval_to_number(tolua_S, 4,&arg2, "cc.AutoPolygon:generatePolygon"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AutoPolygon_generatePolygon'", nullptr); + return 0; + } + cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2)); + object_to_luaval(tolua_S, "cc.PolygonInfo",(cocos2d::PolygonInfo*)ret); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + return 1; + } + if (argc == 4) + { + std::string arg0; + cocos2d::Rect arg1; + double arg2; + double arg3; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.AutoPolygon:generatePolygon"); + ok &= luaval_to_rect(tolua_S, 3, &arg1, "cc.AutoPolygon:generatePolygon"); + ok &= luaval_to_number(tolua_S, 4,&arg2, "cc.AutoPolygon:generatePolygon"); + ok &= luaval_to_number(tolua_S, 5,&arg3, "cc.AutoPolygon:generatePolygon"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AutoPolygon_generatePolygon'", nullptr); + return 0; + } + cocos2d::PolygonInfo* ret = new cocos2d::PolygonInfo(cocos2d::AutoPolygon::generatePolygon(arg0, arg1, arg2, arg3)); + object_to_luaval(tolua_S, "cc.PolygonInfo",(cocos2d::PolygonInfo*)ret); + tolua_register_gc(tolua_S,lua_gettop(tolua_S)); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AutoPolygon:generatePolygon",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AutoPolygon_generatePolygon'.",&tolua_err); +#endif + return 0; +} + +static int lua_collect_AutoPolygon (lua_State* tolua_S) +{ + cocos2d::AutoPolygon* self = (cocos2d::AutoPolygon*) tolua_tousertype(tolua_S,1,0); + CC_SAFE_DELETE(self); + return 0; +} + +static void extendAutoPolygon(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "cc.AutoPolygon"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + tolua_function(tolua_S, "generatePolygon", lua_cocos2dx_AutoPolygon_generatePolygon); + } + lua_pop(tolua_S, 1); + + luaL_getmetatable(tolua_S, "cc.AutoPolygon"); + if (lua_istable(tolua_S, -1)) + { + tolua_function(tolua_S, ".collector", lua_collect_AutoPolygon); + } + lua_pop(tolua_S, 1); +} + int register_all_cocos2dx_manual(lua_State* tolua_S) { if (NULL == tolua_S) @@ -7790,6 +8239,9 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) extendGLView(tolua_S); extendCamera(tolua_S); extendProperties(tolua_S); + extendAutoPolygon(tolua_S); + extendPolygonInfo(tolua_S); + extendPolygonInfo(tolua_S); return 0; } diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 2fb4a6e6e4..29030bf974 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -74,6 +74,8 @@ "cocos/2d/CCAnimationCache.h", "cocos/2d/CCAtlasNode.cpp", "cocos/2d/CCAtlasNode.h", + "cocos/2d/CCAutoPolygon.cpp", + "cocos/2d/CCAutoPolygon.h", "cocos/2d/CCCamera.cpp", "cocos/2d/CCCamera.h", "cocos/2d/CCClippingNode.cpp", @@ -181,12 +183,6 @@ "cocos/2d/CCTweenFunction.cpp", "cocos/2d/CCTweenFunction.h", "cocos/2d/CMakeLists.txt", - "cocos/2d/MarchingSquare.cpp", - "cocos/2d/MarchingSquare.h", - "cocos/2d/SpritePolygon.cpp", - "cocos/2d/SpritePolygon.h", - "cocos/2d/SpritePolygonCache.cpp", - "cocos/2d/SpritePolygonCache.h", "cocos/2d/cocos2d.def", "cocos/2d/cocos2d_headers.props", "cocos/2d/cocos2dx.props", @@ -5531,7 +5527,6 @@ "cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js", "cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js", "cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_builder_auto_api.js", - "cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_experimental_api.js", "cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_experimental_video_auto_api.js", "cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_experimental_webView_auto_api.js", "cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_extension_auto_api.js", @@ -5547,8 +5542,6 @@ "cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp", "cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.cpp", "cocos/scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.hpp", - "cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental.cpp", - "cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental.hpp", "cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.cpp", "cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp", "cocos/scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.cpp", @@ -5586,8 +5579,6 @@ "cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_conversions.h", "cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.cpp", "cocos/scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.h", - "cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_manual.cpp", - "cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_manual.h", "cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_video_manual.cpp", "cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_video_manual.h", "cocos/scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_webView_manual.cpp", @@ -6443,7 +6434,6 @@ "tools/tojs/cocos2dx_3d.ini", "tools/tojs/cocos2dx_3d_ext.ini", "tools/tojs/cocos2dx_builder.ini", - "tools/tojs/cocos2dx_experimental.ini", "tools/tojs/cocos2dx_experimental_video.ini", "tools/tojs/cocos2dx_experimental_webView.ini", "tools/tojs/cocos2dx_extension.ini", @@ -6858,6 +6848,7 @@ "cocos/scripting/lua-bindings/auto/api/AttachNode.lua", "cocos/scripting/lua-bindings/auto/api/AudioEngine.lua", "cocos/scripting/lua-bindings/auto/api/AudioProfile.lua", + "cocos/scripting/lua-bindings/auto/api/AutoPolygon.lua", "cocos/scripting/lua-bindings/auto/api/BaseData.lua", "cocos/scripting/lua-bindings/auto/api/BaseLight.lua", "cocos/scripting/lua-bindings/auto/api/BatchNode.lua", @@ -7035,6 +7026,9 @@ "cocos/scripting/lua-bindings/auto/api/MoveTo.lua", "cocos/scripting/lua-bindings/auto/api/MovementBoneData.lua", "cocos/scripting/lua-bindings/auto/api/MovementData.lua", + "cocos/scripting/lua-bindings/auto/api/NavMesh.lua", + "cocos/scripting/lua-bindings/auto/api/NavMeshAgent.lua", + "cocos/scripting/lua-bindings/auto/api/NavMeshObstacle.lua", "cocos/scripting/lua-bindings/auto/api/Node.lua", "cocos/scripting/lua-bindings/auto/api/NodeGrid.lua", "cocos/scripting/lua-bindings/auto/api/OrbitCamera.lua", @@ -7099,6 +7093,7 @@ "cocos/scripting/lua-bindings/auto/api/PhysicsWorld.lua", "cocos/scripting/lua-bindings/auto/api/Place.lua", "cocos/scripting/lua-bindings/auto/api/PointLight.lua", + "cocos/scripting/lua-bindings/auto/api/PolygonInfo.lua", "cocos/scripting/lua-bindings/auto/api/PositionFrame.lua", "cocos/scripting/lua-bindings/auto/api/ProgressFromTo.lua", "cocos/scripting/lua-bindings/auto/api/ProgressTimer.lua", @@ -7160,8 +7155,6 @@ "cocos/scripting/lua-bindings/auto/api/SpriteDisplayData.lua", "cocos/scripting/lua-bindings/auto/api/SpriteFrame.lua", "cocos/scripting/lua-bindings/auto/api/SpriteFrameCache.lua", - "cocos/scripting/lua-bindings/auto/api/SpritePolygon.lua", - "cocos/scripting/lua-bindings/auto/api/SpritePolygonCache.lua", "cocos/scripting/lua-bindings/auto/api/StopGrid.lua", "cocos/scripting/lua-bindings/auto/api/TMXLayer.lua", "cocos/scripting/lua-bindings/auto/api/TMXLayerInfo.lua", @@ -7253,6 +7246,7 @@ "cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_experimental_video_auto_api.lua", "cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_experimental_webview_auto_api.lua", "cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_extension_auto_api.lua", + "cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_navmesh_auto_api.lua", "cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_physics3d_auto_api.lua", "cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_physics_auto_api.lua", "cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_spine_auto_api.lua", @@ -7280,6 +7274,8 @@ "cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.hpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp", + "cocos/scripting/lua-bindings/auto/lua_cocos2dx_navmesh_auto.cpp", + "cocos/scripting/lua-bindings/auto/lua_cocos2dx_navmesh_auto.hpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.cpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics3d_auto.hpp", "cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp", diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index a2063e754a..2c4ce7a629 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -101,7 +101,7 @@ public: } // normal effect: order == 0 - _trianglesCommand.init(_globalZOrder, _texture->getName(), getGLProgramState(), _blendFunc, getRenderedTriangles(), transform, flags); + _trianglesCommand.init(_globalZOrder, _texture->getName(), getGLProgramState(), _blendFunc, _polyInfo.triangles, transform, flags); renderer->addCommand(&_trianglesCommand); // postive effects: oder >= 0 diff --git a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp index d73fdab97d..ec132e6139 100644 --- a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp +++ b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.cpp @@ -1,31 +1,125 @@ -// -// SpritePolygonTest.cpp -// cocos2d_tests -// -// Created by WuHao on 15/4/23. -// -// - #include "SpritePolygonTest.h" -#include "2d/SpritePolygon.h" #include "../testResource.h" +#include "ui/CocosGUI.h" USING_NS_CC; - SpritePolygonTest::SpritePolygonTest() { ADD_TEST_CASE(SpritePolygonTest1); ADD_TEST_CASE(SpritePolygonTest2); - ADD_TEST_CASE(SpritePolygonTest3); - ADD_TEST_CASE(SpritePolygonTest4); - ADD_TEST_CASE(SpritePolygonPerformanceTestStatic); - ADD_TEST_CASE(SpritePerformanceTestStatic); + ADD_TEST_CASE(SpritePolygonTest3); + ADD_TEST_CASE(SpritePolygonTest4); ADD_TEST_CASE(SpritePolygonPerformanceTestDynamic); ADD_TEST_CASE(SpritePerformanceTestDynamic); } +void SpritePolygonTestCase::onBackCallback(cocos2d::Ref *sender) +{ + TestCase::onBackCallback(sender); + Director::getInstance()->setClearColor(Color4F::BLACK); +} +void SpritePolygonTestDemo::initTouchDebugDraw() +{ + auto touchListener = EventListenerTouchOneByOne::create(); + touchListener->onTouchBegan = [&](Touch* touch, Event* event){ + sp->debugDraw(true); + spp->debugDraw(true); + return true; + }; + touchListener->onTouchMoved = [&](Touch* touch, Event* event){ + auto pos = touch->getDelta(); + float newScale = clampf(spp->getScale() + pos.x * 0.01f, 0.1f, 2.f); + spp->setScale(newScale); + sp->setScale(newScale); + }; + touchListener->onTouchEnded = [&](Touch* touch, Event* event){ + spp->debugDraw(false); + sp->debugDraw(false); + }; + _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); + + + +} +void SpritePolygonTest1::make2Sprites() +{ + Director::getInstance()->setClearColor(Color4F(102.f/255, 184.f/255, 204.f/255, 255.f)); + auto filename = s_pathGrossini; + auto pinfo = AutoPolygon::generatePolygon(filename); + spp = Sprite::create(pinfo); + addChild(spp); + auto s = Director::getInstance()->getWinSize(); + auto offset = Vec2(0.15*s.width,0); + spp->setPosition(Vec2(s)/2 + offset); + + + sp = Sprite::create(filename); + addChild(sp); + sp->setPosition(Vec2(s)/2 - offset); + + TTFConfig ttfConfig("fonts/arial.ttf", 8); + std::string temp = "Sprite:\nPixels drawn: "; + auto spSize = sp->getContentSize(); + auto spArea = Label::createWithTTF(ttfConfig, temp+Value((int)spSize.width*(int)spSize.height).asString()); + sp->addChild(spArea); + spArea->setAnchorPoint(Vec2(0,1)); + + temp = "SpritePolygon:\nPixels drawn: "; + auto vertCount = "\nverts:"+Value((int)pinfo.getVertCount()).asString(); + auto sppArea = Label::createWithTTF(ttfConfig, temp+Value((int)pinfo.getArea()).asString()+vertCount); + spp->addChild(sppArea); + sppArea->setAnchorPoint(Vec2(0,1)); + + initTouchDebugDraw(); +} +SpritePolygonTest1::SpritePolygonTest1() +{ + _title = "SpritePolygon Creation"; + _subtitle = "Sprite::create(AutoPolygon::generatePolygon(filename))"; + make2Sprites(); +} +SpritePolygonTest2::SpritePolygonTest2() +{ + _title = "SpritePolygon Creation with a rect"; + _subtitle = "Sprite::create(AutoPolygon::generatePolygon(filename, rect))"; + make2Sprites(); +} +void SpritePolygonTest2::make2Sprites() +{ + Director::getInstance()->setClearColor(Color4F(102.f/255, 184.f/255, 204.f/255, 255.f)); + auto filename = s_pathGrossini; + Rect head = Rect(30,25,25,25); + auto pinfo = AutoPolygon::generatePolygon(filename, head); + spp = Sprite::create(pinfo); + addChild(spp); + auto s = Director::getInstance()->getWinSize(); + auto offset = Vec2(0.15*s.width,0); + spp->setPosition(Vec2(s)/2 + offset); + + + sp = Sprite::create(filename,head); + addChild(sp); + sp->setPosition(Vec2(s)/2 - offset); + + TTFConfig ttfConfig("fonts/arial.ttf", 8); + std::string temp = "Sprite:\nPixels drawn: "; + auto spSize = sp->getContentSize(); + auto spArea = Label::createWithTTF(ttfConfig, temp+Value((int)spSize.width*(int)spSize.height).asString()); + sp->addChild(spArea); + spArea->setAnchorPoint(Vec2(0,1)); + + temp = "SpritePolygon:\nPixels drawn: "; + auto vertCount = "\nverts:"+Value((int)pinfo.getVertCount()).asString(); + auto sppArea = Label::createWithTTF(ttfConfig, temp+Value((int)pinfo.getArea()).asString()+vertCount); + spp->addChild(sppArea); + sppArea->setAnchorPoint(Vec2(0,1)); + + initTouchDebugDraw(); +} + + + SpritePolygonPerformance::SpritePolygonPerformance() { - SpritePolygonCache::getInstance()->removeAllSpritePolygonCache(); Director::getInstance()->setClearColor(Color4F(102.f/255, 184.f/255, 204.f/255, 255.f)); TTFConfig ttfConfig("fonts/arial.ttf", 10); perfLabel = Label::createWithTTF(ttfConfig, "performance test"); @@ -47,7 +141,7 @@ SpritePolygonPerformance::SpritePolygonPerformance() } void SpritePolygonPerformance::updateLabel() { -// std::string temp = "Nodes: " + Value(spriteCount).asString() + " Triangles: " + Value(triCount).asString() + "\nPixels: " + Value(pixelCount).asString() + " Vertices: " + Value(vertCount).asString(); + std::string temp = "Nodes: " + Value(spriteCount).asString() + " Triangles: " + Value(triCount).asString() + "\nPixels: " + Value(pixelCount).asString() + " Vertices: " + Value(vertCount).asString(); if(!ended) perfLabel->setString("Nodes: " + Value(spriteCount).asString() + " Triangles: " + Value(triCount).asString() + "\nPixels: " + Value(pixelCount).asString() + " Vertices: " + Value(vertCount).asString()); } @@ -115,384 +209,155 @@ void SpritePolygonPerformance::incrementStats() triCount += _incTri; pixelCount += _incPix; } - - - - - -SpritePolygonPerformanceTestStatic::SpritePolygonPerformanceTestStatic() +void SpritePolygonPerformanceTestDynamic::initIncrementStats() { - _title = "Static SpritePolygon Performance"; - _subtitle = "Test running, please wait until it ends"; - initIncrementStats(); -} -experimental::SpritePolygon* SpritePolygonPerformanceTestStatic::makeSprite() -{ - return experimental::SpritePolygon::create(s_pathGrossini); -} -void SpritePolygonPerformanceTestStatic::initIncrementStats() -{ - auto t = experimental::SpritePolygon::create(s_pathGrossini); - _incVert = (int)t->getVertCount(); - _incTri = (int)t->getTrianglesCount(); - _incPix = (int)t->getArea(); + _incVert = _pinfo.getVertCount(); + _incTri = _pinfo.getTriaglesCount(); + _incPix = _pinfo.getArea(); } SpritePolygonPerformanceTestDynamic::SpritePolygonPerformanceTestDynamic() { + _pinfo = AutoPolygon::generatePolygon(s_pathGrossini); _title = "Dynamic SpritePolygon Performance"; _subtitle = "Test running, please wait until it ends"; initIncrementStats(); } -experimental::SpritePolygon* SpritePolygonPerformanceTestDynamic::makeSprite() +Sprite* SpritePolygonPerformanceTestDynamic::makeSprite() { - auto ret = experimental::SpritePolygon::create(s_pathGrossini); + auto ret = Sprite::create(_pinfo); ret->runAction(RepeatForever::create(RotateBy::create(1.0,360.0))); return ret; } -SpritePerformanceTestStatic::SpritePerformanceTestStatic() -{ - _title = "Static Sprite Performance"; - _subtitle = "Test running, please wait until it ends"; - initIncrementStats(); -} -Sprite* SpritePerformanceTestStatic::makeSprite() -{ - return Sprite::create(s_pathGrossini); -} -void SpritePerformanceTestStatic::initIncrementStats() -{ - auto t = Sprite::create(s_pathGrossini); - _incVert = 4; - _incTri = 2; - _incPix = t->getContentSize().width * t->getContentSize().height; -} - SpritePerformanceTestDynamic::SpritePerformanceTestDynamic() { _title = "Dynamic Sprite Performance"; _subtitle = "Test running, please wait until it ends"; initIncrementStats(); } +void SpritePerformanceTestDynamic::initIncrementStats() +{ + auto t = Sprite::create(s_pathGrossini); + _incVert = 4; + _incTri = 2; + _incPix = t->getContentSize().width * t->getContentSize().height; +} Sprite* SpritePerformanceTestDynamic::makeSprite() { - auto ret = Sprite::create(s_pathGrossini); + auto ret = Sprite::create(s_pathGrossini); ret->runAction(RepeatForever::create(RotateBy::create(1.0,360.0))); return ret; } - -void SpritePolygonTestDemo::initDefaultSprite(const std::string &filename, cocos2d::experimental::SpritePolygon * inst) +SpritePolygonTestSlider::SpritePolygonTestSlider() { - Director::getInstance()->setClearColor(Color4F(102.f/255, 184.f/255, 204.f/255, 255.f)); + _ttfConfig = TTFConfig("fonts/arial.ttf", 8); + _title = "Optimization Value (default:2.0)"; + _subtitle = ""; - spp = inst; - addChild(spp); - auto s = Director::getInstance()->getWinSize(); - auto offset = Vec2(0.15*s.width,0); - spp->setPosition(Vec2(s)/2 + offset); - + auto vsize =Director::getInstance()->getVisibleSize(); + cocos2d::ui::Slider* slider = cocos2d::ui::Slider::create(); + slider->loadBarTexture("cocosui/sliderTrack.png"); + slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", ""); + slider->loadProgressBarTexture("cocosui/sliderProgress.png"); + slider->setPosition(Vec2(vsize.width/2, vsize.height/4/* + slider->getSize().height * 2.0f*/)); - sp = Sprite::create(filename); - addChild(sp); - sp->setPosition(Vec2(s)/2 - offset); + slider->addEventListener(CC_CALLBACK_2(SpritePolygonTestSlider::changeEpsilon, this)); + slider->setPercent((int)(sqrtf(1.0f/19.0f)*100)); - auto touchListener = EventListenerTouchOneByOne::create(); - touchListener->onTouchBegan = [&](Touch* touch, Event* event){ - spp->showDebug(true); - debugForNormalSprite->setVisible(true); - return true; - }; - touchListener->onTouchMoved = [&](Touch* touch, Event* event){ - auto pos = touch->getDelta(); - float newScale = clampf(spp->getScale() + pos.x * 0.01f, 0.1f, 2.f); - spp->setScale(newScale); - sp->setScale(newScale); - }; - touchListener->onTouchEnded = [&](Touch* touch, Event* event){ - spp->showDebug(false); - debugForNormalSprite->setVisible(false); - }; - _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); - - debugForNormalSprite = DrawNode::create(); - sp->addChild(debugForNormalSprite); - - auto positions = new Vec2[4]; - auto spSize = sp->getContentSize(); - positions[0] = Vec2(0, spSize.height); - positions[1] = Vec2(spSize); - positions[2] = Vec2(spSize.width, 0); - positions[3] = Vec2(0,0); - debugForNormalSprite->drawPoints(positions, 4, 8, Color4F(0.0,1.0,1.0,1.0)); - debugForNormalSprite->drawLine(positions[0], positions[1], Color4F::GREEN); - debugForNormalSprite->drawLine(positions[1], positions[2], Color4F::GREEN); - debugForNormalSprite->drawLine(positions[2], positions[3], Color4F::GREEN); - debugForNormalSprite->drawLine(positions[3], positions[0], Color4F::GREEN); - debugForNormalSprite->drawLine(positions[0], positions[2], Color4F::GREEN); - debugForNormalSprite->setVisible(false); - delete [] positions; - - TTFConfig ttfConfig("fonts/arial.ttf", 8); - std::string temp = "Sprite:\nPixels drawn: "; - auto spArea = Label::createWithTTF(ttfConfig, temp+Value((int)spSize.width*(int)spSize.height).asString()); - sp->addChild(spArea); - spArea->setAnchorPoint(Vec2(0,1)); - - temp = "SpritePolygon:\nPixels drawn: "; - auto vertCount = "\nverts:"+Value((int)spp->getVertCount()).asString(); - auto sppArea = Label::createWithTTF(ttfConfig, temp+Value((int)spp->getArea()).asString()+vertCount); - spp->addChild(sppArea); - sppArea->setAnchorPoint(Vec2(0,1)); + _epsilonLabel = Label::createWithTTF(_ttfConfig, "Epsilon: 2.0"); + addChild(_epsilonLabel); + _epsilonLabel->setPosition(Vec2(vsize.width/2, vsize.height/4 + 15)); + addChild(slider); } -void SpritePolygonTestCase::onBackCallback(cocos2d::Ref *sender) +void SpritePolygonTestSlider::makeSprites(const std::string* list, const int count, const float y) { - TestCase::onBackCallback(sender); - Director::getInstance()->setClearColor(Color4F::BLACK); -} - - -SpritePolygonTest1::SpritePolygonTest1() -{ - SpritePolygonCache::getInstance()->removeAllSpritePolygonCache(); - _title = "SpritePolygon Creation"; - _subtitle = "SpritePolygon::create(\"Images/grossini.png\")"; - cocos2d::experimental::SpritePolygon *s; - for(int i = 0; i < 10; i ++) + auto vsize =Director::getInstance()->getVisibleSize(); + float offset = (vsize.width-100)/(count-1); + for(int i = 0; i < count; i++) { - s= experimental::SpritePolygon::create(s_pathGrossini); + auto sp = makeSprite(list[i], Vec2(50+offset*i, y)); + addChild(sp); + sp->debugDraw(true); } - initDefaultSprite(s_pathGrossini, s); } - -SpritePolygonTest2::SpritePolygonTest2() +void SpritePolygonTestSlider::changeEpsilon(cocos2d::Ref *pSender, cocos2d::ui::Slider::EventType type) { - /* - 36.5 128.5 - 27.5 133.5 - 24.5 145.5 - 26.5 161.5 - 33.5 168.5 - 27.5 168.5 - 16.5 179.5 - 30.5 197.5 - 28.5 237.5 - 56.5 237.5 - 54.5 197.5 - 68.5 184.5 - 57.5 168.5 - 51.5 168.5 - 60.5 154.5 - 57.5 133.5 - 48.5 127.5 - 36.5 127.5 - */ - std::vector verts; - verts.push_back(Vec2(36.5, 242.0-128.5)); - verts.push_back(Vec2(27.5, 242.0-133.5)); - verts.push_back(Vec2(24.5, 242.0-145.5)); - verts.push_back(Vec2(26.5, 242.0-161.5)); - verts.push_back(Vec2(33.5, 242.0-168.5)); - verts.push_back(Vec2(27.5, 242.0-168.5)); - verts.push_back(Vec2(16.5, 242.0-179.5)); - verts.push_back(Vec2(30.5, 242.0-197.5)); - verts.push_back(Vec2(28.5, 242.0-237.5)); - verts.push_back(Vec2(56.5, 242.0-237.5)); - verts.push_back(Vec2(54.5, 242.0-197.5)); - verts.push_back(Vec2(68.5, 242.0-184.5)); - verts.push_back(Vec2(57.5, 242.0-168.5)); - verts.push_back(Vec2(51.5, 242.0-168.5)); - verts.push_back(Vec2(60.5, 242.0-154.5)); - verts.push_back(Vec2(57.5, 242.0-133.5)); - verts.push_back(Vec2(48.5, 242.0-127.5)); - verts.push_back(Vec2(36.5, 242.0-127.5)); - - SpritePolygonCache::getInstance()->removeAllSpritePolygonCache(); - _title = "SpritePolygon Creation"; - _subtitle = "SpritePolygon::create(\"Images/grossini.png\", verts)"; - auto s = experimental::SpritePolygon::create(s_pathGrossini, verts); - initDefaultSprite(s_pathGrossini, s); + if (type == cocos2d::ui::Slider::EventType::ON_PERCENTAGE_CHANGED) + { + cocos2d::ui::Slider* slider = dynamic_cast(pSender); + float epsilon = powf(slider->getPercent()/100.0,2)*19.0f + 1.0f; + for(auto child : _children) + { + if(child->getName().size()) + { + Sprite *sp = (Sprite*)child; + auto file = sp->getName(); + auto pinfo = AutoPolygon::generatePolygon(file, Rect::ZERO, epsilon); + sp->setPolygonInfo(pinfo); + sp->debugDraw(true); + updateLabel(sp, pinfo); + } + } + _epsilonLabel->setString("Epsilon: "+ Value(epsilon).asString()); + } } +void SpritePolygonTestSlider::updateLabel(const cocos2d::Sprite *sp, const PolygonInfo &pinfo) +{ + Label *label = (Label*)(sp->getChildren().at(0)); + auto filename = sp->getName(); + auto size = pinfo.rect.size/Director::getInstance()->getContentScaleFactor(); + label->setString(filename+"\nVerts: "+Value((int)pinfo.getVertCount()).asString()+ "\nPixels: "+Value((int)(pinfo.getArea()/(size.width*size.height)*100)).asString()+"%"); +} + +Sprite* SpritePolygonTestSlider::makeSprite(const std::string &filename, const Vec2 &pos) +{ + auto quadSize = Sprite::create(filename)->getContentSize(); + int originalSize = quadSize.width * quadSize.height; + auto pinfo = AutoPolygon::generatePolygon(filename); + auto ret = Sprite::create(pinfo); + ret->setPosition(pos); + + auto spArea = Label::createWithTTF(_ttfConfig, filename+"\nVerts: "+Value((int)pinfo.getVertCount()).asString()+ "\nPixels: "+Value((int)(pinfo.getArea()/originalSize*100)).asString()+"%"); + ret->addChild(spArea); + spArea->setAnchorPoint(Vec2(0,1)); + ret->setName(filename); + ret->setAnchorPoint(Vec2(0.5, 0)); + return ret; +} SpritePolygonTest3::SpritePolygonTest3() { - /* - 18, 48 - 33.500000, 73.500000 - 27.500000, 73.500000 - 16.500000, 62.500000 - 30.500000, 44.500000 - 54.500000, 44.500000 - 51.500000, 73.500000 - 60.500000, 87.500000 - 26.500000, 80.500000 - 24.500000, 96.500000 - 57.500000, 108.500000 - 36.500000, 113.500000 - 48.500000, 114.500000 - 36.500000, 114.500000 - 27.500000, 108.500000 - 68.500000, 57.500000 - 57.500000, 73.500000 - 56.500000, 4.500000 - 28.500000, 4.500000 - 0, 1, 2 - 3, 0, 2 - 4, 0, 3 - 5, 0, 4 - 5, 6, 0 - 0, 6, 7 - 8, 7, 6 - 6, 9, 8 - 9, 10, 8 - 9, 11, 10 - 11, 12, 10 - 8, 10, 13 - 14, 5, 4 - 15, 5, 14 - 4, 3, 16 - 3, 17, 16 - */ - std::vector verts; - verts.push_back(Vec2(33.500000, 73.500000)); - verts.push_back(Vec2(27.500000, 73.500000)); - verts.push_back(Vec2(16.500000, 62.500000)); - verts.push_back(Vec2(30.500000, 44.500000)); - verts.push_back(Vec2(54.500000, 44.500000)); - verts.push_back(Vec2(51.500000, 73.500000)); - verts.push_back(Vec2(60.500000, 87.500000)); - verts.push_back(Vec2(26.500000, 80.500000)); - verts.push_back(Vec2(24.500000, 96.500000)); - verts.push_back(Vec2(57.500000, 108.500000)); - verts.push_back(Vec2(36.500000, 113.500000)); - verts.push_back(Vec2(48.500000, 114.500000)); - verts.push_back(Vec2(36.500000, 114.500000)); - verts.push_back(Vec2(27.500000, 108.500000)); - verts.push_back(Vec2(68.500000, 57.500000)); - verts.push_back(Vec2(57.500000, 73.500000)); - verts.push_back(Vec2(56.500000, 4.500000)); - verts.push_back(Vec2(28.500000, 4.500000)); - unsigned short indicesArr[] = {0, 1, 2, 3, 0, 2, 4, 0, 3, 5, 0, 4, 5, 6, 0, 0, 6, 7, 8, 7, 6, 6, 9, 8, 9, 10, 8, 9, 11, 10, 11, 12, 10, 8, 10, 13, 14, 5, 4, 15, 5, 14, 4, 3, 16, 3, 17, 16}; - std::vector indices(indicesArr, indicesArr + sizeof indicesArr / sizeof indicesArr[0]); + _ttfConfig = TTFConfig("fonts/arial.ttf", 8); + _title = "Optimization Value (default:2.0)"; + _subtitle = ""; + auto vsize =Director::getInstance()->getVisibleSize(); + std::string list[] = { + "Images/arrows.png", + "Images/CyanTriangle.png", + s_pathB2, + "Images/elephant1_Diffuse.png" + }; + int count = 4; + makeSprites(list, count, vsize.height/2); +} +SpritePolygonTest4::SpritePolygonTest4() +{ + _ttfConfig = TTFConfig("fonts/arial.ttf", 8); + _title = "Optimization Value (default:2.0)"; + _subtitle = ""; + auto vsize =Director::getInstance()->getVisibleSize(); - SpritePolygonCache::getInstance()->removeAllSpritePolygonCache(); - _title = "SpritePolygon Creation"; - _subtitle = "SpritePolygon::create(\"Images/grossini.png\", verts, indices)"; - auto s = experimental::SpritePolygon::create(s_pathGrossini, verts, indices); - initDefaultSprite(s_pathGrossini, s); -} - -SpritePolygonTest4::SpritePolygonTest4(){ - /* - 18, 48 - 33.500000, 73.500000 - 27.500000, 73.500000 - 16.500000, 62.500000 - 30.500000, 44.500000 - 54.500000, 44.500000 - 51.500000, 73.500000 - 60.500000, 87.500000 - 26.500000, 80.500000 - 24.500000, 96.500000 - 57.500000, 108.500000 - 36.500000, 113.500000 - 48.500000, 114.500000 - 36.500000, 114.500000 - 27.500000, 108.500000 - 68.500000, 57.500000 - 57.500000, 73.500000 - 56.500000, 4.500000 - 28.500000, 4.500000 - 0, 1, 2, - 3, 0, 2, - 4, 0, 3, - 5, 0, 4, - 5, 6, 0, - 0, 6, 7, - 8, 7, 6, - 6, 9, 8, - 9, 10, 8, - 9, 11, 10, - 11, 12, 10, - 8, 10, 13, - 14, 5, 4, - 15, 5, 14, - 4, 3, 16, - 3, 17, 16, - 0.394118, 0.392562 - 0.323529, 0.392562 - 0.194118, 0.483471 - 0.358824, 0.632231 - 0.641176, 0.632231 - 0.605882, 0.392562 - 0.711765, 0.276859 - 0.311765, 0.334711 - 0.288235, 0.202479 - 0.676471, 0.103306 - 0.429412, 0.061983 - 0.570588, 0.053719 - 0.429412, 0.053719 - 0.323529, 0.103306 - 0.805882, 0.524793 - 0.676471, 0.392562 - 0.664706, 0.962810 - 0.335294, 0.962810 - */ - Vec3 poss[] = {Vec3(33.500000, 73.500000,0), - Vec3(27.500000, 73.500000,0), - Vec3(16.500000, 62.500000,0), - Vec3(30.500000, 44.500000,0), - Vec3(54.500000, 44.500000,0), - Vec3(51.500000, 73.500000,0), - Vec3(60.500000, 87.500000,0), - Vec3(26.500000, 80.500000,0), - Vec3(24.500000, 96.500000,0), - Vec3(57.500000, 108.500000,0), - Vec3(36.500000, 113.500000,0), - Vec3(48.500000, 114.500000,0), - Vec3(36.500000, 114.500000,0), - Vec3(27.500000, 108.500000,0), - Vec3(68.500000, 57.500000,0), - Vec3(57.500000, 73.500000,0), - Vec3(56.500000, 4.500000,0), - Vec3(28.500000, 4.50000, 0) - }; - unsigned short idxs[] = {0, 1, 2, 3, 0, 2, 4, 0, 3, 5, 0, 4, 5, 6, 0, 0, 6, 7, 8, 7, 6, 6, 9, 8, 9, 10, 8, 9, 11, 10, 11, 12, 10, 8, 10, 13, 14, 5, 4, 15, 5, 14, 4, 3, 16, 3, 17, 16}; - std::vector indices(idxs, idxs + sizeof idxs / sizeof idxs[0]); - Tex2F t2f[] = { - Tex2F(0.394118f, 0.392562f), - Tex2F(0.323529f, 0.392562f), - Tex2F(0.194118f, 0.483471f), - Tex2F(0.358824f, 0.632231f), - Tex2F(0.641176f, 0.632231f), - Tex2F(0.605882f, 0.392562f), - Tex2F(0.711765f, 0.276859f), - Tex2F(0.311765f, 0.334711f), - Tex2F(0.288235f, 0.202479f), - Tex2F(0.676471f, 0.103306f), - Tex2F(0.429412f, 0.061983f), - Tex2F(0.570588f, 0.053719f), - Tex2F(0.429412f, 0.053719f), - Tex2F(0.323529f, 0.103306f), - Tex2F(0.805882f, 0.524793f), - Tex2F(0.676471f, 0.392562f), - Tex2F(0.664706f, 0.962810f), - Tex2F(0.335294f, 0.962810f) - }; - std::vector vs; - for(int i = 0; i < 18; i++) - { - V3F_C4B_T2F t = {poss[i],Color4B::WHITE, t2f[i]}; - vs.push_back(t); - } - - SpritePolygonCache::getInstance()->removeAllSpritePolygonCache(); - _title = "SpritePolygon Creation"; - _subtitle = "SpritePolygon::create(\"Images/grossini.png\", vector v, vector indices)"; - auto s = experimental::SpritePolygon::create(s_pathGrossini, vs, indices); - initDefaultSprite(s_pathGrossini, s); + int count = 3; + std::string list[] = { + s_pathGrossini, + "Images/grossinis_sister1.png", + "Images/grossinis_sister2.png" + }; + + makeSprites(list, count, vsize.height/5*2); } diff --git a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.h b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.h index 3353eb791f..5bfc7b8531 100644 --- a/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.h +++ b/tests/cpp-tests/Classes/SpritePolygonTest/SpritePolygonTest.h @@ -1,7 +1,9 @@ #ifndef __cocos2d_tests__SpritePolygonTest__ + #include "../testBasic.h" #include "../BaseTest.h" -#include "2d/SpritePolygon.h" +#include "ui/CocosGUI.h" + DEFINE_TEST_SUITE(SpritePolygonTest); class SpritePolygonTestCase : public TestCase @@ -16,14 +18,29 @@ protected: class SpritePolygonTestDemo : public SpritePolygonTestCase { -public: - void initDefaultSprite(const std::string &filename, cocos2d::experimental::SpritePolygon *inst); protected: - cocos2d::experimental::SpritePolygon* spp; + void initTouchDebugDraw(); + cocos2d::Sprite* spp; cocos2d::Sprite* sp; - cocos2d::DrawNode *debugForNormalSprite; }; +class SpritePolygonTest1 : public SpritePolygonTestDemo +{ +public: + CREATE_FUNC(SpritePolygonTest1); + SpritePolygonTest1(); + void make2Sprites(); +}; + +class SpritePolygonTest2 : public SpritePolygonTestDemo +{ +public: + CREATE_FUNC(SpritePolygonTest2); + SpritePolygonTest2(); + void make2Sprites(); +}; + + class SpritePolygonPerformance : public SpritePolygonTestCase { public: @@ -41,6 +58,7 @@ protected: int continuousLowDt; float continuousHighDtTime; float waitingTime; + int _posX; int _posY; @@ -55,76 +73,58 @@ protected: virtual void incrementStats(); void initIncrementStats(); - int _incVert; - int _incTri; - int _incPix; + unsigned int _incVert; + unsigned int _incTri; + unsigned int _incPix; }; -class SpritePolygonPerformanceTestStatic : public SpritePolygonPerformance -{ -public: - CREATE_FUNC(SpritePolygonPerformanceTestStatic); - SpritePolygonPerformanceTestStatic(); -protected: - cocos2d::experimental::SpritePolygon* makeSprite(); - void initIncrementStats(); -}; - -class SpritePerformanceTestStatic : public SpritePolygonPerformance -{ -public: - CREATE_FUNC(SpritePerformanceTestStatic); - SpritePerformanceTestStatic(); -protected: - cocos2d::Sprite* makeSprite(); - void initIncrementStats(); -}; - -class SpritePolygonPerformanceTestDynamic : public SpritePolygonPerformanceTestStatic +class SpritePolygonPerformanceTestDynamic : public SpritePolygonPerformance { public: CREATE_FUNC(SpritePolygonPerformanceTestDynamic); SpritePolygonPerformanceTestDynamic(); protected: - cocos2d::experimental::SpritePolygon* makeSprite(); + cocos2d::Sprite* makeSprite(); + cocos2d::PolygonInfo _pinfo; + void initIncrementStats(); }; -class SpritePerformanceTestDynamic : public SpritePerformanceTestStatic +class SpritePerformanceTestDynamic : public SpritePolygonPerformance { public: CREATE_FUNC(SpritePerformanceTestDynamic); SpritePerformanceTestDynamic(); protected: cocos2d::Sprite* makeSprite(); + void initIncrementStats(); }; - -class SpritePolygonTest1 : public SpritePolygonTestDemo +class SpritePolygonTestSlider : public SpritePolygonTestCase { public: - CREATE_FUNC(SpritePolygonTest1); - SpritePolygonTest1(); + CREATE_FUNC(SpritePolygonTestSlider); + SpritePolygonTestSlider(); +protected: + cocos2d::Label *_epsilonLabel; + cocos2d::Sprite* makeSprite(const std::string& filename, const cocos2d::Vec2& pos); + void makeSprites(const std::string* list, const int count, const float y); + cocos2d::TTFConfig _ttfConfig; + void changeEpsilon(Ref *pSender, cocos2d::ui::Slider::EventType type); + void updateLabel(const cocos2d::Sprite* sp, const cocos2d::PolygonInfo &pinfo); }; -class SpritePolygonTest2 : public SpritePolygonTestDemo -{ -public: - CREATE_FUNC(SpritePolygonTest2); - SpritePolygonTest2(); -}; - -class SpritePolygonTest3 : public SpritePolygonTestDemo +class SpritePolygonTest3 : public SpritePolygonTestSlider { public: CREATE_FUNC(SpritePolygonTest3); SpritePolygonTest3(); }; - -class SpritePolygonTest4 : public SpritePolygonTestDemo +class SpritePolygonTest4 : public SpritePolygonTestSlider { public: CREATE_FUNC(SpritePolygonTest4); SpritePolygonTest4(); }; + #endif /* defined(__cocos2d_tests__SpritePolygonTest__) */ diff --git a/tests/js-tests/project/Classes/AppDelegate.cpp b/tests/js-tests/project/Classes/AppDelegate.cpp index 03746d1ec3..238d686973 100644 --- a/tests/js-tests/project/Classes/AppDelegate.cpp +++ b/tests/js-tests/project/Classes/AppDelegate.cpp @@ -9,10 +9,8 @@ #include "jsb_cocos2dx_spine_auto.hpp" #include "jsb_cocos2dx_3d_auto.hpp" #include "jsb_cocos2dx_3d_extension_auto.hpp" -#include "jsb_cocos2dx_experimental.hpp" #include "jsb_cocos2dx_physics3d_auto.hpp" #include "physics3d/jsb_cocos2dx_physics3d_manual.h" -#include "experimental/jsb_cocos2dx_experimental_manual.h" #include "3d/jsb_cocos2dx_3d_manual.h" #include "extension/jsb_cocos2dx_extension_manual.h" #include "cocostudio/jsb_cocos2dx_studio_manual.h" @@ -116,9 +114,6 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx_3d_manual); sc->addRegisterCallback(register_all_cocos2dx_3d_extension); - - sc->addRegisterCallback(register_all_cocos2dx_experimental); - sc->addRegisterCallback(register_all_cocos2dx_experimental_manual); #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION sc->addRegisterCallback(register_all_cocos2dx_physics3d); diff --git a/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageScene/CustomImageScene.js b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageScene/CustomImageScene.js index 32193417af..90d087d69a 100644 --- a/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageScene/CustomImageScene.js +++ b/tests/js-tests/src/CocoStudioTest/CustomTest/CustomImageScene/CustomImageScene.js @@ -33,7 +33,7 @@ var CustomImageLayer = cc.Layer.extend({ customImageViewReader, customImageViewReader.setProperties); - var layout = guiReader.widgetFromJsonFile("css-res/cocosui/CustomImageViewTest/NewProject_2_1.ExportJson"); + var layout = guiReader.widgetFromJsonFile("ccs-res/cocosui/CustomImageViewTest/NewProject_2_1.ExportJson"); this.addChild(layout); } }); diff --git a/tests/js-tests/src/FacebookTest/FacebookTestsManager.js b/tests/js-tests/src/FacebookTest/FacebookTestsManager.js index da6177b523..53747b6785 100644 --- a/tests/js-tests/src/FacebookTest/FacebookTestsManager.js +++ b/tests/js-tests/src/FacebookTest/FacebookTestsManager.js @@ -43,8 +43,8 @@ FacebookTestScene = TestScene.extend({ if(!cc.sys.isNative) { //browser cc.loader.loadJs('', [ - "../../../web/external/pluginx/platform/facebook_sdk.js", - "../../../web/external/pluginx/platform/facebook.js" + "../../web/external/pluginx/platform/facebook_sdk.js", + "../../web/external/pluginx/platform/facebook.js" ], function() { var layer = nextFacebookTest(); self.addChild(layer); diff --git a/tests/js-tests/src/GUITest/UIScene.js b/tests/js-tests/src/GUITest/UIScene.js index ddf0a4eaac..b95c8a6265 100644 --- a/tests/js-tests/src/GUITest/UIScene.js +++ b/tests/js-tests/src/GUITest/UIScene.js @@ -55,17 +55,19 @@ UIScene = cc.Scene.extend({ this._sceneTitle = widget.getChildByName("UItest"); - - var label = new cc.LabelTTF("Main Menu", "Arial", 20); - var menuItem = new cc.MenuItemLabel(label, this.toExtensionsMainLayer, this); - - var menu = new cc.Menu(menuItem); - menu.x = 0; - menu.y = 0; - menuItem.x = winSize.width - 50; - menuItem.y = 25; - - this.addChild(menu, 1); + var back_label = widget.getChildByName("back"); + if(back_label){ + back_label.addTouchEventListener(this.toExtensionsMainLayer, this); + }else{ + var label = new cc.LabelTTF("Back", "Arial", 20); + var menuItem = new cc.MenuItemLabel(label, this.toExtensionsMainLayer, this); + var menu = new cc.Menu(menuItem); + menu.x = 0; + menu.y = 0; + menuItem.x = winSize.width - 50; + menuItem.y = 25; + this.addChild(menu, 1); + } var left_button = widget.getChildByName("left_Button"); left_button.addTouchEventListener(this.previousCallback ,this); diff --git a/tests/js-tests/src/GUITest/UIVideoPlayerTest/UIVideoPlayerTest.js b/tests/js-tests/src/GUITest/UIVideoPlayerTest/UIVideoPlayerTest.js index 497f82ab3d..af6afd3355 100644 --- a/tests/js-tests/src/GUITest/UIVideoPlayerTest/UIVideoPlayerTest.js +++ b/tests/js-tests/src/GUITest/UIVideoPlayerTest/UIVideoPlayerTest.js @@ -3,7 +3,7 @@ var UIVideoPlayerTest = UIScene.extend({ onEnter: function(){ UIScene.prototype.onEnter.call(this); - var video = new ccui.VideoPlayer("http://benchmark.cocos2d-x.org/cocosvideo.mp4"); + var video = new ccui.VideoPlayer("cocosvideo.mp4"); video.setContentSize(320, 240); video.setPosition(800/2, 450/2); video.setScale(0.5); @@ -37,38 +37,38 @@ var UIVideoPlayerTest = UIScene.extend({ }}, { name: "PLAYNATIVE", func: function(){ cc.log("play!"); - video.setURL("res/cocosvideo.mp4"); + video.setURL("cocosvideo.mp4"); video.play(); }}, { name: "STOP", func: function(){ - cc.log("stop!"); - video.stop(); + cc.log("stop!"); + video.stop(); }}, { name: "PAUSE", func: function(){ - cc.log("pause!"); - video.pause(); + cc.log("pause!"); + video.pause(); }}, { name: "RESUME", func: function(){ - cc.log("resume!"); - video.resume(); + cc.log("resume!"); + video.resume(); }}, { name: "SEEKTO", func: function(){ var sec = ((Math.random() * 3) * 100 | 0) / 100; - cc.log("seekTo %f sec!", sec); - video.seekTo(sec); + cc.log("seekTo %f sec!", sec); + video.seekTo(sec); }}, { name: "ISPLAYING", func: function(){ - cc.log("isPlaying!"); - cc.log(video.isPlaying()); + cc.log("isPlaying!"); + cc.log(video.isPlaying()); }}, { name: "Full Screen", func: function(){ - cc.log("setFullScreenEnabled!"); - video.setFullScreenEnabled(true); + cc.log("setFullScreenEnabled!"); + video.setFullScreenEnabled(true); }}, { name: "Scale", func: function(){ var scale = ((Math.random() * 0.5 + 0.2) * 100 | 0) / 100; - cc.log("setScale(%f)!", scale); - video.setScale(scale); + cc.log("setScale(%f)!", scale); + video.setScale(scale); }}, { name: "AnchorPoint 0 / 1", func: function(){ var anp = video.getAnchorPoint(); diff --git a/tests/js-tests/src/Physics3DTest/Physics3DTest.js b/tests/js-tests/src/Physics3DTest/Physics3DTest.js index 41184ae602..9e4544513c 100644 --- a/tests/js-tests/src/Physics3DTest/Physics3DTest.js +++ b/tests/js-tests/src/Physics3DTest/Physics3DTest.js @@ -138,7 +138,7 @@ var Physics3DTestDemo = cc.Layer.extend({ this.addChild(sprite); sprite.setPosition3D(this._camera.getPosition3D()); sprite.setScale(0.5); - sprite.syncToNode(); + sprite.syncNodeToPhysics(); sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE); sprite.setCameraMask(cc.CameraFlag.USER1); }, @@ -250,7 +250,7 @@ var BasicPhysics3DDemo = Physics3DTestDemo.extend({ floor.setScaleZ(60); this.addChild(floor); floor.setCameraMask(cc.CameraFlag.USER1); - floor.syncToNode(); + floor.syncNodeToPhysics(); //static object sync is not needed floor.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE); @@ -270,7 +270,7 @@ var BasicPhysics3DDemo = Physics3DTestDemo.extend({ var sprite = cc.PhysicsSprite3D.create("Sprite3DTest/box.c3t", rbDes); sprite.setTexture("Images/CyanSquare.png"); sprite.setPosition3D(cc.math.vec3(x, y, z)); - sprite.syncToNode(); + sprite.syncNodeToPhysics(); sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE); sprite.setCameraMask(cc.CameraFlag.USER1); sprite.setScale(0.8); @@ -305,7 +305,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.setCameraMask(cc.CameraFlag.USER1); sprite.setScale(0.4); sprite.setPosition3D(cc.math.vec3(-20, 5, 0)); - component.syncToNode(); + component.syncNodeToPhysics(); component.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE); physicsScene.setPhysics3DDebugCamera(this._camera); @@ -327,7 +327,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.addComponent(component); sprite.setCameraMask(cc.CameraFlag.USER1); this.addChild(sprite); - component.syncToNode(); + component.syncNodeToPhysics(); rigidBody.setAngularVelocity(cc.math.vec3(0, 3, 0)); constraint = cc.Physics3DHingeConstraint.create(rigidBody, cc.math.vec3(4, 4, 0.5), cc.math.vec3(0, 1, 0)); physicsScene.getPhysics3DWorld().addPhysics3DConstraint(constraint); @@ -345,7 +345,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.addComponent(component); sprite.setCameraMask(cc.CameraFlag.USER1); this.addChild(sprite); - component.syncToNode(); + component.syncNodeToPhysics(); rigidBody.setLinearVelocity(cc.math.vec3(0, 3, 0)); rbDes.mass = 0; @@ -359,7 +359,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.addComponent(component); sprite.setCameraMask(cc.CameraFlag.USER1); this.addChild(sprite); - component.syncToNode(); + component.syncNodeToPhysics(); var frameInA = [-4.37114e-08, 1, 0, 0, -1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0, -5, 0, 1]; var frameInB = [-4.37114e-08, 1, 0, 0, -1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0, 5, 0, 1]; @@ -380,7 +380,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.addComponent(component); sprite.setCameraMask(cc.CameraFlag.USER1); this.addChild(sprite); - component.syncToNode(); + component.syncNodeToPhysics(); frameInA = [-4.37114e-08, 1, 0, 0, -1, -4.37114e-08, 0, 0, 0, 0, 1, 0, 0, -10, 0, 1]; constraint = cc.Physics3DConeTwistConstraint.create(rigidBody, frameInA); @@ -399,7 +399,7 @@ var Physics3DConstraintDemo = Physics3DTestDemo.extend({ sprite.addComponent(component); sprite.setCameraMask(cc.CameraFlag.USER1); this.addChild(sprite); - component.syncToNode(); + component.syncNodeToPhysics(); frameInA = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; constraint = cc.Physics3D6DofConstraint.create(rigidBody, frameInA, false); @@ -428,7 +428,7 @@ var Physics3DKinematicDemo = Physics3DTestDemo.extend({ floor.setPosition3D(cc.math.vec3(0, -1, 0)); this.addChild(floor); floor.setCameraMask(cc.CameraFlag.USER1); - floor.syncToNode(); + floor.syncNodeToPhysics(); //static object sync is not needed floor.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE); @@ -472,7 +472,7 @@ var Physics3DKinematicDemo = Physics3DTestDemo.extend({ var sprite = cc.PhysicsSprite3D.create("Sprite3DTest/sphere.c3b", rbDes); sprite.setTexture("Sprite3DTest/plane.png"); sprite.setPosition3D(cc.math.vec3(x, y, z)); - sprite.syncToNode(); + sprite.syncNodeToPhysics(); sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE); sprite.setCameraMask(cc.CameraFlag.USER1); sprite.setScale(1/sprite.getContentSize().width); @@ -571,7 +571,7 @@ var Physics3DTerrainDemo = Physics3DTestDemo.extend({ var rigidBody = cc.Physics3DRigidBody.create(rbDes); var component = cc.Physics3DComponent.create(rigidBody); terrain.addComponent(component); - component.syncToNode(); + component.syncNodeToPhysics(); component.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE); this.addChild(terrain); @@ -593,7 +593,7 @@ var Physics3DTerrainDemo = Physics3DTestDemo.extend({ var sprite = cc.PhysicsSprite3D.create("Sprite3DTest/sphere.c3b", rbDes); sprite.setTexture("Sprite3DTest/plane.png"); sprite.setPosition3D(cc.math.vec3(x, y, z)); - sprite.syncToNode(); + sprite.syncNodeToPhysics(); sprite.setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE); sprite.setCameraMask(cc.CameraFlag.USER1); sprite.setScale(1/sprite.getContentSize().width); diff --git a/tests/js-tests/src/SchedulerTest/SchedulerTest.js b/tests/js-tests/src/SchedulerTest/SchedulerTest.js index d7cbf1618e..0519d8e2c9 100644 --- a/tests/js-tests/src/SchedulerTest/SchedulerTest.js +++ b/tests/js-tests/src/SchedulerTest/SchedulerTest.js @@ -644,6 +644,7 @@ var SchedulerTimeScale = SchedulerTestLayer.extend({ }, onExit: function() { + cc.director.getScheduler().setTimeScale(1); // restore scale cc.director.getScheduler().unscheduleUpdateForTarget(this._newScheduler); this._super(); diff --git a/tests/js-tests/src/SpritePolygonTest/SpritePolygonTest.js b/tests/js-tests/src/SpritePolygonTest/SpritePolygonTest.js index 611019eacb..da11edf7fc 100644 --- a/tests/js-tests/src/SpritePolygonTest/SpritePolygonTest.js +++ b/tests/js-tests/src/SpritePolygonTest/SpritePolygonTest.js @@ -29,62 +29,37 @@ var SpritePolygonTestDemo = BaseTestLayer.extend({ _title:"", _subtitle:"", _debugDraw:null, + _sp: null, + _spp: null, ctor:function () { this._super(); }, - initDefaultSprite:function(filename, inst){ - cc.director.setClearColor(cc.color(102/255, 184/255, 204/255, 255/255)); - this.addChild(inst); - - var s = cc.director.getWinSize(); - inst.setPosition(s.width/2 + 0.15*s.width, s.height/2); - - var sp = new cc.Sprite(filename); - this.addChild(sp); - sp.setPosition(s.width/2 - 0.15*s.width, s.height/2); - - this._debugDraw = new cc.DrawNode(); - sp.addChild(this._debugDraw); - - var self = this; - cc.eventManager.addListener({ - event:cc.EventListener.TOUCH_ONE_BY_ONE, - onTouchBegan:function(){ - inst.showDebug(true); - self._debugDraw.setVisible(true); + initTouchDebugDraw: function() { + var touchListener = cc.EventListener.create({ + event: cc.EventListener.TOUCH_ONE_BY_ONE, + swallowTouch: true, + onTouchBegan: function (touch, event) { + var target = event.getCurrentTarget(); + target._sp.debugDraw(true); + target._spp.debugDraw(true); return true; }, - onTouchEnded:function(){ - inst.showDebug(false); - self._debugDraw.setVisible(false); + onTouchMoved: function (touch, event) { + var target = event.getCurrentTarget(); + var pos = touch.getDelta(); + var newScale = cc.clampf(target._spp.getScale() + pos.x * 0.01, 0.1, 2); + target._spp.setScale(newScale); + target._sp.setScale(newScale); + }, + onTouchEnded: function (touch, event) { + var target = event.getCurrentTarget(); + target._sp.debugDraw(false); + target._spp.debugDraw(false); } - }, this); - - var positions = new Array(4); - var spSize = sp.getContentSize(); - positions[0] = cc.p(0, spSize.height); - positions[1] = cc.p(spSize.width, spSize.height); - positions[2] = cc.p(spSize.width, 0); - positions[3] = cc.p(0, 0); - - this._debugDraw.drawSegment(positions[0], positions[1], 1, cc.color.GREEN); - this._debugDraw.drawSegment(positions[1], positions[2], 1, cc.color.GREEN); - this._debugDraw.drawSegment(positions[2], positions[3], 1, cc.color.GREEN); - this._debugDraw.drawSegment(positions[3], positions[0], 1, cc.color.GREEN); - this._debugDraw.drawSegment(positions[0], positions[2], 1, cc.color.GREEN); - - this._debugDraw.setVisible(false); - - var label1 = new cc.LabelTTF("Sprite:\nPixels drawn:"+spSize.width*spSize.height, "fonts/arial.ttf", 10); - sp.addChild(label1); - label1.setAnchorPoint(cc.p(0, 1)); - - var label2 = new cc.LabelTTF("SpritePolygon:\nPixels drawn:"+(inst.getArea()+inst.getVertCount()), "fonts/arial.ttf", 10); - inst.addChild(label2); - label2.setAnchorPoint(cc.p(0, 1)); - + }); + cc.eventManager.addListener(touchListener, this); }, onRestartCallback:function (sender) { @@ -136,150 +111,354 @@ var SpritePolygonTestScene = cc.Scene.extend({ }); var SpritePolygonTest1 = SpritePolygonTestDemo.extend({ - _title:"SpritePolygon Creation", - _subtitle:"SpritePolygon::create(\"Images/grossini.png\")", + _title:"PolygonSprite Creation", + _subtitle:"new cc.Sprite(jsb.AutoPolygon.generatePolygon(filename))", - ctor:function(){ + ctor:function () { this._super(); + this.make2Sprites(); + }, + make2Sprites: function() { + var polygons = jsb.AutoPolygon.generatePolygon(s_pathGrossini); + this._spp = new cc.Sprite(polygons); + this._spp.setPosition((0.5+0.15) * winSize.width, 0.5 * winSize.height); + this.addChild(this._spp); - var s = ccexp.SpritePolygon.create(s_pathGrossini); - this.initDefaultSprite(s_pathGrossini, s); + this._sp = new cc.Sprite(s_pathGrossini); + this.addChild(this._sp); + this._sp.setPosition((0.5-0.15) * winSize.width, 0.5 * winSize.height); + + var ttfConfig = new cc.FontDefinition({ + fontName: "fonts/arial.ttf", + fontSize: 8 + }); + var temp = "Sprite:\nPixels drawn: "; + var spSize = this._sp.getContentSize(); + var spArea = new cc.LabelTTF(temp+Math.round(spSize.width*spSize.height), ttfConfig); + spArea.anchorX = 0; + spArea.anchorY = 1; + this._sp.addChild(spArea); + + temp = "PolygonSprite:\nPixels drawn: "; + var vertCount = "\nverts:"+Math.round(polygons.getVertCount()); + var sppArea = new cc.LabelTTF(temp+Math.round(polygons.getArea())+vertCount, ttfConfig); + sppArea.anchorX = 0; + sppArea.anchorY = 1; + this._spp.addChild(sppArea); + + this.initTouchDebugDraw(); } }); var SpritePolygonTest2 = SpritePolygonTestDemo.extend({ - _title:"SpritePolygon Creation", - _subtitle:"SpritePolygon::create(\"Images/grossini.png\", verts)", + _title:"PolygonSprite Creation with a rect", + _subtitle:"new cc.Sprite(jsb.AutoPolygon.generatePolygon(filename, rect))", ctor:function(){ this._super(); + this.make2Sprites(); + }, + make2Sprites: function() { + var head = cc.rect(30, 25, 25, 25); + var polygons = jsb.AutoPolygon.generatePolygon(s_pathGrossini, head); + this._spp = new cc.Sprite(polygons); + this._spp.setPosition((0.5+0.15) * winSize.width, 0.5 * winSize.height); + this.addChild(this._spp); - var verts = []; - verts.push(cc.p(36.5, 242.0-128.5)); - verts.push(cc.p(27.5, 242.0-133.5)); - verts.push(cc.p(24.5, 242.0-145.5)); - verts.push(cc.p(26.5, 242.0-161.5)); - verts.push(cc.p(33.5, 242.0-168.5)); - verts.push(cc.p(27.5, 242.0-168.5)); - verts.push(cc.p(16.5, 242.0-179.5)); - verts.push(cc.p(30.5, 242.0-197.5)); - verts.push(cc.p(28.5, 242.0-237.5)); - verts.push(cc.p(56.5, 242.0-237.5)); - verts.push(cc.p(54.5, 242.0-197.5)); - verts.push(cc.p(68.5, 242.0-184.5)); - verts.push(cc.p(57.5, 242.0-168.5)); - verts.push(cc.p(51.5, 242.0-168.5)); - verts.push(cc.p(60.5, 242.0-154.5)); - verts.push(cc.p(57.5, 242.0-133.5)); - verts.push(cc.p(48.5, 242.0-127.5)); - verts.push(cc.p(36.5, 242.0-127.5)); + this._sp = new cc.Sprite(s_pathGrossini, head); + this.addChild(this._sp); + this._sp.setPosition((0.5-0.15) * winSize.width, 0.5 * winSize.height); - cc.SpritePolygonCache.getInstance().removeAllSpritePolygonCache(); - var s = ccexp.SpritePolygon.create(s_pathGrossini, verts); - this.initDefaultSprite(s_pathGrossini, s); + var ttfConfig = new cc.FontDefinition({ + fontName: "fonts/arial.ttf", + fontSize: 8 + }); + var temp = "Sprite:\nPixels drawn: "; + var spSize = this._sp.getContentSize(); + var spArea = new cc.LabelTTF(temp+Math.round(spSize.width*spSize.height), ttfConfig); + spArea.anchorX = 0; + spArea.anchorY = 1; + this._sp.addChild(spArea); + + temp = "PolygonSprite:\nPixels drawn: "; + var vertCount = "\nverts:"+Math.round(polygons.getVertCount()); + var sppArea = new cc.LabelTTF(temp+Math.round(polygons.getArea())+vertCount, ttfConfig); + sppArea.anchorX = 0; + sppArea.anchorY = 1; + this._spp.addChild(sppArea); + + this.initTouchDebugDraw(); } }); -var SpritePolygonTest3 = SpritePolygonTestDemo.extend({ - _title:"SpritePolygon Creation", - _subtitle:"SpritePolygon::create(\"Images/grossini.png\", verts, indices)", +var SpritePolygonTestSlider = SpritePolygonTestDemo.extend({ + _title:"Optimization Value (default:2.0)", + _subtitle:"", - ctor:function(){ + _ttfConfig: null, + _epsilonLabel: null, + + ctor: function () { this._super(); - var verts = []; - verts.push(cc.p(33.500000, 73.500000)); - verts.push(cc.p(27.500000, 73.500000)); - verts.push(cc.p(16.500000, 62.500000)); - verts.push(cc.p(30.500000, 44.500000)); - verts.push(cc.p(54.500000, 44.500000)); - verts.push(cc.p(51.500000, 73.500000)); - verts.push(cc.p(60.500000, 87.500000)); - verts.push(cc.p(26.500000, 80.500000)); - verts.push(cc.p(24.500000, 96.500000)); - verts.push(cc.p(57.500000, 108.500000)); - verts.push(cc.p(36.500000, 113.500000)); - verts.push(cc.p(48.500000, 114.500000)); - verts.push(cc.p(36.500000, 114.500000)); - verts.push(cc.p(27.500000, 108.500000)); - verts.push(cc.p(68.500000, 57.500000)); - verts.push(cc.p(57.500000, 73.500000)); - verts.push(cc.p(56.500000, 4.500000)); - verts.push(cc.p(28.500000, 4.500000)); - - var indices = [0, 1, 2, 3, 0, 2, 4, 0, 3, 5, 0, 4, 5, 6, 0, 0, 6, 7, 8, 7, 6, 6, 9, 8, 9, 10, 8, 9, 11, 10, 11, 12, 10, 8, 10, 13, 14, 5, 4, 15, 5, 14, 4, 3, 16, 3, 17, 16]; - - cc.SpritePolygonCache.getInstance().removeAllSpritePolygonCache(); - var s = ccexp.SpritePolygon.create(s_pathGrossini, verts, indices); - this.initDefaultSprite(s_pathGrossini, s); - } -}); - -var SpritePolygonTest4 = SpritePolygonTestDemo.extend({ - _title:"SpritePolygon Creation", - _subtitle: "SpritePolygon::create(\"Images/grossini.png\", \n\tvector v, vector indices)", - - ctor:function(){ - this._super(); - - var vec3 = []; - vec3.push(cc.math.vec3(33.500000, 73.500000,0)); - vec3.push(cc.math.vec3(27.500000, 73.500000,0)); - vec3.push(cc.math.vec3(16.500000, 62.500000,0)); - vec3.push(cc.math.vec3(30.500000, 44.500000,0)); - vec3.push(cc.math.vec3(54.500000, 44.500000,0)); - vec3.push(cc.math.vec3(51.500000, 73.500000,0)); - vec3.push(cc.math.vec3(60.500000, 87.500000,0)); - vec3.push(cc.math.vec3(26.500000, 80.500000,0)); - vec3.push(cc.math.vec3(24.500000, 96.500000,0)); - vec3.push(cc.math.vec3(57.500000, 108.500000,0)); - vec3.push(cc.math.vec3(36.500000, 113.500000,0)); - vec3.push(cc.math.vec3(48.500000, 114.500000,0)); - vec3.push(cc.math.vec3(36.500000, 114.500000,0)); - vec3.push(cc.math.vec3(27.500000, 108.500000,0)); - vec3.push(cc.math.vec3(68.500000, 57.500000,0)); - vec3.push(cc.math.vec3(57.500000, 73.500000,0)); - vec3.push(cc.math.vec3(56.500000, 4.500000,0)); - vec3.push(cc.math.vec3(28.500000, 4.50000, 0)); - - var t2f = []; - t2f.push(cc.p(0.394118, 0.392562)); - t2f.push(cc.p(0.323529, 0.392562)); - t2f.push(cc.p(0.194118, 0.483471)); - t2f.push(cc.p(0.358824, 0.632231)); - t2f.push(cc.p(0.641176, 0.632231)); - t2f.push(cc.p(0.605882, 0.392562)); - t2f.push(cc.p(0.711765, 0.276859)); - t2f.push(cc.p(0.311765, 0.334711)); - t2f.push(cc.p(0.288235, 0.202479)); - t2f.push(cc.p(0.676471, 0.103306)); - t2f.push(cc.p(0.429412, 0.061983)); - t2f.push(cc.p(0.570588, 0.053719)); - t2f.push(cc.p(0.429412, 0.053719)); - t2f.push(cc.p(0.323529, 0.103306)); - t2f.push(cc.p(0.805882, 0.524793)); - t2f.push(cc.p(0.676471, 0.392562)); - t2f.push(cc.p(0.664706, 0.962810)); - t2f.push(cc.p(0.335294, 0.962810)); - - var verts = []; - for(var i = 0; i < 18; ++i) + this._ttfConfig = new cc.FontDefinition({ + fontName: "fonts/arial.ttf", + fontSize: 8 + }); + + var vsize = cc.visibleRect; + var slider = new ccui.Slider(); + slider.setTouchEnabled(true); + slider.loadBarTexture("ccs-res/cocosui/sliderTrack.png"); + slider.loadSlidBallTextures("ccs-res/cocosui/sliderThumb.png", "ccs-res/cocosui/sliderThumb.png", ""); + slider.loadProgressBarTexture("ccs-res/cocosui/sliderProgress.png"); + slider.setPosition(vsize.width/2, vsize.height/4); + + slider.addEventListener(this.changeEpsilon, this); + slider.setPercent(Math.sqrt(1/19) * 100); + + this._epsilonLabel = new cc.LabelTTF("Epsilon: 2.0", this._ttfConfig); + this.addChild(this._epsilonLabel); + this._epsilonLabel.setPosition(vsize.width/2, vsize.height/4 + 15); + this.addChild(slider); + }, + makeSprites: function (list, y) { + var vsize = cc.visibleRect; + var offset = (vsize.width-100)/(list.length-1); + for(var i = 0; i < list.length; i++) { - var t = { - v3f:vec3[i], - c4b:cc.color.WHITE, - t2f:t2f[i] - }; - verts.push(t); + var sp = this.makeSprite(list[i], 50+offset*i, y); + this.addChild(sp); + sp.debugDraw(true); } - var indices = [0, 1, 2, 3, 0, 2, 4, 0, 3, 5, 0, 4, 5, 6, 0, 0, 6, 7, 8, 7, 6, 6, 9, 8, 9, 10, 8, 9, 11, 10, 11, 12, 10, 8, 10, 13, 14, 5, 4, 15, 5, 14, 4, 3, 16, 3, 17, 16]; + }, + makeSprite: function (filename, x, y) { + var sp = new cc.Sprite(filename); + var quadSize = sp.getContentSize(); + var originalSize = quadSize.width * quadSize.height; + var polygons = jsb.AutoPolygon.generatePolygon(filename); + var ret = new cc.Sprite(polygons); + ret.setPosition(x, y); + + var pixels = polygons.getArea()/originalSize*100; + var spArea = new cc.LabelTTF(filename+"\nVerts: "+polygons.getVertCount()+ "\nPixels: "+pixels.toFixed(2)+"%", this._ttfConfig); + ret.addChild(spArea); + spArea.setAnchorPoint(cc.p(0,1)); + ret.setName(filename); + ret.setAnchorPoint(cc.p(0.5, 0)); + return ret; + }, + updateLabel: function (sp, polygons) { + var label = sp.getChildren()[0]; + var filename = sp.getName(); + var w = polygons.rect.width/cc.director.getContentScaleFactor(); + var h = polygons.rect.width/cc.director.getContentScaleFactor(); + var pixels = polygons.getArea()/(w*h)*100; + label.string = filename+"\nVerts: "+polygons.getVertCount()+"\nPixels: "+pixels.toFixed(2)+"%"; + }, + changeEpsilon: function (sender, type) { + if (type == ccui.Slider.EVENT_PERCENT_CHANGED) { + var epsilon = Math.pow(sender.getPercent()/100, 2) * 19 + 1; + var children = this.children, child, file; + for(var i = 0; i < children.length; i++) { + child = children[i]; + file = child.getName(); + if(file.length) { + var polygons = jsb.AutoPolygon.generatePolygon(file, cc.rect(), epsilon); + child.setPolygonInfo(polygons); + child.debugDraw(true); + this.updateLabel(child, polygons); + } + } + this._epsilonLabel.setString("Epsilon: "+ epsilon.toFixed(2)); + } + } +}); - cc.SpritePolygonCache.getInstance().removeAllSpritePolygonCache(); - var s = ccexp.SpritePolygon.create(s_pathGrossini, verts, indices); - this.initDefaultSprite(s_pathGrossini, s); +var SpritePolygonTest3 = SpritePolygonTestSlider.extend({ + _title:"Optimization Value (default:2.0)", + _subtitle:"", + + ctor:function(){ + this._super(); + + var vsize = cc.visibleRect; + var list = [ + "Images/arrows.png", + "Images/CyanTriangle.png", + s_pathB2, + "Images/elephant1_Diffuse.png" + ]; + this.makeSprites(list, vsize.height/2); + } +}); + +var SpritePolygonTest4 = SpritePolygonTestSlider.extend({ + _title:"Optimization Value (default:2.0)", + _subtitle: "", + + ctor:function(){ + this._super(); + + var vsize = cc.visibleRect; + var list = [ + s_pathGrossini, + "Images/grossinis_sister1.png", + "Images/grossinis_sister2.png" + ]; + this.makeSprites(list, vsize.height/2); } -}) +}); + +var SpritePolygonPerformance = SpritePolygonTestDemo.extend({ + spriteCount: 0, + vertCount: 0, + triCount: 0, + pixelCount: 0, + elapsedTime: 0, + perfLabel: null, + continuousLowDt: 0, + continuousHighDtTime: 0, + waitingTime: 0, + _posX: 0, + _posY: 0, + _leftX: 0, + _rightX: 0, + goRight: true, + ended: false, + prevDt: 0, + _incVert: 0, + _incTri: 0, + _incPix: 0, + ctor: function () { + this._super(); + var ttfConfig = new cc.FontDefinition({ + fontName: "fonts/arial.ttf", + fontSize: 10 + }); + this.perfLabel = new cc.LabelTTF("Performance test", ttfConfig); + this.addChild(this.perfLabel); + this.perfLabel.setPosition(cc.visibleRect.width/2, 80); + + var size = cc.visibleRect; + this._posX = this._leftX = size.width*0.15; + this._rightX = size.width*0.85; + this._posY = size.height/2; + this.prevDt = 0.016; + this.goRight = true; + this.ended = false; + this.scheduleUpdate(); + }, + updateLabel: function () { + var temp = "Nodes: "+this.spriteCount+" Triangles: "+this.triCount+"\nPixels: "+this.pixelCount.toFixed(2)+" Vertices: "+this.vertCount; + if(!this.ended) + this.perfLabel.string = temp; + }, + makeSprite: function () { + return new cc.Node(); + }, + update: function (dt) { + dt = dt*0.3 + this.prevDt*0.7; + this.prevDt = dt; + this.elapsedTime += dt; + var loops = (0.025-dt)*1000; + if(dt < 0.025 && loops>0) + { + this.continuousHighDtTime = cc.clampf(this.continuousHighDtTime-dt*2, 0.0, 1.0); + this.waitingTime = cc.clampf(this.waitingTime-dt, 0.0, 5.0); + this.continuousLowDt++; + } + else + { + this.continuousHighDtTime+=dt; + this.continuousLowDt = 0; + } + if (this.continuousLowDt >= 5 && loops > 0) { + for(var i = 0; i < loops; i++) + { + if(this._posX >= this._rightX) + { + this.goRight = false; + } + else if(this._posX <= this._leftX) + { + this.goRight = true; + } + var s = this.makeSprite(); + this.addChild(s); + s.setPosition(this._posX, this._posY); + if(this.goRight) + this._posX++; + else + this._posX--; + + this.incrementStats(); + } + this.updateLabel(); + } + + //if we have 10 continuous low dt, then we will start to create more sprites + else if(this.continuousHighDtTime >= 0.5 || this.waitingTime > 3.0){ + // its now 1 seconds with high DT time, time to end + this.ended = true; + this.unscheduleUpdate(); + this.perfLabel.string = "Test ended in " + this.elapsedTime + " seconds\nNodes: " + this.spriteCount + " Triangles: " + this.triCount + "\nPixels: " + this.pixelCount.toFixed() + " Vertices: " + this.vertCount; + this.getChildByTag(BASE_TEST_SUBTITLE_TAG).string = "Test ended"; + } + else{ + this.waitingTime += dt; + } + }, + incrementStats: function () { + this.spriteCount ++; + this.vertCount += this._incVert; + this.triCount += this._incTri; + this.pixelCount += this._incPix; + } +}); + +var SpritePolygonPerformanceTestDynamic = SpritePolygonPerformance.extend({ + _title: "Dynamic SpritePolygon Performance", + _subtitle: "Test running, please wait until it ends", + _polygons: null, + ctor: function () { + this._super(); + this._polygons = jsb.AutoPolygon.generatePolygon(s_pathGrossini); + this.initIncrementStats(); + }, + initIncrementStats: function () { + this._incVert = this._polygons.getVertCount(); + this._incTri = this._polygons.getTriaglesCount(); + this._incPix = this._polygons.getArea(); + }, + makeSprite: function () { + var ret = new cc.Sprite(this._polygons); + ret.runAction(cc.rotateBy(1,360).repeatForever()); + return ret; + } +}); + +var SpritePerformanceTestDynamic = SpritePolygonPerformance.extend({ + _title: "Dynamic Sprite Performance", + _subtitle: "Test running, please wait until it ends", + ctor: function () { + this._super(); + this.initIncrementStats(); + }, + initIncrementStats: function () { + var t = new cc.Sprite(s_pathGrossini); + this._incVert = 4; + this._incTri = 2; + this._incPix = t.width * t.height; + }, + makeSprite: function () { + var ret = new cc.Sprite(s_pathGrossini); + ret.runAction(cc.rotateBy(1,360).repeatForever()); + return ret; + } +}); + // // Flow control // @@ -287,7 +466,9 @@ var arrayOfSpritePolygonTest = [ SpritePolygonTest1, SpritePolygonTest2, SpritePolygonTest3, - SpritePolygonTest4 + SpritePolygonTest4, + SpritePolygonPerformanceTestDynamic, + SpritePerformanceTestDynamic ]; var nextSpritePolygonTest = function () { diff --git a/tests/js-tests/src/tests_resources.js b/tests/js-tests/src/tests_resources.js index 943d7e3d89..2cad6d76b4 100644 --- a/tests/js-tests/src/tests_resources.js +++ b/tests/js-tests/src/tests_resources.js @@ -1096,3 +1096,6 @@ var g_ccs2 = [ "ccs-res/cocosui/UIEditorTest/UILabelBMFont_Editor/GUI/missing-font.fnt", "ccs-res/cocosui/UIEditorTest/UILabelBMFont_Editor/GUI/missing-font.png" ]; + +res.CCControlColourPickerSpriteSheet_plist = "extensions/CCControlColourPickerSpriteSheet.plist"; +res.CCControlColourPickerSpriteSheet_png = "extensions/CCControlColourPickerSpriteSheet.png"; \ No newline at end of file diff --git a/tests/lua-tests/src/Physics3DTest/Physics3DTest.lua b/tests/lua-tests/src/Physics3DTest/Physics3DTest.lua index 0e47383996..1594bbed8e 100644 --- a/tests/lua-tests/src/Physics3DTest/Physics3DTest.lua +++ b/tests/lua-tests/src/Physics3DTest/Physics3DTest.lua @@ -63,7 +63,7 @@ function Physics3DTestDemo:shootBox(des) self:addChild(sprite) sprite:setPosition3D(self._camera:getPosition3D()) sprite:setScale(0.5) - sprite:syncToNode() + sprite:syncNodeToPhysics() --optimize, only sync node to physics sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE) --sync node to physics @@ -184,7 +184,7 @@ function BasicPhysics3DDemo:extend() floor:setScaleZ(60) self:addChild(floor) floor:setCameraMask(cc.CameraFlag.USER1) - floor:syncToNode() + floor:syncNodeToPhysics() floor:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE) rbDes.mass = 1.0 @@ -204,7 +204,7 @@ function BasicPhysics3DDemo:extend() local sprite = cc.PhysicsSprite3D:create("Sprite3DTest/box.c3t", rbDes) sprite:setTexture("Images/CyanSquare.png") sprite:setPosition3D(cc.vec3(x, y, z)) - sprite:syncToNode() + sprite:syncNodeToPhysics() sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE) sprite:setCameraMask(cc.CameraFlag.USER1) sprite:setScale(0.8) @@ -332,7 +332,7 @@ function Physics3DConstraintDemo:extend() sprite:setScale(0.4) sprite:setPosition3D(cc.vec3(-20.0, 5.0, 0.0)) --sync node position to physics - component:syncToNode() + component:syncNodeToPhysics() --physics controlled, we will not set position for it, so we can skip sync node position to physics component:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE) @@ -356,7 +356,7 @@ function Physics3DConstraintDemo:extend() sprite:addComponent(component) sprite:setCameraMask(cc.CameraFlag.USER1) self:addChild(sprite) - component:syncToNode() + component:syncNodeToPhysics() rigidBody:setAngularVelocity(cc.vec3(0,3,0)) constraint = cc.Physics3DHingeConstraint:create(rigidBody, cc.vec3(4.0, 4.0, 0.5), cc.vec3(0.0, 1.0, 0.0)) physicsWorld:addPhysics3DConstraint(constraint) @@ -374,7 +374,7 @@ function Physics3DConstraintDemo:extend() sprite:addComponent(component) sprite:setCameraMask(cc.CameraFlag.USER1) self:addChild(sprite) - component:syncToNode() + component:syncNodeToPhysics() rigidBody:setLinearVelocity(cc.vec3(0,3,0)) rbDes.mass = 0.0 @@ -388,7 +388,7 @@ function Physics3DConstraintDemo:extend() sprite:addComponent(component) sprite:setCameraMask(cc.CameraFlag.USER1) self:addChild(sprite) - component:syncToNode() + component:syncNodeToPhysics() local frameInA = cc.mat4.createRotationZ(cc.mat4.createIdentity(), math.pi / 2) local frameInB = frameInA @@ -411,7 +411,7 @@ function Physics3DConstraintDemo:extend() sprite:addComponent(component) sprite:setCameraMask(cc.CameraFlag.USER1) self:addChild(sprite) - component:syncToNode() + component:syncNodeToPhysics() frameInA = cc.mat4.createRotationZ(frameInA, math.pi / 2) frameInA[13] = 0.0 @@ -433,7 +433,7 @@ function Physics3DConstraintDemo:extend() sprite:addComponent(component) sprite:setCameraMask(cc.CameraFlag.USER1) self:addChild(sprite) - component:syncToNode() + component:syncNodeToPhysics() frameInA = cc.mat4.setIdentity(frameInA) constraint = cc.Physics3D6DofConstraint:create(rigidBody, frameInA, false) physicsWorld:addPhysics3DConstraint(constraint) @@ -463,7 +463,7 @@ function Physics3DKinematicDemo:extend() floor:setPosition3D(cc.vec3(0.0, -1.0, 0.0)) self:addChild(floor) floor:setCameraMask(cc.CameraFlag.USER1) - floor:syncToNode() + floor:syncNodeToPhysics() --static object sync is not needed floor:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE) @@ -514,7 +514,7 @@ function Physics3DKinematicDemo:extend() sprite:setScale(1.00 / sprite:getContentSize().width) self:addChild(sprite) sprite:setPosition3D(cc.vec3(x, y, z)) - sprite:syncToNode() + sprite:syncNodeToPhysics() sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE) end end @@ -608,7 +608,7 @@ function Physics3DTerrainDemo:extend() local component = cc.Physics3DComponent:create(rigidBody) terrain:addComponent(component) self:addChild(terrain) - component:syncToNode() + component:syncNodeToPhysics() component:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.NONE) --create several spheres @@ -631,7 +631,7 @@ function Physics3DTerrainDemo:extend() sprite:setScale(1.0 / sprite:getContentSize().width) sprite:setPosition3D(cc.vec3(x, y, z)) self:addChild(sprite) - sprite:syncToNode() + sprite:syncNodeToPhysics() sprite:setSyncFlag(cc.Physics3DComponent.PhysicsSyncFlag.PHYSICS_TO_NODE) end end diff --git a/tests/lua-tests/src/SpritePolygonTest/SpritePolygonTest.lua b/tests/lua-tests/src/SpritePolygonTest/SpritePolygonTest.lua index e8afdbb11d..3d30986394 100644 --- a/tests/lua-tests/src/SpritePolygonTest/SpritePolygonTest.lua +++ b/tests/lua-tests/src/SpritePolygonTest/SpritePolygonTest.lua @@ -88,29 +88,45 @@ local SpritePolygonTest1 = class("SpritePolygonTest1", function () return layer end) +function SpritePolygonTest1:make2Sprites() + -- body +end function SpritePolygonTest1:ctor() - cc.SpritePolygonCache:getInstance():removeAllSpritePolygonCache() - local spp = ccexp.SpritePolygon:create(imageFileName) - cc.Director:getInstance():setClearColor(cc.c4f(102.0/255, 184.0/255, 204.0/255, 255.0)) - self:addChild(spp) local s = cc.Director:getInstance():getWinSize() local offset = cc.p(0.15 * s.width, 0) - spp:setPosition(s.width/2 + 0.15 * s.width, s.height/2) + local filename = s_pPathGrossini + local info = cc.AutoPolygon:generatePolygon(filename) + local spp = cc.Sprite:create(info) + self:addChild(spp) + spp:setPosition(cc.p(s.width / 2 + offset.x, s.height / 2 + offset.y)) - local sp = cc.Sprite:create(imageFileName) + sp = cc.Sprite:create(filename) self:addChild(sp) - sp:setPosition(s.width/2 - 0.15 * s.width, s.height/2) + sp:setPosition(cc.p(s.width/2 - offset.x, s.height/2 - offset.y)) - local debugForNormalSprite = cc.DrawNode:create() - sp:addChild(debugForNormalSprite) + local ttfConfig = {} + ttfConfig.fontFilePath = "fonts/arial.ttf" + ttfConfig.fontSize = 8 + + local temp = "Sprite:\nPixels drawn: " + local spSize = sp:getContentSize() + local spArea = cc.Label:createWithTTF(ttfConfig, temp .. (spSize.width * spSize.height)) + sp:addChild(spArea) + spArea:setAnchorPoint(cc.p(0, 1)) + + temp = "SpritePolygon:\nPixels drawn: " + local vertCount = "\nverts:" .. info:getVertCount() + local sppArea = cc.Label:createWithTTF(ttfConfig, temp .. info:getArea() .. vertCount) + spp:addChild(sppArea) + sppArea:setAnchorPoint(cc.p(0, 1)) local touchListener = cc.EventListenerTouchOneByOne:create() touchListener:registerScriptHandler(function (touch, event) - spp:showDebug(true) - debugForNormalSprite:setVisible(true) + sp:debugDraw(true) + spp:debugDraw(true) return true end,cc.Handler.EVENT_TOUCH_BEGAN) @@ -122,42 +138,13 @@ function SpritePolygonTest1:ctor() end,cc.Handler.EVENT_TOUCH_MOVED) touchListener:registerScriptHandler(function (touch, event) - spp:showDebug(false) - debugForNormalSprite:setVisible(false) + sp:debugDraw(false) + spp:debugDraw(false) end,cc.Handler.EVENT_TOUCH_ENDED) local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, self) - - local positions = {} - local spSize = sp:getContentSize() - positions[1] = cc.p(0, spSize.height) - positions[2] = cc.p(spSize.width, spSize.height) - positions[3] = cc.p(spSize.width, 0) - positions[4] = cc.p(0,0) - debugForNormalSprite:drawPoints(positions, 4, 8, cc.c4f(0.0,1.0,1.0,1.0)) - debugForNormalSprite:drawLine(positions[1], positions[2], cc.c4f(0.0,1.0,0.0,1.0)) - debugForNormalSprite:drawLine(positions[2], positions[3], cc.c4f(0.0,1.0,0.0,1.0)) - debugForNormalSprite:drawLine(positions[3], positions[4], cc.c4f(0.0,1.0,0.0,1.0)) - debugForNormalSprite:drawLine(positions[4], positions[1], cc.c4f(0.0,1.0,0.0,1.0)) - debugForNormalSprite:drawLine(positions[1], positions[3], cc.c4f(0.0,1.0,0.0,1.0)) - debugForNormalSprite:setVisible(false) - - local ttfConfig = {} - ttfConfig.fontFilePath = "fonts/arial.ttf" - ttfConfig.fontSize = 8 - local temp = "Sprite:\nPixels drawn: ".. spSize.width*spSize.height - local spArea = cc.Label:createWithTTF(ttfConfig, temp) - sp:addChild(spArea) - spArea:setAnchorPoint(cc.p(0,1)) - - temp = "SpritePolygon:\nPixels drawn: " - local vertCount = "\nverts:" .. spp:getVertCount() - local sppArea = cc.Label:createWithTTF(ttfConfig, temp .. spp:getArea() .. vertCount) - spp:addChild(sppArea) - sppArea:setAnchorPoint(cc.p(0,1)) - Helper.initWithLayer(self) Helper.titleLabel:setString(self:title()) Helper.subtitleLabel:setString(self:subtitle()) @@ -178,7 +165,7 @@ function SpritePolygonTest1:title() end function SpritePolygonTest1:subtitle() - return "SpritePolygon:create(\"Images/grossini.png\")" + return "Sprite:create(AutoPolygon:generatePolygon(filename))" end function SpritePolygonTest1:onEnter() @@ -197,38 +184,86 @@ local SpritePolygonTest2 = class("SpritePolygonTest2", function () return layer end) -function SpritePolygonTest2:ctor() - local verts = {} - verts[1]= cc.p(36.5, 242.0-128.5) - verts[2]= cc.p(27.5, 242.0-133.5) - verts[3]= cc.p(24.5, 242.0-145.5) - verts[4]= cc.p(26.5, 242.0-161.5) - verts[5]= cc.p(33.5, 242.0-168.5) - verts[6]= cc.p(27.5, 242.0-168.5) - verts[7]= cc.p(16.5, 242.0-179.5) - verts[8]= cc.p(30.5, 242.0-197.5) - verts[9]= cc.p(28.5, 242.0-237.5) - verts[10]= cc.p(56.5, 242.0-237.5) - verts[11]= cc.p(54.5, 242.0-197.5) - verts[12]= cc.p(68.5, 242.0-184.5) - verts[13]= cc.p(57.5, 242.0-168.5) - verts[14]= cc.p(51.5, 242.0-168.5) - verts[15]= cc.p(60.5, 242.0-154.5) - verts[16]= cc.p(57.5, 242.0-133.5) - verts[17]= cc.p(48.5, 242.0-127.5) - verts[18]= cc.p(36.5, 242.0-127.5) +function SpritePolygonTest2:make2Sprites() + local s = cc.Director:getInstance():getWinSize() + local offset = cc.p(0.15 * s.width, 0) + local filename = s_pPathGrossini + local head = cc.rect(30, 25, 25, 25) + local info = cc.AutoPolygon:generatePolygon(filename, head) + self.spp = cc.Sprite:create(info) + self:addChild(self.spp) + self.spp:setPosition(cc.p(s.width / 2 + offset.x, s.height / 2 + offset.y)) + + + self.sp = cc.Sprite:create(filename,head) + self:addChild(self.sp) + self.sp:setPosition(cc.p(s.width/2 - offset.x, s.height/2 - offset.y)) + + + local ttfConfig = {} + ttfConfig.fontFilePath = "fonts/arial.ttf" + ttfConfig.fontSize = 8 + + local temp = "Sprite:\nPixels drawn: " + local spSize = self.sp:getContentSize() + local spArea = cc.Label:createWithTTF(ttfConfig, temp .. (spSize.width * spSize.height)) + self.sp:addChild(spArea) + spArea:setAnchorPoint(cc.p(0, 1)) + + temp = "SpritePolygon:\nPixels drawn: " + local vertCount = "\nverts:" .. info:getVertCount() + local sppArea = cc.Label:createWithTTF(ttfConfig, temp .. info:getArea() .. vertCount) + self.spp:addChild(sppArea) + sppArea:setAnchorPoint(cc.p(0, 1)) +end + +function SpritePolygonTest2:ctor() + self:make2Sprites() + + local touchListener = cc.EventListenerTouchOneByOne:create() + touchListener:registerScriptHandler(function (touch, event) + self.sp:debugDraw(true) + self.spp:debugDraw(true) + return true + end,cc.Handler.EVENT_TOUCH_BEGAN) + + touchListener:registerScriptHandler(function (touch, event) + local pos = touch:getDelta() + local newScale = cc.clampf(self.spp:getScale()+pos.x*0.01, 0.1, 2) + self.spp:setScale(newScale) + self.sp:setScale(newScale) + end,cc.Handler.EVENT_TOUCH_MOVED) + + touchListener:registerScriptHandler(function (touch, event) + self.sp:debugDraw(false) + self.spp:debugDraw(false) + end,cc.Handler.EVENT_TOUCH_ENDED) + + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, self) + + Helper.initWithLayer(self) + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) + + local function onNodeEvent(event) + if "enter" == event then + self:onEnter() + elseif "exit" == event then + self:onExit() + end + end + + self:registerScriptHandler(onNodeEvent) - cc.SpritePolygonCache:getInstance():removeAllSpritePolygonCache() - local s = ccexp.SpritePolygon:create(imageFileName, verts) - initDefaultSprite(imageFileName, s, self) end function SpritePolygonTest2:title() - return "SpritePolygon Creation" + return "SpritePolygon Creation with a rect" end function SpritePolygonTest2:subtitle() - return "SpritePolygon:create(\"Images/grossini.png\", verts)" + return "Sprite:create(AutoPolygon:generatePolygon(filename, rect))" end function SpritePolygonTest2:onEnter() @@ -239,7 +274,6 @@ function SpritePolygonTest2:onExit() cc.Director:getInstance():setClearColor(cc.c4f(0.0, 0.0, 0.0, 1.0)) end - ---------------------------------------- ----SpritePolygonTest3 ---------------------------------------- @@ -248,41 +282,115 @@ local SpritePolygonTest3 = class("SpritePolygonTest3", function () return layer end) +function SpritePolygonTest3:makeSprite(filename, pos) + local quadSize = cc.Sprite:create(filename):getContentSize() + local originalSize = quadSize.width * quadSize.height + local info = cc.AutoPolygon:generatePolygon(filename) + local ret = cc.Sprite:create(info) + ret:setPosition(pos) + + local spArea = cc.Label:createWithTTF(self._ttfConfig, filename .. "\nVerts: " .. info:getVertCount() .. "\nPixels: " .. math.floor(info:getArea() / originalSize * 100) .. "%") + ret:addChild(spArea) + spArea:setAnchorPoint(cc.p(0,1)) + ret:setName(filename) + ret:setAnchorPoint(cc.p(0.5, 0)) + return ret +end + +function SpritePolygonTest3:makeSprites(list, count, y) + local vsize = cc.Director:getInstance():getVisibleSize() + local offset = (vsize.width - 100) / (count - 1) + for i = 1, count do + local sp = self:makeSprite(list[i], cc.p(50 + offset * (i - 1), y)) + self:addChild(sp) + sp:debugDraw(true) + end +end + +function SpritePolygonTest3:updateLabel(sprite, polygonInfo) + local label = sprite:getChildren()[1] + local filename = sprite:getName() + local scaleFactor = cc.Director:getInstance():getContentScaleFactor() + local size = cc.size(polygonInfo.rect.width / scaleFactor , polygonInfo.rect.height / scaleFactor ) + local labelInfo = filename .. "\nVerts: " .. polygonInfo:getVertCount() .. "\nPixels: " .. math.floor(polygonInfo:getArea() / (size.width*size.height)*100) .. "%" + label:setString(labelInfo) +end + function SpritePolygonTest3:ctor() - local verts = {} - verts[1] = cc.p(33.500000, 73.500000) - verts[2] = cc.p(27.500000, 73.500000) - verts[3] = cc.p(16.500000, 62.500000) - verts[4] = cc.p(30.500000, 44.500000) - verts[5] = cc.p(54.500000, 44.500000) - verts[6] = cc.p(51.500000, 73.500000) - verts[7] = cc.p(60.500000, 87.500000) - verts[8] = cc.p(26.500000, 80.500000) - verts[9] = cc.p(24.500000, 96.500000) - verts[10] = cc.p(57.500000, 108.500000) - verts[11] = cc.p(36.500000, 113.500000) - verts[12] = cc.p(48.500000, 114.500000) - verts[13] = cc.p(36.500000, 114.500000) - verts[14] = cc.p(27.500000, 108.500000) - verts[15] = cc.p(68.500000, 57.500000) - verts[16] = cc.p(57.500000, 73.500000) - verts[17] = cc.p(56.500000, 4.500000) - verts[18] = cc.p(28.500000, 4.500000) + self._ttfConfig = {} + self._ttfConfig.fontFilePath = "fonts/arial.ttf" + self._ttfConfig.fontSize = 8 - local indices = {0, 1, 2, 3, 0, 2, 4, 0, 3, 5, 0, 4, 5, 6, 0, 0, 6, 7, 8, 7, 6, 6, 9, 8, 9, 10, 8, 9, 11, 10, 11, 12, 10, 8, 10, 13, 14, 5, 4, 15, 5, 14, 4, 3, 16, 3, 17, 16} + local vsize = cc.Director:getInstance():getVisibleSize() + local slider = ccui.Slider:create() + slider:loadBarTexture("cocosui/sliderTrack.png") + slider:loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "") + slider:loadProgressBarTexture("cocosui/sliderProgress.png") + slider:setPosition(cc.p(vsize.width/2, vsize.height/4)) + - cc.SpritePolygonCache:getInstance():removeAllSpritePolygonCache() - local s = ccexp.SpritePolygon:create(imageFileName, verts, indices) - initDefaultSprite(imageFileName, s, self) + local function percentChangedEvent(sender,eventType) + if eventType == ccui.SliderEventType.percentChanged then + local slider = sender + local percent = "Percent " .. slider:getPercent() + self._displayValueLabel:setString(percent) + end + end + + slider:addEventListener(function(sender, eventType) + local epsilon = math.pow(sender:getPercent() / 100.0 , 2) * 19.0 + 1.0 + local children = self:getChildren() + for i = 1, #children do + local child = children[i] + if child:getName() ~= nil and child:getName() ~= "" then + local file = child:getName() + local info = cc.AutoPolygon:generatePolygon(file, cc.rect(0, 0, 0, 0), epsilon) + child:setPolygonInfo(info) + child:debugDraw(true) + self:updateLabel(child, info) + end + + end + self._epsilonLabel:setString("Epsilon: " .. epsilon) + end) + slider:setPercent(math.sqrt(1.0 /19.0 )*100) + + self._epsilonLabel = cc.Label:createWithTTF(self._ttfConfig, "Epsilon: 2.0") + self:addChild(self._epsilonLabel) + self._epsilonLabel:setPosition(cc.p(vsize.width/2, vsize.height/4 + 15)) + self:addChild(slider) + + local list = { + "Images/arrows.png", + "Images/CyanTriangle.png", + s_pPathB2, + "Images/elephant1_Diffuse.png" + } + local count = 4 + self:makeSprites(list, count, vsize.height / 2) + + local function onNodeEvent(event) + if "enter" == event then + self:onEnter() + elseif "exit" == event then + self:onExit() + end + end + + self:registerScriptHandler(onNodeEvent) + + Helper.initWithLayer(self) + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) end function SpritePolygonTest3:title() - return "SpritePolygon Creation" + return "Optimization Value (default:2.0)" end function SpritePolygonTest3:subtitle() - return "SpritePolygon::create(\"Images/grossini.png\", verts, indices)" + return "" end function SpritePolygonTest3:onEnter() @@ -303,82 +411,113 @@ local SpritePolygonTest4 = class("SpritePolygonTest4", function () end) function SpritePolygonTest4:ctor() - local poss = { - cc.vec3(33.500000, 73.500000,0), - cc.vec3(27.500000, 73.500000,0), - cc.vec3(16.500000, 62.500000,0), - cc.vec3(30.500000, 44.500000,0), - cc.vec3(54.500000, 44.500000,0), - cc.vec3(51.500000, 73.500000,0), - cc.vec3(60.500000, 87.500000,0), - cc.vec3(26.500000, 80.500000,0), - cc.vec3(24.500000, 96.500000,0), - cc.vec3(57.500000, 108.500000,0), - cc.vec3(36.500000, 113.500000,0), - cc.vec3(48.500000, 114.500000,0), - cc.vec3(36.500000, 114.500000,0), - cc.vec3(27.500000, 108.500000,0), - cc.vec3(68.500000, 57.500000,0), - cc.vec3(57.500000, 73.500000,0), - cc.vec3(56.500000, 4.500000,0), - cc.vec3(28.500000, 4.50000, 0), + self._ttfConfig = {} + self._ttfConfig.fontFilePath = "fonts/arial.ttf" + self._ttfConfig.fontSize = 8 + + local vsize = cc.Director:getInstance():getVisibleSize() + + local slider = ccui.Slider:create() + slider:loadBarTexture("cocosui/sliderTrack.png") + slider:loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "") + slider:loadProgressBarTexture("cocosui/sliderProgress.png") + slider:setPosition(cc.p(vsize.width/2, vsize.height/4)) + + + local function percentChangedEvent(sender,eventType) + if eventType == ccui.SliderEventType.percentChanged then + local slider = sender + local percent = "Percent " .. slider:getPercent() + self._displayValueLabel:setString(percent) + end + end + + slider:addEventListener(function(sender, eventType) + local epsilon = math.pow(sender:getPercent() / 100.0 , 2) * 19.0 + 1.0 + local children = self:getChildren() + for i = 1, #children do + local child = children[i] + if child:getName() ~= nil and child:getName() ~= "" then + local file = child:getName() + local info = cc.AutoPolygon:generatePolygon(file, cc.rect(0, 0, 0, 0), epsilon) + child:setPolygonInfo(info) + child:debugDraw(true) + self:updateLabel(child, info) + end + + end + self._epsilonLabel:setString("Epsilon: " .. epsilon) + end) + slider:setPercent(math.sqrt(1.0 /19.0 )*100) + + self._epsilonLabel = cc.Label:createWithTTF(self._ttfConfig, "Epsilon: 2.0") + self:addChild(self._epsilonLabel) + self._epsilonLabel:setPosition(cc.p(vsize.width/2, vsize.height/4 + 15)) + self:addChild(slider) + + local list = { + imageFileName, + "Images/grossinis_sister1.png", + "Images/grossinis_sister2.png", } + local count = 3 + self:makeSprites(list, count, vsize.height / 2) - local indices = {0, 1, 2, 3, 0, 2, 4, 0, 3, 5, 0, 4, 5, 6, 0, 0, 6, 7, 8, 7, 6, 6, 9, 8, 9, 10, 8, 9, 11, 10, 11, 12, 10, 8, 10, 13, 14, 5, 4, 15, 5, 14, 4, 3, 16, 3, 17, 16} + local function onNodeEvent(event) + if "enter" == event then + self:onEnter() + elseif "exit" == event then + self:onExit() + end + end - local t2f = { - cc.tex2F(0.394118, 0.392562), - cc.tex2F(0.323529, 0.392562), - cc.tex2F(0.194118, 0.483471), - cc.tex2F(0.358824, 0.632231), - cc.tex2F(0.641176, 0.632231), - cc.tex2F(0.605882, 0.392562), - cc.tex2F(0.711765, 0.276859), - cc.tex2F(0.311765, 0.334711), - cc.tex2F(0.288235, 0.202479), - cc.tex2F(0.676471, 0.103306), - cc.tex2F(0.429412, 0.061983), - cc.tex2F(0.570588, 0.053719), - cc.tex2F(0.429412, 0.053719), - cc.tex2F(0.323529, 0.103306), - cc.tex2F(0.805882, 0.524793), - cc.tex2F(0.676471, 0.392562), - cc.tex2F(0.664706, 0.962810), - cc.tex2F(0.335294, 0.962810), - } + self:registerScriptHandler(onNodeEvent) - local v3f_c4b_t2f_table = { - { vertices = poss[1], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[1]}, - { vertices = poss[2], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[2]}, - { vertices = poss[3], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[3]}, - { vertices = poss[4], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[4]}, - { vertices = poss[5], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[5]}, - { vertices = poss[6], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[6]}, - { vertices = poss[7], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[7]}, - { vertices = poss[8], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[8]}, - { vertices = poss[9], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[9]}, - { vertices = poss[10], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[10]}, - { vertices = poss[11], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[11]}, - { vertices = poss[12], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[12]}, - { vertices = poss[13], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[13]}, - { vertices = poss[14], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[14]}, - { vertices = poss[15], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[15]}, - { vertices = poss[16], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[16]}, - { vertices = poss[17], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[17]}, - { vertices = poss[18], colors = cc.c4b(255, 255, 255, 255), texCoords = t2f[18]}, - } - - cc.SpritePolygonCache:getInstance():removeAllSpritePolygonCache() - local s = ccexp.SpritePolygon:create(imageFileName, v3f_c4b_t2f_table, indices) - initDefaultSprite(imageFileName, s, self) + Helper.initWithLayer(self) + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) end function SpritePolygonTest4:title() - return "SpritePolygon Creation" + return "Optimization Value (default:2.0)" end function SpritePolygonTest4:subtitle() - return "SpritePolygon::create(\"Images/grossini.png\", vector v, vector indices)" + return "" +end + +function SpritePolygonTest4:updateLabel(sprite, polygonInfo) + local label = sprite:getChildren()[1] + local filename = sprite:getName() + local rectSize = cc.size(polygonInfo.rect.width, polygonInfo.rect.height) + local size = cc.size(rectSize.width / cc.Director:getInstance():getContentScaleFactor(), rectSize.height / cc.Director:getInstance():getContentScaleFactor()) + local labelInfo = filename .. "\nVerts: " .. polygonInfo:getVertCount() .. "\nPixels: " .. math.floor(polygonInfo:getArea() / (size.width*size.height)*100) .. "%" + label:setString(labelInfo) +end + +function SpritePolygonTest4:makeSprite(filename, pos) + local quadSize = cc.Sprite:create(filename):getContentSize() + local originalSize = quadSize.width * quadSize.height + local info = cc.AutoPolygon:generatePolygon(filename) + local ret = cc.Sprite:create(info) + ret:setPosition(pos) + + local spArea = cc.Label:createWithTTF(self._ttfConfig, filename .. "\nVerts: " .. info:getVertCount() .. "\nPixels: " .. math.floor(info:getArea() / originalSize * 100) .. "%") + ret:addChild(spArea) + spArea:setAnchorPoint(cc.p(0,1)) + ret:setName(filename) + ret:setAnchorPoint(cc.p(0.5, 0)) + return ret +end + +function SpritePolygonTest4:makeSprites(list, count, y) + local vsize = cc.Director:getInstance():getVisibleSize() + local offset = (vsize.width - 100) / (count - 1) + for i = 1, count do + local sp = self:makeSprite(list[i], cc.p(50 + offset * (i - 1), y)) + self:addChild(sp) + sp:debugDraw(true) + end end function SpritePolygonTest4:onEnter() @@ -389,6 +528,207 @@ function SpritePolygonTest4:onExit() cc.Director:getInstance():setClearColor(cc.c4f(0.0, 0.0, 0.0, 1.0)) end + +---------------------------------------- +----SpritePolygonPerformance +---------------------------------------- +local SpritePolygonPerformance = class("SpritePolygonPerformance", function () + local layer = cc.Layer:create() + return layer +end) + + +function SpritePolygonPerformance:ctor() + Helper.initWithLayer(self) + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) + + self:init() + self:initExtend() + + local function onNodeEvent(event) + if "enter" == event then + self:onEnter() + elseif "exit" == event then + self:onExit() + end + end + + self:registerScriptHandler(onNodeEvent) +end + +function SpritePolygonPerformance:title() + return "SpritePolygonPerformance" +end + +function SpritePolygonPerformance:subtitle() + return "" +end + +function SpritePolygonPerformance:updateLabel() + local temp = "Nodes: " .. self._spriteCount .. " Triangles: " .. self._triCount .. "\nPixels: " .. self._pixelCount .. " Vertices: " .. self._vertCount + if not self.ended then + local labelInfo = "Nodes: " .. self._spriteCount .. " Triangles: " .. self._triCount .. "\nPixels: " .. self._pixelCount .. " Vertices: " .. self._vertCount + self._perfLabel:setString(labelInfo) + end +end + +function SpritePolygonPerformance:onEnter() + cc.Director:getInstance():setClearColor(cc.c4f(102.0/255, 184.0/255, 204.0/255, 255.0)) +end + +function SpritePolygonPerformance:onExit() + cc.Director:getInstance():setClearColor(cc.c4f(0.0, 0.0, 0.0, 1.0)) + self:unscheduleUpdate() +end + +function SpritePolygonPerformance:init() + local ttfConfig = { fontFilePath = "fonts/arial.ttf", fontSize = 8 } + self._perfLabel = cc.Label:createWithTTF(ttfConfig, "performance test") + self:addChild(self._perfLabel) + self._perfLabel:setPosition(cc.Director:getInstance():getVisibleSize().width / 2, 80) + + self._spriteCount, self._vertCount, self._triCount, self._pixelCount, self._continuousLowDt = 0,0,0,0,0 + + local size = cc.Director:getInstance():getVisibleSize() + self._elapsedTime = 0 + self._posX,self._leftX = size.width * 0.15, size.width * 0.15 + self._rightX = size.width*0.85 + self._posY = size.height/2 + self._prevDt = 0.016 + self._goRight = true + self._ended = false + self._continuousHighDtTime = 0.0 + self._waitingTime = 0.0 + + self:scheduleUpdateWithPriorityLua(function (dt) + dt = dt * 0.3 + self._prevDt * 0.7 + self._prevDt = dt + self._elapsedTime = self._elapsedTime + dt + local loops = (0.025 - dt)*1000 + if dt < 0.025 and loops > 0 then + self._continuousHighDtTime = cc.clampf(self._continuousHighDtTime-dt*2, 0.0, 1.0) + self._waitingTime = cc.clampf(self._waitingTime-dt, 0.0, 5.0) + self._continuousLowDt = self._continuousLowDt + 1 + else + self._continuousHighDtTime = self._continuousHighDtTime + dt + self._continuousLowDt = 0 + end + + if self._continuousLowDt >= 5 and loops > 0 then + for i = 1, loops do + if self._posX >= self._rightX then + self._goRight = false + elseif self._posX <= self._leftX then + self._goRight = true + end + + + local s = self:makeSprite() + self:addChild(s) + s:setPosition(self._posX, self._posY) + if self._goRight then + self._posX = self._posX + 1 + else + self._posX = self._posX - 1 + end + self:incrementStats() + end + + self:updateLabel() + elseif self._continuousHighDtTime >= 0.5 or self._waitingTime > 3.0 then + self._ended = true + self:unscheduleUpdate() + local labelInfo = "Test ended in" .. self._elapsedTime .. " seconds\nNodes: " .. self._spriteCount .. " Triangles: " .. self._triCount .. "\nPixels: " .. self._pixelCount .. " Vertices: " .. self._vertCount + self._perfLabel:setString(labelInfo) + Helper.subtitleLabel:setString("Test ended") + else + self._waitingTime = self._waitingTime + dt + end + end, 0) +end + +function SpritePolygonPerformance:initExtend() + +end + +function SpritePolygonPerformance:makeSprite() + return cc.Node:create() +end + +function SpritePolygonPerformance:incrementStats() + self._spriteCount = self._spriteCount + 1 + self._vertCount = self._vertCount + self._incVert + self._triCount = self._triCount + self._incTri + self._pixelCount = self._pixelCount + self._incPix +end + + +---------------------------------------- +----SpritePolygonPerformanceTestDynamic +---------------------------------------- +local SpritePolygonPerformanceTestDynamic = class("SpritePolygonPerformanceTestDynamic", SpritePolygonPerformance) + +function SpritePolygonPerformanceTestDynamic:makeSprite() + local ret = cc.Sprite:create(self._info) + ret:runAction(cc.RepeatForever:create(cc.RotateBy:create(1.0,360.0))) + return ret +end + +function SpritePolygonPerformanceTestDynamic:initExtend() + self._info = cc.AutoPolygon:generatePolygon(imageFileName) + self:initIncrementStats() +end + +function SpritePolygonPerformanceTestDynamic:title() + return "Dynamic SpritePolygon Performance" +end + +function SpritePolygonPerformanceTestDynamic:subtitle() + return "Test running, please wait until it ends" +end + +function SpritePolygonPerformanceTestDynamic:initIncrementStats() + self._incVert = self._info:getVertCount() + self._incTri = self._info:getTriaglesCount() + self._incPix = self._info:getArea() +end + +---------------------------------------- +----SpritePerformanceTestDynamic +---------------------------------------- +local SpritePerformanceTestDynamic = class("SpritePerformanceTestDynamic", SpritePolygonPerformance) + +function SpritePerformanceTestDynamic:initExtend() + -- self._info = cc.AutoPolygon:generatePolygon(imageFileName) + self:initIncrementStats() +end + +function SpritePerformanceTestDynamic:title() + return "Dynamic Sprite Performance" +end + +function SpritePerformanceTestDynamic:subtitle() + return "Test running, please wait until it ends" +end + +function SpritePerformanceTestDynamic:initIncrementStats() + local t = cc.Sprite:create(imageFileName) + self._incVert = 4 + self._incTri = 2 + self._incPix = t:getContentSize().width * t:getContentSize().height +end + +function SpritePerformanceTestDynamic:makeSprite() + local ret = cc.Sprite:create(imageFileName) + ret:runAction(cc.RepeatForever:create(cc.RotateBy:create(1.0,360.0))) + return ret +end + + +---------------------------------------- +----SpritePolygonTest +---------------------------------------- function SpritePolygonTest() local scene = cc.Scene:create() @@ -398,6 +738,8 @@ function SpritePolygonTest() SpritePolygonTest2.create, SpritePolygonTest3.create, SpritePolygonTest4.create, + SpritePolygonPerformanceTestDynamic.create, + SpritePerformanceTestDynamic.create, } scene:addChild(SpritePolygonTest1.create()) diff --git a/tools/cocos2d-console b/tools/cocos2d-console index c6bc7c5583..caaaef354e 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit c6bc7c55837faa461ada8980690ac5c83a14026b +Subproject commit caaaef354e1e91f312676ee3086aff3a485b2d9d diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 91bc8f9be9..da1e96417d 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -22,12 +22,12 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/audio/include/SimpleAudioEngine.h %(cocosdir)s/cocos/2d/CCProtectedNode.h %(cocosdir)s/cocos/base/CCAsyncTaskPool.h %(cocosdir)s/cocos/2d/SpritePolygonCache.h +headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/audio/include/SimpleAudioEngine.h %(cocosdir)s/cocos/2d/CCProtectedNode.h %(cocosdir)s/cocos/base/CCAsyncTaskPool.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = New.* Sprite SpriteBatchNode SpriteFrame SpriteFrameCache Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn ReverseTime Animate AnimationFrame Animation AnimationCache Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc CallFuncN RenderTexture GridAction Grid3DAction Grid3D TiledGrid3D GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Lens3D Ripple3D PageTurn3D ShakyTiles3D ShatteredTiles3D WavesTiles3D JumpTiles3D Speed ActionManager Set SimpleAudioEngine Scheduler Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram GLProgramCache Application ClippingNode MotionStreak TextFieldTTF GLViewProtocol GLView Component ComponentContainer __NodeRGBA __LayerRGBA SAXParser Event(?!.*(Physics).*).* Device Configuration ProtectedNode GLProgramState Image .*Light$ AsyncTaskPool SpritePolygonCache Properties Material Technique RenderState Pass +classes = New.* Sprite SpriteBatchNode SpriteFrame SpriteFrameCache Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn ReverseTime Animate AnimationFrame Animation AnimationCache Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc CallFuncN RenderTexture GridAction Grid3DAction Grid3D TiledGrid3D GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Lens3D Ripple3D PageTurn3D ShakyTiles3D ShatteredTiles3D WavesTiles3D JumpTiles3D Speed ActionManager Set SimpleAudioEngine Scheduler Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram GLProgramCache Application ClippingNode MotionStreak TextFieldTTF GLViewProtocol GLView Component ComponentContainer __NodeRGBA __LayerRGBA SAXParser Event(?!.*(Physics).*).* Device Configuration ProtectedNode GLProgramState Image .*Light$ AsyncTaskPool Properties Material Technique RenderState Pass classes_need_extend = Node __NodeRGBA Layer.* Sprite SpriteBatchNode SpriteFrame Menu MenuItem.* Scene DrawNode Component .*Action.* GridBase Grid3D TiledGrid3D MotionStreak ParticleBatchNode ParticleSystem TextFieldTTF RenderTexture TileMapAtlas TMXLayer TMXTiledMap TMXMapInfo TransitionScene ProgressTimer ParallaxNode Label.* GLProgram @@ -39,7 +39,7 @@ classes_need_extend = Node __NodeRGBA Layer.* Sprite SpriteBatchNode SpriteFrame # functions from all classes. skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserData getGLServerState .*schedule setContentSize setAnchorPoint setColor pause resume setAdditionalTransform convertToWorldSpace], - Sprite::[getQuad ^setPosition$], + Sprite::[getQuad ^setPosition$ create setPolygonInfo initWithPolygon getPolygonInfo], NodeGrid::[setGrid], SpriteBatchNode::[getDescendants], MotionStreak::[draw update], @@ -103,7 +103,7 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat CardinalSpline.*::[create actionWithDuration setPoints initWithDuration], Scheduler::[pause resume ^unschedule$ unscheduleUpdate unscheduleAllForTarget schedule isTargetPaused isScheduled], TextureCache::[addPVRTCImage], - *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType onTouch.* onAcc.* onKey.* onRegisterTouchListener], + *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType onTouch.* onAcc.* onKey.* onRegisterTouchListener operator.+], FileUtils::[getFileData getDataFromFile setFilenameLookupDictionary destroyInstance getFullPathCache], Application::[^application.* ^run$ getCurrentLanguageCode setAnimationInterval], Camera::[getEyeXYZ getCenterXYZ getUpXYZ], @@ -136,7 +136,6 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat BillBoard::[*], Camera::[unproject isVisibleInFrustum], ClippingNode::[init], - SpritePolygonCache::[addSpritePolygonCache getSpritePolygonCache], RenderState::[setStateBlock] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], @@ -183,7 +182,7 @@ base_classes_to_skip = Ref Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application GLViewProtocol GLView ComponentContainer SAXParser Configuration EventListener BaseLight AsyncTaskPool SpritePolygonCache +abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application GLViewProtocol GLView ComponentContainer SAXParser Configuration EventListener BaseLight AsyncTaskPool # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. script_control_cpp = no diff --git a/tools/tojs/cocos2dx_experimental.ini b/tools/tojs/cocos2dx_experimental.ini deleted file mode 100644 index 4ae61bbee7..0000000000 --- a/tools/tojs/cocos2dx_experimental.ini +++ /dev/null @@ -1,60 +0,0 @@ -[cocos2dx_experimental] -# the prefix to be added to the generated functions. You might or might not use this in your own -# templates -prefix = cocos2dx_experimental - -# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) -# all classes will be embedded in that namespace -target_namespace = ccexp - -android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include -android_flags = -D_SIZE_T_DEFINED_ - -clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include -clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__ - -cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external - -cocos_flags = -DANDROID - -cxxgenerator_headers = - -# extra arguments for clang -extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s - -# what headers to parse -headers = %(cocosdir)s/cocos/2d/SpritePolygon.h - -# what classes to produce code for. You can use regular expressions here. When testing the regular -# expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = SpritePolygon - -# what should we skip? in the format ClassName::[function function] -# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also -# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just -# add a single "*" as functions. See bellow for several examples. A special class name is "*", which -# will apply to all class names. This is a convenience wildcard to be able to skip similar named -# functions from all classes. - -skip = SpritePolygon::[create initWithVerts initWithRect initWithPoly2tri initWithCache] - -rename_functions = - -rename_classes = - -# for all class names, should we remove something when registering in the target VM? -remove_prefix = - -# classes for which there will be no "parent" lookup -classes_have_no_parents = - -# base classes which will be skipped when their sub-classes found them. -base_classes_to_skip = - -# classes that create no constructor -# Set is special and we will use a hand-written constructor -abstract_classes = - -# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. -script_control_cpp = no - diff --git a/tools/tojs/genbindings.py b/tools/tojs/genbindings.py index b4db91e40f..a5c03f314d 100755 --- a/tools/tojs/genbindings.py +++ b/tools/tojs/genbindings.py @@ -144,7 +144,6 @@ def main(): 'cocos2dx_3d_ext.ini' : ('cocos2dx_3d_extension', 'jsb_cocos2dx_3d_extension_auto'), \ 'cocos2dx_experimental_webView.ini' : ('cocos2dx_experimental_webView', 'jsb_cocos2dx_experimental_webView_auto'), \ 'cocos2dx_experimental_video.ini' : ('cocos2dx_experimental_video', 'jsb_cocos2dx_experimental_video_auto'), \ - 'cocos2dx_experimental.ini' : ('cocos2dx_experimental', 'jsb_cocos2dx_experimental'), \ 'cocos2dx_physics3d.ini' : ('cocos2dx_physics3d', 'jsb_cocos2dx_physics3d_auto') } target = 'spidermonkey' diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 105dde77e9..11c87fe934 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -22,11 +22,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h %(cocosdir)s/cocos/base/CCAsyncTaskPool.h %(cocosdir)s/cocos/2d/SpritePolygonCache.h +headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h %(cocosdir)s/cocos/base/CCAsyncTaskPool.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device ClippingRectangleNode .*Light$ AsyncTaskPool SpritePolygonCache RenderState Material Properties Technique Pass +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device ClippingRectangleNode .*Light$ AsyncTaskPool RenderState Material Properties Technique Pass PolygonInfo AutoPolygon # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -36,7 +36,7 @@ classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* M # functions from all classes. skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition$ setContentSize setAnchorPoint enumerateChildren getonEnterTransitionDidFinishCallback getOnEnterCallback getOnExitCallback getonExitTransitionDidStartCallback setAdditionalTransform setRotationQuat getRotationQuat .*(Physics).*], - Sprite::[getQuad ^setPosition$], + Sprite::[getQuad ^setPosition$ create setPolygonInfo initWithPolygon getPolygonInfo], SpriteBatchNode::[getDescendants], MotionStreak::[draw update], ParticleSystem::[updateQuadWithParticle initParticle], @@ -137,12 +137,13 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS Device::[getTextureDataForText], BillBoard::[*], Camera::[unproject], - SpritePolygonCache::[addSpritePolygonCache getSpritePolygonCache], EventListenerCustom::[init], EventListener::[init], RotateTo::[calculateAngles], RenderState::[finalize setStateBlock], - Properties::[createNonRefCounted] + Properties::[createNonRefCounted], + AutoPolygon::[trace reduce expand triangulate calculateUV generateTriangles generatePolygon], + PolygonInfo::[operator=] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], ProgressTimer::[setReverseProgress=setReverseDirection], diff --git a/tools/tolua/cocos2dx_experimental.ini b/tools/tolua/cocos2dx_experimental.ini index 4c3946a5b4..93e54f9a45 100644 --- a/tools/tolua/cocos2dx_experimental.ini +++ b/tools/tolua/cocos2dx_experimental.ini @@ -23,11 +23,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/2d/CCFastTMXLayer.h %(cocosdir)s/cocos/2d/CCFastTMXTiledMap.h %(cocosdir)s/cocos/2d/SpritePolygon.h +headers = %(cocosdir)s/cocos/2d/CCFastTMXLayer.h %(cocosdir)s/cocos/2d/CCFastTMXTiledMap.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = TMXLayer TMXTiledMap SpritePolygon +classes = TMXLayer TMXTiledMap # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -36,8 +36,7 @@ classes = TMXLayer TMXTiledMap SpritePolygon # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = TMXLayer::[(g|s)etTiles getTileGIDAt], - SpritePolygon::[create initWithVerts initWithRect initWithPoly2tri initWithMarching] +skip = TMXLayer::[(g|s)etTiles getTileGIDAt] rename_functions = diff --git a/web b/web index 726f11e7f6..71c5db165e 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 726f11e7f646ff32e4999056d3c26366703930aa +Subproject commit 71c5db165e2fb84ac0203889b23286904296ef09