mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' into renderFix
Conflicts: tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.h
This commit is contained in:
commit
1c10ae43bc
10
AUTHORS
10
AUTHORS
|
@ -815,6 +815,7 @@ Developers:
|
|||
Precompiled headers improvements
|
||||
Added Application::openUrl for all supported platforms ecept WP8 and WinRT
|
||||
Scale9Sprite capInsets set fix
|
||||
Clang static analyzer crash fix
|
||||
|
||||
youknowone
|
||||
Adds iOS-like elastic bounceback support for cocos2d::extension::ScrollView
|
||||
|
@ -1061,7 +1062,16 @@ Developers:
|
|||
shrimpz
|
||||
Fix two typos in luaval_to_quaternion
|
||||
Fix label crashed on android
|
||||
|
||||
ton1517
|
||||
Fix the issue that JumpTo can not be applied more than once
|
||||
|
||||
takaokato
|
||||
Fix wrong result in Node:getParenttoNodeTransform() if node is transformed
|
||||
|
||||
AknEp
|
||||
Fix FileUtils::fullPathForFilename return empty string if file not found
|
||||
|
||||
Retired Core Developers:
|
||||
WenSheng Yang
|
||||
Author of windows port, CCTextField,
|
||||
|
|
18
CHANGELOG
18
CHANGELOG
|
@ -1,12 +1,26 @@
|
|||
cocos2d-x-3.4 Jan.15 2015
|
||||
[NEW] VertexBuffer&IndexBuffer: allow setting usage(GL_STATIC_DRAW or GL_DYNAMIC_DRAW) in create method
|
||||
|
||||
[FIX] GLProgramState: may cause GL_INVALID_VALUE error at start up on Android
|
||||
|
||||
cocos2d-x-3.4rc0 Jan.9 2015
|
||||
[NEW] 3rd: update libcurl to v7.39
|
||||
|
||||
[NEW] 3rd: update luajit to v2.0.3
|
||||
|
||||
[FIX] C++: crash when run clang static analyzer in Xcode
|
||||
[FIX] DrawNode: can not set color when DrawPoints, wrong behavior of drawRect
|
||||
[FIX] FileUtils: getData() can't get data from file when file was using by other application on windows
|
||||
[FIX] FileUtils: getData() will cause memory leak if file size is 0 on windows
|
||||
[FIX] GLProgram: when there is a shader compile error in shader, it will crash on windows
|
||||
[FIX] GLProgramState: Assert error because uniforms and attribute is not refreshed when come to foreground on android
|
||||
[FIX] HttpClient: http requests will be lost in immediately mode on iOS
|
||||
[FIX] JumpTo: can not be applied more than once
|
||||
[FIX] Label: may cause infinite loop if using system font on Android
|
||||
[FIX] Particle: GL_INVALID_OPERATION error because VAO and VBOs is not reset when come to foreground on android
|
||||
[FIX] Physics integration: physics body is not still after disabling gravitational force by PhysicsBody::setGravityEnable()
|
||||
[FIX] Sprite3DTest: Sprite3DUVAnimationTest, Sprite3DFakeShadowTest, Sprite3DLightMapTest, Sprite3DBasicToonShaderTest will crash on android when switch to foreground from background
|
||||
[FIX] HttpClient: http requests will be lost in immediately mode on iOS
|
||||
[FIX] Template: multiple dex files define error on Android if using Eclipse to build new generated application
|
||||
[FIX] VideoPlayer: can not play video if passing path returned from FileUtils::fullPathForFilename() on Android
|
||||
[FIX] WP8: compiling error on ARM architecture
|
||||
|
||||
cocos2d-x-3.4beta0 Dec.31 2014
|
||||
|
|
|
@ -1928,28 +1928,6 @@
|
|||
B29A7E3F19EE1B7700872B35 /* AnimationState.h in Headers */ = {isa = PBXBuildFile; fileRef = B29A7DC619EE1B7700872B35 /* AnimationState.h */; };
|
||||
B29A7E4019EE1B7700872B35 /* AnimationState.h in Headers */ = {isa = PBXBuildFile; fileRef = B29A7DC619EE1B7700872B35 /* AnimationState.h */; };
|
||||
B2CC507C19776DD10041958E /* CCPhysicsJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A170721807CE7A005B8026 /* CCPhysicsJoint.cpp */; };
|
||||
B37510711823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */; };
|
||||
B37510721823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */; };
|
||||
B37510731823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */; };
|
||||
B37510741823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */; };
|
||||
B37510751823AC9F00B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */; };
|
||||
B37510761823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */; };
|
||||
B37510771823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */; };
|
||||
B37510781823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */; };
|
||||
B37510791823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */; };
|
||||
B375107A1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */; };
|
||||
B375107B1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */; };
|
||||
B375107C1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */; };
|
||||
B375107D1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */; };
|
||||
B375107E1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */; };
|
||||
B375107F1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */; };
|
||||
B37510801823ACA100B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */; };
|
||||
B37510811823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */; };
|
||||
B37510821823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */; };
|
||||
B37510831823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */; };
|
||||
B37510841823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */; };
|
||||
B37510851823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */; };
|
||||
B37510861823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */ = {isa = PBXBuildFile; fileRef = B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */; };
|
||||
B60C5BD419AC68B10056FBDE /* CCBillBoard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */; };
|
||||
B60C5BD519AC68B10056FBDE /* CCBillBoard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */; };
|
||||
B60C5BD619AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; };
|
||||
|
@ -1990,6 +1968,8 @@
|
|||
DABC9FAA19E7DFA900FA252C /* CCClippingRectangleNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DABC9FA719E7DFA900FA252C /* CCClippingRectangleNode.cpp */; };
|
||||
DABC9FAB19E7DFA900FA252C /* CCClippingRectangleNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DABC9FA819E7DFA900FA252C /* CCClippingRectangleNode.h */; };
|
||||
DABC9FAC19E7DFA900FA252C /* CCClippingRectangleNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DABC9FA819E7DFA900FA252C /* CCClippingRectangleNode.h */; };
|
||||
ED74D7691A5B8A2600157FD4 /* CCPhysicsHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = ED74D7681A5B8A2600157FD4 /* CCPhysicsHelper.h */; };
|
||||
ED74D76A1A5B8A2600157FD4 /* CCPhysicsHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = ED74D7681A5B8A2600157FD4 /* CCPhysicsHelper.h */; };
|
||||
ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; };
|
||||
ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; };
|
||||
ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */; };
|
||||
|
@ -3043,17 +3023,6 @@
|
|||
B29A7DC419EE1B7700872B35 /* Animation.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Animation.c; sourceTree = "<group>"; };
|
||||
B29A7DC519EE1B7700872B35 /* AnimationState.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = AnimationState.c; sourceTree = "<group>"; };
|
||||
B29A7DC619EE1B7700872B35 /* AnimationState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationState.h; sourceTree = "<group>"; };
|
||||
B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsBodyInfo_chipmunk.cpp; sourceTree = "<group>"; };
|
||||
B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsBodyInfo_chipmunk.h; sourceTree = "<group>"; };
|
||||
B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsContactInfo_chipmunk.cpp; sourceTree = "<group>"; };
|
||||
B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsContactInfo_chipmunk.h; sourceTree = "<group>"; };
|
||||
B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsHelper_chipmunk.h; sourceTree = "<group>"; };
|
||||
B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsJointInfo_chipmunk.cpp; sourceTree = "<group>"; };
|
||||
B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsJointInfo_chipmunk.h; sourceTree = "<group>"; };
|
||||
B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsShapeInfo_chipmunk.cpp; sourceTree = "<group>"; };
|
||||
B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsShapeInfo_chipmunk.h; sourceTree = "<group>"; };
|
||||
B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsWorldInfo_chipmunk.cpp; sourceTree = "<group>"; };
|
||||
B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsWorldInfo_chipmunk.h; sourceTree = "<group>"; };
|
||||
B3AF019E1842FBA400A98B85 /* b2MotorJoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = b2MotorJoint.cpp; sourceTree = "<group>"; };
|
||||
B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2MotorJoint.h; sourceTree = "<group>"; };
|
||||
B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBillBoard.cpp; sourceTree = "<group>"; };
|
||||
|
@ -3079,6 +3048,7 @@
|
|||
DA8C62A119E52C6400000516 /* ioapi_mem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ioapi_mem.h; sourceTree = "<group>"; };
|
||||
DABC9FA719E7DFA900FA252C /* CCClippingRectangleNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCClippingRectangleNode.cpp; sourceTree = "<group>"; };
|
||||
DABC9FA819E7DFA900FA252C /* CCClippingRectangleNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCClippingRectangleNode.h; sourceTree = "<group>"; };
|
||||
ED74D7681A5B8A2600157FD4 /* CCPhysicsHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsHelper.h; sourceTree = "<group>"; };
|
||||
ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCNodeGrid.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeGrid.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
@ -4787,7 +4757,7 @@
|
|||
46A170611807CE7A005B8026 /* physics */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
46A170791807CE7A005B8026 /* chipmunk */,
|
||||
ED74D7681A5B8A2600157FD4 /* CCPhysicsHelper.h */,
|
||||
46A1706E1807CE7A005B8026 /* CCPhysicsBody.cpp */,
|
||||
46A1706F1807CE7A005B8026 /* CCPhysicsBody.h */,
|
||||
46A170701807CE7A005B8026 /* CCPhysicsContact.cpp */,
|
||||
|
@ -4803,24 +4773,6 @@
|
|||
path = ../cocos/physics;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
46A170791807CE7A005B8026 /* chipmunk */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B37510451823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp */,
|
||||
B37510461823AC7B00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h */,
|
||||
B37510471823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp */,
|
||||
B37510481823AC7B00B3BA6A /* CCPhysicsContactInfo_chipmunk.h */,
|
||||
B37510491823AC7B00B3BA6A /* CCPhysicsHelper_chipmunk.h */,
|
||||
B375104A1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp */,
|
||||
B375104B1823AC7B00B3BA6A /* CCPhysicsJointInfo_chipmunk.h */,
|
||||
B375104C1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp */,
|
||||
B375104D1823AC7B00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h */,
|
||||
B375104E1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp */,
|
||||
B375104F1823AC7B00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h */,
|
||||
);
|
||||
path = chipmunk;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
46A170851807CE87005B8026 /* math */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -5329,7 +5281,6 @@
|
|||
15AE18F719AAD35000C27E9E /* CCBatchNode.h in Headers */,
|
||||
15AE181419AAD2F700C27E9E /* CCAnimationCurve.h in Headers */,
|
||||
50ABBE631925AB6F00A911A9 /* CCEventListenerAcceleration.h in Headers */,
|
||||
B37510771823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */,
|
||||
15AE1C1419AAE2C600C27E9E /* CCPhysicsSprite.h in Headers */,
|
||||
46A170EE1807CECA005B8026 /* CCPhysicsShape.h in Headers */,
|
||||
15AE1A5C19AAD40300C27E9E /* b2Timer.h in Headers */,
|
||||
|
@ -5342,7 +5293,6 @@
|
|||
15AE1A6D19AAD40300C27E9E /* b2ChainAndPolygonContact.h in Headers */,
|
||||
3E2F27A719CFBFE400E7C490 /* AudioEngine.h in Headers */,
|
||||
15AE183A19AAD2F700C27E9E /* CCRay.h in Headers */,
|
||||
B375107B1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */,
|
||||
15AE18A319AAD33D00C27E9E /* CCParticleSystemQuadLoader.h in Headers */,
|
||||
46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */,
|
||||
15AE199D19AAD39600C27E9E /* ScrollViewReader.h in Headers */,
|
||||
|
@ -5416,7 +5366,6 @@
|
|||
15AE1A6B19AAD40300C27E9E /* b2ChainAndCircleContact.h in Headers */,
|
||||
1A570110180BC8EE0088DEC7 /* CCDrawingPrimitives.h in Headers */,
|
||||
50CB247D19D9C5A100687767 /* AudioPlayer.h in Headers */,
|
||||
B37510791823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */,
|
||||
1A570114180BC8EE0088DEC7 /* CCDrawNode.h in Headers */,
|
||||
15AE1A6019AAD40300C27E9E /* b2ContactManager.h in Headers */,
|
||||
15B3707A19EE414C00ABE682 /* AssetsManagerEx.h in Headers */,
|
||||
|
@ -5501,6 +5450,7 @@
|
|||
50ABBD401925AB0000A911A9 /* CCMath.h in Headers */,
|
||||
B29A7E1F19EE1B7700872B35 /* BoneData.h in Headers */,
|
||||
15AE1A9319AAD40300C27E9E /* b2WheelJoint.h in Headers */,
|
||||
ED74D7691A5B8A2600157FD4 /* CCPhysicsHelper.h in Headers */,
|
||||
15AE1A3119AAD3D500C27E9E /* b2ChainShape.h in Headers */,
|
||||
1A5701FD180BCBAD0088DEC7 /* CCMenuItem.h in Headers */,
|
||||
1A570204180BCBD40088DEC7 /* CCClippingNode.h in Headers */,
|
||||
|
@ -5641,7 +5591,6 @@
|
|||
50ABC0651926664800A911A9 /* CCGL-mac.h in Headers */,
|
||||
50643BD419BFAECF00EF68ED /* CCGL.h in Headers */,
|
||||
15AE190C19AAD35000C27E9E /* CCDisplayFactory.h in Headers */,
|
||||
B37510751823AC9F00B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */,
|
||||
15AE1A8B19AAD40300C27E9E /* b2PulleyJoint.h in Headers */,
|
||||
15AE1A5119AAD40300C27E9E /* b2BlockAllocator.h in Headers */,
|
||||
15AE199119AAD37200C27E9E /* ImageViewReader.h in Headers */,
|
||||
|
@ -5672,7 +5621,6 @@
|
|||
15AE186719AAD31D00C27E9E /* CDXMacOSXSupport.h in Headers */,
|
||||
B29A7DCD19EE1B7700872B35 /* Slot.h in Headers */,
|
||||
382384311A259112002C4610 /* ParticleReader.h in Headers */,
|
||||
B37510741823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */,
|
||||
5034CA35191D591100CE6051 /* ccShader_PositionTexture.frag in Headers */,
|
||||
15AE1BB219AADFEF00C27E9E /* HttpClient.h in Headers */,
|
||||
15AE197619AAD35700C27E9E /* CCTimelineMacro.h in Headers */,
|
||||
|
@ -5761,7 +5709,6 @@
|
|||
1A01C69018F57BE800EFE3A6 /* CCDictionary.h in Headers */,
|
||||
1A9DCA29180E6955007A3AD4 /* CCGLBufferedNode.h in Headers */,
|
||||
50ABC0031926664800A911A9 /* CCLock-apple.h in Headers */,
|
||||
B37510721823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */,
|
||||
50ABBE2D1925AB6F00A911A9 /* ccCArray.h in Headers */,
|
||||
50ABBD5E1925AB0000A911A9 /* Vec3.h in Headers */,
|
||||
15AE188919AAD33D00C27E9E /* CCControlButtonLoader.h in Headers */,
|
||||
|
@ -5860,6 +5807,7 @@
|
|||
B29A7DFE19EE1B7700872B35 /* IkConstraintData.h in Headers */,
|
||||
382384401A259140002C4610 /* SingleNodeReader.h in Headers */,
|
||||
15AE1A4019AAD3D500C27E9E /* b2Collision.h in Headers */,
|
||||
ED74D76A1A5B8A2600157FD4 /* CCPhysicsHelper.h in Headers */,
|
||||
5034CA40191D591100CE6051 /* ccShader_Position_uColor.vert in Headers */,
|
||||
15AE184719AAD2F700C27E9E /* CCSprite3DMaterial.h in Headers */,
|
||||
15AE1BFC19AAE01E00C27E9E /* CCControlUtils.h in Headers */,
|
||||
|
@ -5901,7 +5849,6 @@
|
|||
1A570074180BC5A10088DEC7 /* CCActionGrid.h in Headers */,
|
||||
15AE194A19AAD35100C27E9E /* CCComController.h in Headers */,
|
||||
382384161A259092002C4610 /* NodeReaderProtocol.h in Headers */,
|
||||
B37510841823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.h in Headers */,
|
||||
5034CA46191D591100CE6051 /* ccShader_Label_outline.frag in Headers */,
|
||||
1A570078180BC5A10088DEC7 /* CCActionGrid3D.h in Headers */,
|
||||
50ABBD631925AB0000A911A9 /* Vec4.h in Headers */,
|
||||
|
@ -5916,7 +5863,6 @@
|
|||
15AE18CD19AAD33D00C27E9E /* CCNode+CCBRelativePositioning.h in Headers */,
|
||||
382384121A259092002C4610 /* NodeReaderDefine.h in Headers */,
|
||||
50ABBE781925AB6F00A911A9 /* CCEventListenerTouch.h in Headers */,
|
||||
B37510861823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.h in Headers */,
|
||||
15AE1BC019AADFF000C27E9E /* WebSocket.h in Headers */,
|
||||
3823840A1A25900F002C4610 /* FlatBuffersSerialize.h in Headers */,
|
||||
1A570080180BC5A10088DEC7 /* CCActionInterval.h in Headers */,
|
||||
|
@ -6077,7 +6023,6 @@
|
|||
15B3708B19EE414C00ABE682 /* Manifest.h in Headers */,
|
||||
1A570213180BCBF40088DEC7 /* CCProgressTimer.h in Headers */,
|
||||
38F526431A48363B000DB7F7 /* CSArmatureNode_generated.h in Headers */,
|
||||
B37510821823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.h in Headers */,
|
||||
1A570217180BCBF40088DEC7 /* CCRenderTexture.h in Headers */,
|
||||
15AE1ABB19AAD40300C27E9E /* b2EdgeAndPolygonContact.h in Headers */,
|
||||
15AE198719AAD36400C27E9E /* WidgetReaderProtocol.h in Headers */,
|
||||
|
@ -6166,7 +6111,6 @@
|
|||
15AE18C419AAD33D00C27E9E /* CCLayerGradientLoader.h in Headers */,
|
||||
1A570313180BCF190088DEC7 /* CCComponentContainer.h in Headers */,
|
||||
1A087AEB1860400400196EF5 /* edtaa3func.h in Headers */,
|
||||
B375107F1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.h in Headers */,
|
||||
15AE185D19AAD31200C27E9E /* CocosDenshion.h in Headers */,
|
||||
15AE194319AAD35100C27E9E /* CCColliderDetector.h in Headers */,
|
||||
D0FD035C1A3B51AA00825BB5 /* CCAllocatorStrategyFixedBlock.h in Headers */,
|
||||
|
@ -6322,12 +6266,10 @@
|
|||
50ABC00A1926664800A911A9 /* CCCommon.h in Headers */,
|
||||
15AE19AD19AAD39700C27E9E /* LoadingBarReader.h in Headers */,
|
||||
50ABBE5C1925AB6F00A911A9 /* CCEventKeyboard.h in Headers */,
|
||||
B375107D1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.h in Headers */,
|
||||
5E9F612D1A3FFE3D0038DE01 /* CCPlane.h in Headers */,
|
||||
50ABC01C1926664800A911A9 /* CCSAXParser.h in Headers */,
|
||||
503DD8F11926736A00CD74DD /* OpenGL_Internal-ios.h in Headers */,
|
||||
38ACD1FF1A27111900C3093D /* WidgetCallBackHandlerProtocol.h in Headers */,
|
||||
B37510801823ACA100B3BA6A /* CCPhysicsHelper_chipmunk.h in Headers */,
|
||||
B29A7DF619EE1B7700872B35 /* Skeleton.h in Headers */,
|
||||
50ABBDAA1925AB4100A911A9 /* CCRenderCommand.h in Headers */,
|
||||
B29A7DF019EE1B7700872B35 /* SkeletonBounds.h in Headers */,
|
||||
|
@ -6492,12 +6434,10 @@
|
|||
15AE1A8219AAD40300C27E9E /* b2GearJoint.cpp in Sources */,
|
||||
1A570071180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */,
|
||||
50CB247F19D9C5A100687767 /* AudioPlayer.mm in Sources */,
|
||||
B37510761823AC9F00B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */,
|
||||
50ABBFFF1926664800A911A9 /* CCFileUtils-apple.mm in Sources */,
|
||||
1A570075180BC5A10088DEC7 /* CCActionGrid3D.cpp in Sources */,
|
||||
382383F81A258FA7002C4610 /* idl_gen_general.cpp in Sources */,
|
||||
15AE1C1319AAE2C600C27E9E /* CCPhysicsSprite.cpp in Sources */,
|
||||
B375107A1823AC9F00B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */,
|
||||
382384131A259092002C4610 /* NodeReaderProtocol.cpp in Sources */,
|
||||
15AE1A5F19AAD40300C27E9E /* b2ContactManager.cpp in Sources */,
|
||||
15AE1B9D19AADFDF00C27E9E /* UIVBox.cpp in Sources */,
|
||||
|
@ -6531,7 +6471,6 @@
|
|||
D0FD034B1A3B51AA00825BB5 /* CCAllocatorDiagnostics.cpp in Sources */,
|
||||
15AE189B19AAD33D00C27E9E /* CCNode+CCBRelativePositioning.cpp in Sources */,
|
||||
15AE183819AAD2F700C27E9E /* CCRay.cpp in Sources */,
|
||||
B37510781823AC9F00B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */,
|
||||
50ABBE391925AB6F00A911A9 /* CCData.cpp in Sources */,
|
||||
1A57010E180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */,
|
||||
50ABBED71925AB6F00A911A9 /* ZipUtils.cpp in Sources */,
|
||||
|
@ -6583,7 +6522,6 @@
|
|||
50ABBD4C1925AB0000A911A9 /* MathUtil.cpp in Sources */,
|
||||
15AE191719AAD35000C27E9E /* CCSpriteFrameCacheHelper.cpp in Sources */,
|
||||
1A087AE81860400400196EF5 /* edtaa3func.cpp in Sources */,
|
||||
B37510731823AC9F00B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */,
|
||||
50ABBD831925AB4100A911A9 /* CCBatchCommand.cpp in Sources */,
|
||||
15AE18FF19AAD35000C27E9E /* CCComAudio.cpp in Sources */,
|
||||
1A5701C7180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */,
|
||||
|
@ -6716,7 +6654,6 @@
|
|||
B29A7E0719EE1B7700872B35 /* SkinnedMeshAttachment.c in Sources */,
|
||||
1A570310180BCF190088DEC7 /* CCComponentContainer.cpp in Sources */,
|
||||
15AE190719AAD35000C27E9E /* CCDatas.cpp in Sources */,
|
||||
B37510711823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */,
|
||||
1A01C69C18F57BE800EFE3A6 /* CCString.cpp in Sources */,
|
||||
50ABBD3C1925AB0000A911A9 /* CCGeometry.cpp in Sources */,
|
||||
B29A7DDD19EE1B7700872B35 /* BoneData.c in Sources */,
|
||||
|
@ -6909,7 +6846,6 @@
|
|||
15AE186119AAD31200C27E9E /* SimpleAudioEngine_objc.m in Sources */,
|
||||
15AE182519AAD2F700C27E9E /* CCMesh.cpp in Sources */,
|
||||
503DD8EE1926736A00CD74DD /* CCImage-ios.mm in Sources */,
|
||||
B37510811823ACA100B3BA6A /* CCPhysicsJointInfo_chipmunk.cpp in Sources */,
|
||||
46A170FC1807CECB005B8026 /* CCPhysicsBody.cpp in Sources */,
|
||||
15AE1BEA19AAE01E00C27E9E /* CCControlButton.cpp in Sources */,
|
||||
50ABBD941925AB4100A911A9 /* CCGLProgramState.cpp in Sources */,
|
||||
|
@ -6993,7 +6929,6 @@
|
|||
15AE1AB219AAD40300C27E9E /* b2CircleContact.cpp in Sources */,
|
||||
B29A7E2619EE1B7700872B35 /* Attachment.c in Sources */,
|
||||
15AE18C119AAD33D00C27E9E /* CCLayerColorLoader.cpp in Sources */,
|
||||
B37510851823ACA100B3BA6A /* CCPhysicsWorldInfo_chipmunk.cpp in Sources */,
|
||||
50ABBD551925AB0000A911A9 /* TransformUtils.cpp in Sources */,
|
||||
292DB14419B4574100A80320 /* UIEditBoxImpl-android.cpp in Sources */,
|
||||
15AE193619AAD35100C27E9E /* CCArmature.cpp in Sources */,
|
||||
|
@ -7028,7 +6963,6 @@
|
|||
50ABBD4D1925AB0000A911A9 /* MathUtil.cpp in Sources */,
|
||||
50ABBE3E1925AB6F00A911A9 /* CCDataVisitor.cpp in Sources */,
|
||||
1A57009F180BC5D20088DEC7 /* CCNode.cpp in Sources */,
|
||||
B37510831823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */,
|
||||
1A57010F180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */,
|
||||
1A570113180BC8EE0088DEC7 /* CCDrawNode.cpp in Sources */,
|
||||
1A57011C180BC90D0088DEC7 /* CCGrabber.cpp in Sources */,
|
||||
|
@ -7084,7 +7018,6 @@
|
|||
15AE1BAD19AADFDF00C27E9E /* UILayoutParameter.cpp in Sources */,
|
||||
3823843E1A259140002C4610 /* SingleNodeReader.cpp in Sources */,
|
||||
B29A7DDE19EE1B7700872B35 /* BoneData.c in Sources */,
|
||||
B375107E1823ACA100B3BA6A /* CCPhysicsContactInfo_chipmunk.cpp in Sources */,
|
||||
15AE19AA19AAD39700C27E9E /* ListViewReader.cpp in Sources */,
|
||||
1A5701C8180BCB5A0088DEC7 /* CCLabelTextFormatter.cpp in Sources */,
|
||||
1A5701CC180BCB5A0088DEC7 /* CCLabelTTF.cpp in Sources */,
|
||||
|
@ -7214,7 +7147,6 @@
|
|||
15AE193219AAD35100C27E9E /* CCActionNode.cpp in Sources */,
|
||||
15AE195319AAD35100C27E9E /* CCDisplayFactory.cpp in Sources */,
|
||||
50ABC0061926664800A911A9 /* CCThread-apple.mm in Sources */,
|
||||
B375107C1823ACA100B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */,
|
||||
50ABBEB61925AB6F00A911A9 /* CCUserDefault-android.cpp in Sources */,
|
||||
296BF6191A4405CB0038EC44 /* UIShaders.cpp in Sources */,
|
||||
1A57034C180BD09B0088DEC7 /* tinyxml2.cpp in Sources */,
|
||||
|
|
|
@ -117,11 +117,11 @@ bool Speed::initWithAction(ActionInterval *action, float speed)
|
|||
|
||||
Speed *Speed::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Speed();
|
||||
a->initWithAction(_innerAction->clone(), _speed);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Speed();
|
||||
a->initWithAction(_innerAction->clone(), _speed);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void Speed::startWithTarget(Node* target)
|
||||
|
@ -148,8 +148,7 @@ bool Speed::isDone() const
|
|||
|
||||
Speed *Speed::reverse() const
|
||||
{
|
||||
|
||||
return Speed::create(_innerAction->reverse(), _speed);
|
||||
return Speed::create(_innerAction->reverse(), _speed);
|
||||
}
|
||||
|
||||
void Speed::setInnerAction(ActionInterval *action)
|
||||
|
@ -184,11 +183,11 @@ Follow* Follow::create(Node *followedNode, const Rect& rect/* = Rect::ZERO*/)
|
|||
|
||||
Follow* Follow::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Follow();
|
||||
a->initWithTarget(_followedNode, _worldRect);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Follow();
|
||||
a->initWithTarget(_followedNode, _worldRect);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
Follow* Follow::reverse() const
|
||||
|
|
|
@ -159,11 +159,11 @@ OrbitCamera * OrbitCamera::create(float t, float radius, float deltaRadius, floa
|
|||
|
||||
OrbitCamera* OrbitCamera::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) OrbitCamera();
|
||||
a->initWithDuration(_duration, _radius, _deltaRadius, _angleZ, _deltaAngleZ, _angleX, _deltaAngleX);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) OrbitCamera();
|
||||
a->initWithDuration(_duration, _radius, _deltaRadius, _angleZ, _deltaAngleZ, _angleX, _deltaAngleX);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
bool OrbitCamera::initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX)
|
||||
|
|
|
@ -138,7 +138,6 @@ Vec2 PointArray::getControlPointAtIndex(ssize_t index)
|
|||
|
||||
void PointArray::replaceControlPoint(cocos2d::Vec2 &controlPoint, ssize_t index)
|
||||
{
|
||||
|
||||
Vec2 *temp = _controlPoints->at(index);
|
||||
temp->x = controlPoint.x;
|
||||
temp->y = controlPoint.y;
|
||||
|
@ -201,9 +200,9 @@ Vec2 ccCardinalSplineAt(Vec2 &p0, Vec2 &p1, Vec2 &p2, Vec2 &p3, float tension, f
|
|||
float t2 = t * t;
|
||||
float t3 = t2 * t;
|
||||
|
||||
/*
|
||||
* Formula: s(-ttt + 2tt - t)P1 + s(-ttt + tt)P2 + (2ttt - 3tt + 1)P2 + s(ttt - 2tt + t)P3 + (-2ttt + 3tt)P3 + s(ttt - tt)P4
|
||||
*/
|
||||
/*
|
||||
* Formula: s(-ttt + 2tt - t)P1 + s(-ttt + tt)P2 + (2ttt - 3tt + 1)P2 + s(ttt - 2tt + t)P3 + (-2ttt + 3tt)P3 + s(ttt - tt)P4
|
||||
*/
|
||||
float s = (1 - tension) / 2;
|
||||
|
||||
float b1 = s * ((-t3 + (2 * t2)) - t); // s(-t3 + 2 t2 - t)P1
|
||||
|
@ -280,11 +279,11 @@ void CardinalSplineTo::startWithTarget(cocos2d::Node *target)
|
|||
|
||||
CardinalSplineTo* CardinalSplineTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) CardinalSplineTo();
|
||||
a->initWithDuration(this->_duration, this->_points->clone(), this->_tension);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) CardinalSplineTo();
|
||||
a->initWithDuration(this->_duration, this->_points->clone(), this->_tension);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void CardinalSplineTo::update(float time)
|
||||
|
@ -292,10 +291,10 @@ void CardinalSplineTo::update(float time)
|
|||
ssize_t p;
|
||||
float lt;
|
||||
|
||||
// eg.
|
||||
// p..p..p..p..p..p..p
|
||||
// 1..2..3..4..5..6..7
|
||||
// want p to be 1, 2, 3, 4, 5, 6
|
||||
// eg.
|
||||
// p..p..p..p..p..p..p
|
||||
// 1..2..3..4..5..6..7
|
||||
// want p to be 1, 2, 3, 4, 5, 6
|
||||
if (time == 1)
|
||||
{
|
||||
p = _points->count() - 1;
|
||||
|
@ -307,7 +306,7 @@ void CardinalSplineTo::update(float time)
|
|||
lt = (time - _deltaT * (float)p) / _deltaT;
|
||||
}
|
||||
|
||||
// Interpolate
|
||||
// Interpolate
|
||||
Vec2 pp0 = _points->getControlPointAtIndex(p-1);
|
||||
Vec2 pp1 = _points->getControlPointAtIndex(p+0);
|
||||
Vec2 pp2 = _points->getControlPointAtIndex(p+1);
|
||||
|
@ -377,9 +376,9 @@ CardinalSplineBy* CardinalSplineBy::reverse() const
|
|||
{
|
||||
PointArray *copyConfig = _points->clone();
|
||||
|
||||
//
|
||||
// convert "absolutes" to "diffs"
|
||||
//
|
||||
//
|
||||
// convert "absolutes" to "diffs"
|
||||
//
|
||||
Vec2 p = copyConfig->getControlPointAtIndex(0);
|
||||
for (ssize_t i = 1; i < copyConfig->count(); ++i)
|
||||
{
|
||||
|
@ -390,12 +389,11 @@ CardinalSplineBy* CardinalSplineBy::reverse() const
|
|||
p = current;
|
||||
}
|
||||
|
||||
|
||||
// convert to "diffs" to "reverse absolute"
|
||||
// convert to "diffs" to "reverse absolute"
|
||||
|
||||
PointArray *pReverse = copyConfig->reverse();
|
||||
|
||||
// 1st element (which should be 0,0) should be here too
|
||||
// 1st element (which should be 0,0) should be here too
|
||||
|
||||
p = pReverse->getControlPointAtIndex(pReverse->count()-1);
|
||||
pReverse->removeControlPointAtIndex(pReverse->count()-1);
|
||||
|
@ -424,11 +422,11 @@ void CardinalSplineBy::startWithTarget(cocos2d::Node *target)
|
|||
|
||||
CardinalSplineBy* CardinalSplineBy::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) CardinalSplineBy();
|
||||
a->initWithDuration(this->_duration, this->_points->clone(), this->_tension);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) CardinalSplineBy();
|
||||
a->initWithDuration(this->_duration, this->_points->clone(), this->_tension);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
/* CatmullRomTo
|
||||
|
@ -464,11 +462,11 @@ bool CatmullRomTo::initWithDuration(float dt, cocos2d::PointArray *points)
|
|||
|
||||
CatmullRomTo* CatmullRomTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) CatmullRomTo();
|
||||
a->initWithDuration(this->_duration, this->_points->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) CatmullRomTo();
|
||||
a->initWithDuration(this->_duration, this->_points->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
CatmullRomTo* CatmullRomTo::reverse() const
|
||||
|
@ -511,20 +509,20 @@ bool CatmullRomBy::initWithDuration(float dt, cocos2d::PointArray *points)
|
|||
|
||||
CatmullRomBy* CatmullRomBy::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) CatmullRomBy();
|
||||
a->initWithDuration(this->_duration, this->_points->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) CatmullRomBy();
|
||||
a->initWithDuration(this->_duration, this->_points->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
CatmullRomBy* CatmullRomBy::reverse() const
|
||||
{
|
||||
PointArray *copyConfig = _points->clone();
|
||||
|
||||
//
|
||||
// convert "absolutes" to "diffs"
|
||||
//
|
||||
//
|
||||
// convert "absolutes" to "diffs"
|
||||
//
|
||||
Vec2 p = copyConfig->getControlPointAtIndex(0);
|
||||
for (ssize_t i = 1; i < copyConfig->count(); ++i)
|
||||
{
|
||||
|
@ -535,7 +533,6 @@ CatmullRomBy* CatmullRomBy::reverse() const
|
|||
p = current;
|
||||
}
|
||||
|
||||
|
||||
// convert to "diffs" to "reverse absolute"
|
||||
|
||||
PointArray *reverse = copyConfig->reverse();
|
||||
|
@ -562,4 +559,3 @@ CatmullRomBy* CatmullRomBy::reverse() const
|
|||
}
|
||||
|
||||
NS_CC_END;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -87,7 +87,7 @@ void GridAction::cacheTargetAsGridNode()
|
|||
GridAction* GridAction::reverse() const
|
||||
{
|
||||
// FIXME: This conversion isn't safe.
|
||||
return (GridAction*)ReverseTime::create( this->clone() );
|
||||
return (GridAction*)ReverseTime::create( this->clone() );
|
||||
}
|
||||
|
||||
GridBase* GridAction::getGrid()
|
||||
|
@ -184,11 +184,11 @@ bool AccelDeccelAmplitude::initWithAction(Action *action, float duration)
|
|||
|
||||
AccelDeccelAmplitude* AccelDeccelAmplitude::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) AccelDeccelAmplitude();
|
||||
a->initWithAction(_other->clone(), _rate);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) AccelDeccelAmplitude();
|
||||
a->initWithAction(_other->clone(), _rate);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
AccelDeccelAmplitude::~AccelDeccelAmplitude()
|
||||
|
@ -256,11 +256,11 @@ bool AccelAmplitude::initWithAction(Action *action, float duration)
|
|||
|
||||
AccelAmplitude* AccelAmplitude::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) AccelAmplitude();
|
||||
a->initWithAction(_other->clone(), _duration);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) AccelAmplitude();
|
||||
a->initWithAction(_other->clone(), _duration);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
AccelAmplitude::~AccelAmplitude()
|
||||
|
@ -338,11 +338,11 @@ void DeccelAmplitude::update(float time)
|
|||
|
||||
DeccelAmplitude* DeccelAmplitude::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) DeccelAmplitude();
|
||||
a->initWithAction(_other->clone(), _duration);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) DeccelAmplitude();
|
||||
a->initWithAction(_other->clone(), _duration);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
DeccelAmplitude* DeccelAmplitude::reverse() const
|
||||
|
@ -379,13 +379,13 @@ StopGrid* StopGrid::create()
|
|||
|
||||
StopGrid* StopGrid::clone() const
|
||||
{
|
||||
return StopGrid::create();
|
||||
return StopGrid::create();
|
||||
}
|
||||
|
||||
StopGrid* StopGrid::reverse() const
|
||||
{
|
||||
// no reverse, just clone it
|
||||
return this->clone();
|
||||
// no reverse, just clone it
|
||||
return this->clone();
|
||||
}
|
||||
|
||||
// implementation of ReuseGrid
|
||||
|
@ -434,13 +434,13 @@ void ReuseGrid::cacheTargetAsGridNode()
|
|||
|
||||
ReuseGrid* ReuseGrid::clone() const
|
||||
{
|
||||
return ReuseGrid::create(_times);
|
||||
return ReuseGrid::create(_times);
|
||||
}
|
||||
|
||||
ReuseGrid* ReuseGrid::reverse() const
|
||||
{
|
||||
// no reverse, just clone it
|
||||
return this->clone();
|
||||
// no reverse, just clone it
|
||||
return this->clone();
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -64,11 +64,11 @@ bool Waves3D::initWithDuration(float duration, const Size& gridSize, unsigned in
|
|||
|
||||
Waves3D* Waves3D::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Waves3D();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Waves3D();
|
||||
a->initWithDuration(_duration, _gridSize, _waves, _amplitude);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void Waves3D::update(float time)
|
||||
|
@ -127,11 +127,11 @@ bool FlipX3D::initWithSize(const Size& gridSize, float duration)
|
|||
|
||||
FlipX3D* FlipX3D::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FlipX3D();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FlipX3D();
|
||||
a->initWithSize(_gridSize, _duration);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void FlipX3D::update(float time)
|
||||
|
@ -203,10 +203,10 @@ void FlipX3D::update(float time)
|
|||
FlipY3D* FlipY3D::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FlipY3D();
|
||||
auto a = new (std::nothrow) FlipY3D();
|
||||
a->initWithSize(_gridSize, _duration);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
FlipY3D* FlipY3D::create(float duration)
|
||||
|
@ -333,11 +333,11 @@ bool Lens3D::initWithDuration(float duration, const Size& gridSize, const Vec2&
|
|||
|
||||
Lens3D* Lens3D::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Lens3D();
|
||||
a->initWithDuration(_duration, _gridSize, _position, _radius);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Lens3D();
|
||||
a->initWithDuration(_duration, _gridSize, _position, _radius);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void Lens3D::setPosition(const Vec2& pos)
|
||||
|
@ -437,11 +437,11 @@ void Ripple3D::setPosition(const Vec2& position)
|
|||
|
||||
Ripple3D* Ripple3D::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Ripple3D();
|
||||
a->initWithDuration(_duration, _gridSize, _position, _radius, _waves, _amplitude);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Ripple3D();
|
||||
a->initWithDuration(_duration, _gridSize, _position, _radius, _waves, _amplitude);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void Ripple3D::update(float time)
|
||||
|
@ -504,11 +504,11 @@ bool Shaky3D::initWithDuration(float duration, const Size& gridSize, int range,
|
|||
|
||||
Shaky3D* Shaky3D::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Shaky3D();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Shaky3D();
|
||||
a->initWithDuration(_duration, _gridSize, _randrange, _shakeZ);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void Shaky3D::update(float time)
|
||||
|
@ -570,11 +570,11 @@ bool Liquid::initWithDuration(float duration, const Size& gridSize, unsigned int
|
|||
|
||||
Liquid* Liquid::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Liquid();
|
||||
a->initWithDuration(_duration, _gridSize, _waves, _amplitude);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Liquid();
|
||||
a->initWithDuration(_duration, _gridSize, _waves, _amplitude);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void Liquid::update(float time)
|
||||
|
@ -632,11 +632,11 @@ bool Waves::initWithDuration(float duration, const Size& gridSize, unsigned int
|
|||
|
||||
Waves* Waves::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Waves();
|
||||
a->initWithDuration(_duration, _gridSize, _waves, _amplitude, _horizontal, _vertical);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Waves();
|
||||
a->initWithDuration(_duration, _gridSize, _waves, _amplitude, _horizontal, _vertical);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void Waves::update(float time)
|
||||
|
@ -707,11 +707,11 @@ void Twirl::setPosition(const Vec2& position)
|
|||
|
||||
Twirl *Twirl::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Twirl();
|
||||
a->initWithDuration(_duration, _gridSize, _position, _twirls, _amplitude);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Twirl();
|
||||
a->initWithDuration(_duration, _gridSize, _position, _twirls, _amplitude);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void Twirl::update(float time)
|
||||
|
@ -744,4 +744,3 @@ void Twirl::update(float time)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -82,10 +82,10 @@ ActionInstant* Show::reverse() const
|
|||
|
||||
Show * Show::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Show();
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Show();
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -114,10 +114,10 @@ ActionInstant *Hide::reverse() const
|
|||
|
||||
Hide * Hide::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Hide();
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Hide();
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -143,15 +143,15 @@ void ToggleVisibility::update(float time)
|
|||
|
||||
ToggleVisibility * ToggleVisibility::reverse() const
|
||||
{
|
||||
return ToggleVisibility::create();
|
||||
return ToggleVisibility::create();
|
||||
}
|
||||
|
||||
ToggleVisibility * ToggleVisibility::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ToggleVisibility();
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ToggleVisibility();
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -159,37 +159,37 @@ ToggleVisibility * ToggleVisibility::clone() const
|
|||
//
|
||||
RemoveSelf * RemoveSelf::create(bool isNeedCleanUp /*= true*/)
|
||||
{
|
||||
RemoveSelf *ret = new (std::nothrow) RemoveSelf();
|
||||
RemoveSelf *ret = new (std::nothrow) RemoveSelf();
|
||||
|
||||
if (ret && ret->init(isNeedCleanUp)) {
|
||||
ret->autorelease();
|
||||
}
|
||||
if (ret && ret->init(isNeedCleanUp)) {
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool RemoveSelf::init(bool isNeedCleanUp) {
|
||||
_isNeedCleanUp = isNeedCleanUp;
|
||||
return true;
|
||||
_isNeedCleanUp = isNeedCleanUp;
|
||||
return true;
|
||||
}
|
||||
|
||||
void RemoveSelf::update(float time) {
|
||||
CC_UNUSED_PARAM(time);
|
||||
_target->removeFromParentAndCleanup(_isNeedCleanUp);
|
||||
CC_UNUSED_PARAM(time);
|
||||
_target->removeFromParentAndCleanup(_isNeedCleanUp);
|
||||
}
|
||||
|
||||
RemoveSelf *RemoveSelf::reverse() const
|
||||
{
|
||||
return RemoveSelf::create(_isNeedCleanUp);
|
||||
return RemoveSelf::create(_isNeedCleanUp);
|
||||
}
|
||||
|
||||
RemoveSelf * RemoveSelf::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) RemoveSelf();
|
||||
a->init(_isNeedCleanUp);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) RemoveSelf();
|
||||
a->init(_isNeedCleanUp);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -226,11 +226,11 @@ FlipX* FlipX::reverse() const
|
|||
|
||||
FlipX * FlipX::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FlipX();
|
||||
a->initWithFlipX(_flipX);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FlipX();
|
||||
a->initWithFlipX(_flipX);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
//
|
||||
// FlipY
|
||||
|
@ -266,11 +266,11 @@ FlipY* FlipY::reverse() const
|
|||
|
||||
FlipY * FlipY::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FlipY();
|
||||
a->initWithFlipY(_flipY);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FlipY();
|
||||
a->initWithFlipY(_flipY);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -297,17 +297,17 @@ bool Place::initWithPosition(const Vec2& pos) {
|
|||
|
||||
Place * Place::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Place();
|
||||
a->initWithPosition(_position);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Place();
|
||||
a->initWithPosition(_position);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
Place * Place::reverse() const
|
||||
{
|
||||
// no reverse, just clone
|
||||
return this->clone();
|
||||
// no reverse, just clone
|
||||
return this->clone();
|
||||
}
|
||||
|
||||
void Place::update(float time) {
|
||||
|
@ -348,7 +348,7 @@ CallFunc * CallFunc::create(Ref* selectorTarget, SEL_CallFunc selector)
|
|||
|
||||
bool CallFunc::initWithFunction(const std::function<void()> &func)
|
||||
{
|
||||
_function = func;
|
||||
_function = func;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -390,8 +390,8 @@ CallFunc * CallFunc::clone() const
|
|||
|
||||
CallFunc * CallFunc::reverse() const
|
||||
{
|
||||
// no reverse here, just return a clone
|
||||
return this->clone();
|
||||
// no reverse here, just return a clone
|
||||
return this->clone();
|
||||
}
|
||||
|
||||
void CallFunc::update(float time) {
|
||||
|
@ -466,8 +466,8 @@ bool CallFuncN::initWithTarget(Ref* selectorTarget, SEL_CallFuncN selector)
|
|||
|
||||
CallFuncN * CallFuncN::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) CallFuncN();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) CallFuncN();
|
||||
|
||||
if( _selectorTarget) {
|
||||
a->initWithTarget(_selectorTarget, _callFuncN);
|
||||
|
@ -476,8 +476,8 @@ CallFuncN * CallFuncN::clone() const
|
|||
a->initWithFunction(_functionN);
|
||||
}
|
||||
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -519,16 +519,16 @@ void __CCCallFuncND::execute()
|
|||
|
||||
__CCCallFuncND * __CCCallFuncND::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new __CCCallFuncND();
|
||||
// no copy constructor
|
||||
auto a = new __CCCallFuncND();
|
||||
|
||||
if( _selectorTarget)
|
||||
{
|
||||
a->initWithTarget(_selectorTarget, _callFuncND, _data);
|
||||
}
|
||||
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -580,16 +580,16 @@ bool __CCCallFuncO::initWithTarget(Ref* selectorTarget, SEL_CallFuncO selector,
|
|||
|
||||
__CCCallFuncO * __CCCallFuncO::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new __CCCallFuncO();
|
||||
// no copy constructor
|
||||
auto a = new __CCCallFuncO();
|
||||
|
||||
if( _selectorTarget)
|
||||
{
|
||||
a->initWithTarget(_selectorTarget, _callFuncO, _object);
|
||||
}
|
||||
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
Ref* __CCCallFuncO::getObject() const
|
||||
|
|
|
@ -62,10 +62,10 @@ ExtraAction* ExtraAction::create()
|
|||
}
|
||||
ExtraAction* ExtraAction::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ExtraAction();
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ExtraAction();
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
ExtraAction* ExtraAction::reverse() const
|
||||
|
@ -265,11 +265,11 @@ bool Sequence::initWithTwoActions(FiniteTimeAction *actionOne, FiniteTimeAction
|
|||
|
||||
Sequence* Sequence::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Sequence();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Sequence();
|
||||
a->initWithTwoActions(_actions[0]->clone(), _actions[1]->clone() );
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
Sequence::~Sequence(void)
|
||||
|
@ -333,15 +333,15 @@ void Sequence::update(float t)
|
|||
_actions[0]->stop();
|
||||
}
|
||||
}
|
||||
else if(found==0 && _last==1 )
|
||||
{
|
||||
// Reverse mode ?
|
||||
// FIXME: Bug. this case doesn't contemplate when _last==-1, found=0 and in "reverse mode"
|
||||
// since it will require a hack to know if an action is on reverse mode or not.
|
||||
// "step" should be overriden, and the "reverseMode" value propagated to inner Sequences.
|
||||
_actions[1]->update(0);
|
||||
_actions[1]->stop();
|
||||
}
|
||||
else if(found==0 && _last==1 )
|
||||
{
|
||||
// Reverse mode ?
|
||||
// FIXME: Bug. this case doesn't contemplate when _last==-1, found=0 and in "reverse mode"
|
||||
// since it will require a hack to know if an action is on reverse mode or not.
|
||||
// "step" should be overriden, and the "reverseMode" value propagated to inner Sequences.
|
||||
_actions[1]->update(0);
|
||||
_actions[1]->stop();
|
||||
}
|
||||
// Last action found and it is done.
|
||||
if( found == _last && _actions[found]->isDone() )
|
||||
{
|
||||
|
@ -402,11 +402,11 @@ bool Repeat::initWithAction(FiniteTimeAction *action, unsigned int times)
|
|||
|
||||
Repeat* Repeat::clone(void) const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Repeat();
|
||||
a->initWithAction( _innerAction->clone(), _times );
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Repeat();
|
||||
a->initWithAction( _innerAction->clone(), _times );
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
Repeat::~Repeat(void)
|
||||
|
@ -512,11 +512,11 @@ bool RepeatForever::initWithAction(ActionInterval *action)
|
|||
|
||||
RepeatForever *RepeatForever::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) RepeatForever();
|
||||
a->initWithAction(_innerAction->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) RepeatForever();
|
||||
a->initWithAction(_innerAction->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void RepeatForever::startWithTarget(Node* target)
|
||||
|
@ -678,12 +678,12 @@ bool Spawn::initWithTwoActions(FiniteTimeAction *action1, FiniteTimeAction *acti
|
|||
|
||||
Spawn* Spawn::clone(void) const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Spawn();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Spawn();
|
||||
a->initWithTwoActions(_one->clone(), _two->clone());
|
||||
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
Spawn::~Spawn(void)
|
||||
|
@ -787,14 +787,14 @@ bool RotateTo::initWithDuration(float duration, const Vec3& dstAngle3D)
|
|||
|
||||
RotateTo* RotateTo::clone(void) const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) RotateTo();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) RotateTo();
|
||||
if(_is3D)
|
||||
a->initWithDuration(_duration, _dstAngle);
|
||||
a->initWithDuration(_duration, _dstAngle);
|
||||
else
|
||||
a->initWithDuration(_duration, _dstAngle.x, _dstAngle.y);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void RotateTo::calculateAngles(float &startAngle, float &diffAngle, float dstAngle)
|
||||
|
@ -859,12 +859,6 @@ void RotateTo::update(float time)
|
|||
}
|
||||
else
|
||||
{
|
||||
// _startAngle.x != _startAngle.y || _diffAngle.x != _diffAngle.y
|
||||
if (_target->getPhysicsBody() != nullptr)
|
||||
{
|
||||
CCLOG("RotateTo WARNING: PhysicsBody doesn't support skew rotation");
|
||||
}
|
||||
|
||||
_target->setRotationSkewX(_startAngle.x + _diffAngle.x * time);
|
||||
_target->setRotationSkewY(_startAngle.y + _diffAngle.y * time);
|
||||
}
|
||||
|
@ -878,8 +872,8 @@ void RotateTo::update(float time)
|
|||
|
||||
RotateTo *RotateTo::reverse() const
|
||||
{
|
||||
CCASSERT(false, "RotateTo doesn't support the 'reverse' method");
|
||||
return nullptr;
|
||||
CCASSERT(false, "RotateTo doesn't support the 'reverse' method");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -956,14 +950,14 @@ bool RotateBy::initWithDuration(float duration, const Vec3& deltaAngle3D)
|
|||
|
||||
RotateBy* RotateBy::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) RotateBy();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) RotateBy();
|
||||
if(_is3D)
|
||||
a->initWithDuration(_duration, _deltaAngle);
|
||||
else
|
||||
a->initWithDuration(_duration, _deltaAngle.x, _deltaAngle.y);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void RotateBy::startWithTarget(Node *target)
|
||||
|
@ -1002,12 +996,6 @@ void RotateBy::update(float time)
|
|||
}
|
||||
else
|
||||
{
|
||||
// _startAngle.x != _startAngle.y || _deltaAngle.x != _deltaAngle.y
|
||||
if (_target->getPhysicsBody() != nullptr)
|
||||
{
|
||||
CCLOG("RotateBy WARNING: PhysicsBody doesn't support skew rotation");
|
||||
}
|
||||
|
||||
_target->setRotationSkewX(_startAngle.x + _deltaAngle.x * time);
|
||||
_target->setRotationSkewY(_startAngle.y + _deltaAngle.y * time);
|
||||
}
|
||||
|
@ -1085,11 +1073,11 @@ bool MoveBy::initWithDuration(float duration, const Vec3& deltaPosition)
|
|||
|
||||
MoveBy* MoveBy::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) MoveBy();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) MoveBy();
|
||||
a->initWithDuration(_duration, _positionDelta);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void MoveBy::startWithTarget(Node *target)
|
||||
|
@ -1170,11 +1158,11 @@ bool MoveTo::initWithDuration(float duration, const Vec3& position)
|
|||
|
||||
MoveTo* MoveTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) MoveTo();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) MoveTo();
|
||||
a->initWithDuration(_duration, _endPosition);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void MoveTo::startWithTarget(Node *target)
|
||||
|
@ -1222,17 +1210,17 @@ bool SkewTo::initWithDuration(float t, float sx, float sy)
|
|||
|
||||
SkewTo* SkewTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) SkewTo();
|
||||
a->initWithDuration(_duration, _endSkewX, _endSkewY);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) SkewTo();
|
||||
a->initWithDuration(_duration, _endSkewX, _endSkewY);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
SkewTo* SkewTo::reverse() const
|
||||
{
|
||||
CCASSERT(false, "reverse() not supported in SkewTo");
|
||||
return nullptr;
|
||||
CCASSERT(false, "reverse() not supported in SkewTo");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SkewTo::startWithTarget(Node *target)
|
||||
|
@ -1325,11 +1313,11 @@ SkewBy* SkewBy::create(float t, float sx, float sy)
|
|||
|
||||
SkewBy * SkewBy::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) SkewBy();
|
||||
a->initWithDuration(_duration, _skewX, _skewY);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) SkewBy();
|
||||
a->initWithDuration(_duration, _skewX, _skewY);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
bool SkewBy::initWithDuration(float t, float deltaSkewX, float deltaSkewY)
|
||||
|
@ -1392,11 +1380,11 @@ bool JumpBy::initWithDuration(float duration, const Vec2& position, float height
|
|||
|
||||
JumpBy* JumpBy::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) JumpBy();
|
||||
a->initWithDuration(_duration, _delta, _height, _jumps);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) JumpBy();
|
||||
a->initWithDuration(_duration, _delta, _height, _jumps);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void JumpBy::startWithTarget(Node *target)
|
||||
|
@ -1450,25 +1438,41 @@ JumpTo* JumpTo::create(float duration, const Vec2& position, float height, int j
|
|||
return jumpTo;
|
||||
}
|
||||
|
||||
bool JumpTo::initWithDuration(float duration, const Vec2& position, float height, int jumps)
|
||||
{
|
||||
CCASSERT(jumps>=0, "Number of jumps must be >= 0");
|
||||
|
||||
if (ActionInterval::initWithDuration(duration) && jumps>=0)
|
||||
{
|
||||
_endPosition = position;
|
||||
_height = height;
|
||||
_jumps = jumps;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
JumpTo* JumpTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) JumpTo();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) JumpTo();
|
||||
a->initWithDuration(_duration, _delta, _height, _jumps);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
JumpTo* JumpTo::reverse() const
|
||||
{
|
||||
CCASSERT(false, "reverse() not supported in JumpTo");
|
||||
return nullptr;
|
||||
CCASSERT(false, "reverse() not supported in JumpTo");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void JumpTo::startWithTarget(Node *target)
|
||||
{
|
||||
JumpBy::startWithTarget(target);
|
||||
_delta = Vec2(_delta.x - _startPosition.x, _delta.y - _startPosition.y);
|
||||
_delta = Vec2(_endPosition.x - _startPosition.x, _endPosition.y - _startPosition.y);
|
||||
}
|
||||
|
||||
// Bezier cubic formula:
|
||||
|
@ -1515,11 +1519,11 @@ void BezierBy::startWithTarget(Node *target)
|
|||
|
||||
BezierBy* BezierBy::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) BezierBy();
|
||||
a->initWithDuration(_duration, _config);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) BezierBy();
|
||||
a->initWithDuration(_duration, _config);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void BezierBy::update(float time)
|
||||
|
@ -1592,11 +1596,11 @@ bool BezierTo::initWithDuration(float t, const ccBezierConfig &c)
|
|||
|
||||
BezierTo* BezierTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) BezierTo();
|
||||
a->initWithDuration(_duration, _toConfig);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) BezierTo();
|
||||
a->initWithDuration(_duration, _toConfig);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void BezierTo::startWithTarget(Node *target)
|
||||
|
@ -1609,8 +1613,8 @@ void BezierTo::startWithTarget(Node *target)
|
|||
|
||||
BezierTo* BezierTo::reverse() const
|
||||
{
|
||||
CCASSERT(false, "CCBezierTo doesn't support the 'reverse' method");
|
||||
return nullptr;
|
||||
CCASSERT(false, "CCBezierTo doesn't support the 'reverse' method");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1688,17 +1692,17 @@ bool ScaleTo::initWithDuration(float duration, float sx, float sy, float sz)
|
|||
|
||||
ScaleTo* ScaleTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ScaleTo();
|
||||
a->initWithDuration(_duration, _endScaleX, _endScaleY, _endScaleZ);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ScaleTo();
|
||||
a->initWithDuration(_duration, _endScaleX, _endScaleY, _endScaleZ);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
ScaleTo* ScaleTo::reverse() const
|
||||
{
|
||||
CCASSERT(false, "reverse() not supported in ScaleTo");
|
||||
return nullptr;
|
||||
CCASSERT(false, "reverse() not supported in ScaleTo");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1756,11 +1760,11 @@ ScaleBy* ScaleBy::create(float duration, float sx, float sy, float sz)
|
|||
|
||||
ScaleBy* ScaleBy::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ScaleBy();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ScaleBy();
|
||||
a->initWithDuration(_duration, _endScaleX, _endScaleY, _endScaleZ);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void ScaleBy::startWithTarget(Node *target)
|
||||
|
@ -1816,11 +1820,11 @@ void Blink::startWithTarget(Node *target)
|
|||
|
||||
Blink* Blink::clone(void) const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Blink();
|
||||
a->initWithDuration(_duration, _times);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Blink();
|
||||
a->initWithDuration(_duration, _times);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void Blink::update(float time)
|
||||
|
@ -1854,11 +1858,11 @@ FadeIn* FadeIn::create(float d)
|
|||
|
||||
FadeIn* FadeIn::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeIn();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeIn();
|
||||
a->initWithDuration(_duration,255.0f);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void FadeIn::setReverseAction(cocos2d::FadeTo *ac)
|
||||
|
@ -1908,11 +1912,11 @@ FadeOut* FadeOut::create(float d)
|
|||
|
||||
FadeOut* FadeOut::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeOut();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeOut();
|
||||
a->initWithDuration(_duration,0.0f);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void FadeOut::startWithTarget(cocos2d::Node *target)
|
||||
|
@ -1969,17 +1973,17 @@ bool FadeTo::initWithDuration(float duration, GLubyte opacity)
|
|||
|
||||
FadeTo* FadeTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeTo();
|
||||
a->initWithDuration(_duration, _toOpacity);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeTo();
|
||||
a->initWithDuration(_duration, _toOpacity);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
FadeTo* FadeTo::reverse() const
|
||||
{
|
||||
CCASSERT(false, "reverse() not supported in FadeTo");
|
||||
return nullptr;
|
||||
CCASSERT(false, "reverse() not supported in FadeTo");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void FadeTo::startWithTarget(Node *target)
|
||||
|
@ -2027,17 +2031,17 @@ bool TintTo::initWithDuration(float duration, GLubyte red, GLubyte green, GLubyt
|
|||
|
||||
TintTo* TintTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) TintTo();
|
||||
a->initWithDuration(_duration, _to.r, _to.g, _to.b);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) TintTo();
|
||||
a->initWithDuration(_duration, _to.r, _to.g, _to.b);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
TintTo* TintTo::reverse() const
|
||||
{
|
||||
CCASSERT(false, "reverse() not supported in TintTo");
|
||||
return nullptr;
|
||||
CCASSERT(false, "reverse() not supported in TintTo");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TintTo::startWithTarget(Node *target)
|
||||
|
@ -2089,11 +2093,11 @@ bool TintBy::initWithDuration(float duration, GLshort deltaRed, GLshort deltaGre
|
|||
|
||||
TintBy* TintBy::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) TintBy();
|
||||
a->initWithDuration(_duration, (GLubyte)_deltaR, (GLubyte)_deltaG, (GLubyte)_deltaB);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) TintBy();
|
||||
a->initWithDuration(_duration, (GLubyte)_deltaR, (GLubyte)_deltaG, (GLubyte)_deltaB);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void TintBy::startWithTarget(Node *target)
|
||||
|
@ -2139,11 +2143,11 @@ DelayTime* DelayTime::create(float d)
|
|||
|
||||
DelayTime* DelayTime::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) DelayTime();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) DelayTime();
|
||||
a->initWithDuration(_duration);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void DelayTime::update(float time)
|
||||
|
@ -2192,11 +2196,11 @@ bool ReverseTime::initWithAction(FiniteTimeAction *action)
|
|||
|
||||
ReverseTime* ReverseTime::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ReverseTime();
|
||||
a->initWithAction( _other->clone() );
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ReverseTime();
|
||||
a->initWithAction( _other->clone() );
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
ReverseTime::ReverseTime() : _other(nullptr)
|
||||
|
@ -2309,11 +2313,11 @@ void Animate::setAnimation(cocos2d::Animation *animation)
|
|||
|
||||
Animate* Animate::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Animate();
|
||||
a->initWithAnimation(_animation->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Animate();
|
||||
a->initWithAnimation(_animation->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void Animate::startWithTarget(Node *target)
|
||||
|
@ -2454,21 +2458,21 @@ bool TargetedAction::initWithTarget(Node* target, FiniteTimeAction* action)
|
|||
|
||||
TargetedAction* TargetedAction::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) TargetedAction();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) TargetedAction();
|
||||
// win32 : use the _other's copy object.
|
||||
a->initWithTarget(_forcedTarget, _action->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->initWithTarget(_forcedTarget, _action->clone());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
TargetedAction* TargetedAction::reverse() const
|
||||
{
|
||||
// just reverse the internal action
|
||||
auto a = new (std::nothrow) TargetedAction();
|
||||
a->initWithTarget(_forcedTarget, _action->reverse());
|
||||
a->autorelease();
|
||||
return a;
|
||||
// just reverse the internal action
|
||||
auto a = new (std::nothrow) TargetedAction();
|
||||
a->initWithTarget(_forcedTarget, _action->reverse());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void TargetedAction::startWithTarget(Node *target)
|
||||
|
|
|
@ -604,6 +604,12 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
JumpTo() {}
|
||||
virtual ~JumpTo() {}
|
||||
|
||||
/** initializes the action */
|
||||
bool initWithDuration(float duration, const Vec2& position, float height, int jumps);
|
||||
|
||||
protected:
|
||||
Vec2 _endPosition;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(JumpTo);
|
||||
};
|
||||
|
|
|
@ -49,11 +49,11 @@ PageTurn3D* PageTurn3D::create(float duration, const Size& gridSize)
|
|||
|
||||
PageTurn3D *PageTurn3D::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) PageTurn3D();
|
||||
a->initWithDuration(_duration, _gridSize);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) PageTurn3D();
|
||||
a->initWithDuration(_duration, _gridSize);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
GridBase* PageTurn3D::getGrid()
|
||||
|
|
|
@ -55,17 +55,17 @@ bool ProgressTo::initWithDuration(float duration, float percent)
|
|||
|
||||
ProgressTo* ProgressTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ProgressTo();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ProgressTo();
|
||||
a->initWithDuration(_duration, _to);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
ProgressTo* ProgressTo::reverse() const
|
||||
{
|
||||
CCASSERT(false, "reverse() not supported in ProgressTo");
|
||||
return nullptr;
|
||||
CCASSERT(false, "reverse() not supported in ProgressTo");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ProgressTo::startWithTarget(Node *target)
|
||||
|
@ -105,11 +105,11 @@ bool ProgressFromTo::initWithDuration(float duration, float fromPercentage, floa
|
|||
|
||||
ProgressFromTo* ProgressFromTo::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ProgressFromTo();
|
||||
a->initWithDuration(_duration, _from, _to);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ProgressFromTo();
|
||||
a->initWithDuration(_duration, _from, _to);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,4 +129,3 @@ void ProgressFromTo::update(float time)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -74,11 +74,11 @@ bool ShakyTiles3D::initWithDuration(float duration, const Size& gridSize, int ra
|
|||
|
||||
ShakyTiles3D* ShakyTiles3D::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ShakyTiles3D();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ShakyTiles3D();
|
||||
a->initWithDuration(_duration, _gridSize, _randrange, _shakeZ);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void ShakyTiles3D::update(float time)
|
||||
|
@ -154,11 +154,11 @@ bool ShatteredTiles3D::initWithDuration(float duration, const Size& gridSize, in
|
|||
|
||||
ShatteredTiles3D* ShatteredTiles3D::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ShatteredTiles3D();
|
||||
a->initWithDuration(_duration, _gridSize, _randrange, _shatterZ);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ShatteredTiles3D();
|
||||
a->initWithDuration(_duration, _gridSize, _randrange, _shatterZ);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void ShatteredTiles3D::update(float time)
|
||||
|
@ -239,11 +239,11 @@ bool ShuffleTiles::initWithDuration(float duration, const Size& gridSize, unsign
|
|||
|
||||
ShuffleTiles* ShuffleTiles::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ShuffleTiles();
|
||||
a->initWithDuration(_duration, _gridSize, _seed);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ShuffleTiles();
|
||||
a->initWithDuration(_duration, _gridSize, _seed);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
ShuffleTiles::~ShuffleTiles()
|
||||
|
@ -371,11 +371,11 @@ FadeOutTRTiles* FadeOutTRTiles::create(float duration, const Size& gridSize)
|
|||
|
||||
FadeOutTRTiles* FadeOutTRTiles::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeOutTRTiles();
|
||||
a->initWithDuration(_duration, _gridSize);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeOutTRTiles();
|
||||
a->initWithDuration(_duration, _gridSize);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
float FadeOutTRTiles::testFunc(const Size& pos, float time)
|
||||
|
@ -467,11 +467,11 @@ FadeOutBLTiles* FadeOutBLTiles::create(float duration, const Size& gridSize)
|
|||
|
||||
FadeOutBLTiles* FadeOutBLTiles::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeOutBLTiles();
|
||||
a->initWithDuration(_duration, _gridSize);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeOutBLTiles();
|
||||
a->initWithDuration(_duration, _gridSize);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
float FadeOutBLTiles::testFunc(const Size& pos, float time)
|
||||
|
@ -508,11 +508,11 @@ FadeOutUpTiles* FadeOutUpTiles::create(float duration, const Size& gridSize)
|
|||
|
||||
FadeOutUpTiles* FadeOutUpTiles::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeOutUpTiles();
|
||||
a->initWithDuration(_duration, _gridSize);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeOutUpTiles();
|
||||
a->initWithDuration(_duration, _gridSize);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
float FadeOutUpTiles::testFunc(const Size& pos, float time)
|
||||
|
@ -562,11 +562,11 @@ FadeOutDownTiles* FadeOutDownTiles::create(float duration, const Size& gridSize)
|
|||
|
||||
FadeOutDownTiles* FadeOutDownTiles::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeOutDownTiles();
|
||||
a->initWithDuration(_duration, _gridSize);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) FadeOutDownTiles();
|
||||
a->initWithDuration(_duration, _gridSize);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
float FadeOutDownTiles::testFunc(const Size& pos, float time)
|
||||
|
@ -630,11 +630,11 @@ bool TurnOffTiles::initWithDuration(float duration, const Size& gridSize, unsign
|
|||
|
||||
TurnOffTiles* TurnOffTiles::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) TurnOffTiles();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) TurnOffTiles();
|
||||
a->initWithDuration(_duration, _gridSize, _seed );
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
TurnOffTiles::~TurnOffTiles(void)
|
||||
|
@ -744,11 +744,11 @@ bool WavesTiles3D::initWithDuration(float duration, const Size& gridSize, unsign
|
|||
|
||||
WavesTiles3D* WavesTiles3D::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) WavesTiles3D();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) WavesTiles3D();
|
||||
a->initWithDuration(_duration, _gridSize, _waves, _amplitude);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void WavesTiles3D::update(float time)
|
||||
|
@ -807,11 +807,11 @@ bool JumpTiles3D::initWithDuration(float duration, const Size& gridSize, unsigne
|
|||
|
||||
JumpTiles3D* JumpTiles3D::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) JumpTiles3D();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) JumpTiles3D();
|
||||
a->initWithDuration(_duration, _gridSize, _jumps, _amplitude);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void JumpTiles3D::update(float time)
|
||||
|
@ -875,11 +875,11 @@ bool SplitRows::initWithDuration(float duration, unsigned int rows)
|
|||
|
||||
SplitRows* SplitRows::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) SplitRows();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) SplitRows();
|
||||
a->initWithDuration(_duration, _rows);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void SplitRows::startWithTarget(Node *target)
|
||||
|
@ -938,11 +938,11 @@ bool SplitCols::initWithDuration(float duration, unsigned int cols)
|
|||
|
||||
SplitCols* SplitCols::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) SplitCols();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) SplitCols();
|
||||
a->initWithDuration(_duration, _cols);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void SplitCols::startWithTarget(Node *target)
|
||||
|
|
|
@ -57,11 +57,11 @@ bool ActionTween::initWithDuration(float duration, const std::string& key, float
|
|||
|
||||
ActionTween *ActionTween::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ActionTween();
|
||||
a->initWithDuration(_duration, _key.c_str(), _from, _to);
|
||||
a->autorelease();
|
||||
return a;
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) ActionTween();
|
||||
a->initWithDuration(_duration, _key.c_str(), _from, _to);
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void ActionTween::startWithTarget(Node *target)
|
||||
|
|
|
@ -70,14 +70,14 @@ AnimationFrame::~AnimationFrame()
|
|||
|
||||
AnimationFrame* AnimationFrame::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto frame = new (std::nothrow) AnimationFrame();
|
||||
// no copy constructor
|
||||
auto frame = new (std::nothrow) AnimationFrame();
|
||||
frame->initWithSpriteFrame(_spriteFrame->clone(),
|
||||
_delayUnits,
|
||||
_userInfo);
|
||||
_delayUnits,
|
||||
_userInfo);
|
||||
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
|
||||
// implementation of Animation
|
||||
|
@ -191,12 +191,12 @@ float Animation::getDuration(void) const
|
|||
|
||||
Animation* Animation::clone() const
|
||||
{
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Animation();
|
||||
// no copy constructor
|
||||
auto a = new (std::nothrow) Animation();
|
||||
a->initWithAnimationFrames(_frames, _delayPerUnit, _loops);
|
||||
a->setRestoreOriginalFrame(_restoreOriginalFrame);
|
||||
a->autorelease();
|
||||
return a;
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -60,21 +60,21 @@ AtlasNode::~AtlasNode()
|
|||
|
||||
AtlasNode * AtlasNode::create(const std::string& tile, int tileWidth, int tileHeight, int itemsToRender)
|
||||
{
|
||||
AtlasNode * ret = new (std::nothrow) AtlasNode();
|
||||
if (ret->initWithTileFile(tile, tileWidth, tileHeight, itemsToRender))
|
||||
{
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
}
|
||||
CC_SAFE_DELETE(ret);
|
||||
return nullptr;
|
||||
AtlasNode * ret = new (std::nothrow) AtlasNode();
|
||||
if (ret->initWithTileFile(tile, tileWidth, tileHeight, itemsToRender))
|
||||
{
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
}
|
||||
CC_SAFE_DELETE(ret);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool AtlasNode::initWithTileFile(const std::string& tile, int tileWidth, int tileHeight, int itemsToRender)
|
||||
{
|
||||
CCASSERT(tile.size() > 0, "file size should not be empty");
|
||||
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(tile);
|
||||
return initWithTexture(texture, tileWidth, tileHeight, itemsToRender);
|
||||
return initWithTexture(texture, tileWidth, tileHeight, itemsToRender);
|
||||
}
|
||||
|
||||
bool AtlasNode::initWithTexture(Texture2D* texture, int tileWidth, int tileHeight, int itemsToRender)
|
||||
|
|
|
@ -118,7 +118,7 @@ Component* Component::create(void)
|
|||
{
|
||||
CC_SAFE_DELETE(ret);
|
||||
}
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
const std::string& Component::getName() const
|
||||
|
|
|
@ -43,62 +43,62 @@ static Vec2 v2fzero(0.0f,0.0f);
|
|||
static inline Vec2 v2f(float x, float y)
|
||||
{
|
||||
Vec2 ret(x, y);
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline Vec2 v2fadd(const Vec2 &v0, const Vec2 &v1)
|
||||
{
|
||||
return v2f(v0.x+v1.x, v0.y+v1.y);
|
||||
return v2f(v0.x+v1.x, v0.y+v1.y);
|
||||
}
|
||||
|
||||
static inline Vec2 v2fsub(const Vec2 &v0, const Vec2 &v1)
|
||||
{
|
||||
return v2f(v0.x-v1.x, v0.y-v1.y);
|
||||
return v2f(v0.x-v1.x, v0.y-v1.y);
|
||||
}
|
||||
|
||||
static inline Vec2 v2fmult(const Vec2 &v, float s)
|
||||
{
|
||||
return v2f(v.x * s, v.y * s);
|
||||
return v2f(v.x * s, v.y * s);
|
||||
}
|
||||
|
||||
static inline Vec2 v2fperp(const Vec2 &p0)
|
||||
{
|
||||
return v2f(-p0.y, p0.x);
|
||||
return v2f(-p0.y, p0.x);
|
||||
}
|
||||
|
||||
static inline Vec2 v2fneg(const Vec2 &p0)
|
||||
{
|
||||
return v2f(-p0.x, - p0.y);
|
||||
return v2f(-p0.x, - p0.y);
|
||||
}
|
||||
|
||||
static inline float v2fdot(const Vec2 &p0, const Vec2 &p1)
|
||||
{
|
||||
return p0.x * p1.x + p0.y * p1.y;
|
||||
return p0.x * p1.x + p0.y * p1.y;
|
||||
}
|
||||
|
||||
static inline Vec2 v2fforangle(float _a_)
|
||||
{
|
||||
return v2f(cosf(_a_), sinf(_a_));
|
||||
return v2f(cosf(_a_), sinf(_a_));
|
||||
}
|
||||
|
||||
static inline Vec2 v2fnormalize(const Vec2 &p)
|
||||
{
|
||||
Vec2 r = Vec2(p.x, p.y).getNormalized();
|
||||
return v2f(r.x, r.y);
|
||||
Vec2 r = Vec2(p.x, p.y).getNormalized();
|
||||
return v2f(r.x, r.y);
|
||||
}
|
||||
|
||||
static inline Vec2 __v2f(const Vec2 &v)
|
||||
{
|
||||
//#ifdef __LP64__
|
||||
return v2f(v.x, v.y);
|
||||
return v2f(v.x, v.y);
|
||||
// #else
|
||||
// return * ((Vec2*) &v);
|
||||
// return * ((Vec2*) &v);
|
||||
// #endif
|
||||
}
|
||||
|
||||
static inline Tex2F __t(const Vec2 &v)
|
||||
{
|
||||
return *(Tex2F*)&v;
|
||||
return *(Tex2F*)&v;
|
||||
}
|
||||
|
||||
// implementation of DrawNode
|
||||
|
@ -175,9 +175,9 @@ void DrawNode::ensureCapacity(int count)
|
|||
|
||||
if(_bufferCount + count > _bufferCapacity)
|
||||
{
|
||||
_bufferCapacity += MAX(_bufferCapacity, count);
|
||||
_buffer = (V2F_C4B_T2F*)realloc(_buffer, _bufferCapacity*sizeof(V2F_C4B_T2F));
|
||||
}
|
||||
_bufferCapacity += MAX(_bufferCapacity, count);
|
||||
_buffer = (V2F_C4B_T2F*)realloc(_buffer, _bufferCapacity*sizeof(V2F_C4B_T2F));
|
||||
}
|
||||
}
|
||||
|
||||
void DrawNode::ensureCapacityGLPoint(int count)
|
||||
|
@ -391,13 +391,10 @@ void DrawNode::onDrawGLLine(const Mat4 &transform, uint32_t flags)
|
|||
|
||||
void DrawNode::onDrawGLPoint(const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_U_COLOR);
|
||||
auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_COLOR);
|
||||
glProgram->use();
|
||||
glProgram->setUniformsForBuiltins(transform);
|
||||
|
||||
glProgram->setUniformLocationWith4fv(glProgram->getUniformLocation("u_color"), (GLfloat*) &_pointColor.r, 1);
|
||||
glProgram->setUniformLocationWith1f(glProgram->getUniformLocation("u_pointSize"), _pointSize);
|
||||
|
||||
if (_dirtyGLPoint)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
|
||||
|
@ -459,6 +456,12 @@ void DrawNode::drawPoints(const Vec2 *position, unsigned int numberOfPoints, con
|
|||
_dirtyGLPoint = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawPoints(const Vec2 *position, unsigned int numberOfPoints, const float pointSize, const Color4F &color)
|
||||
{
|
||||
_pointSize = pointSize;
|
||||
drawPoints(position, numberOfPoints, color);
|
||||
}
|
||||
|
||||
void DrawNode::drawLine(const Vec2 &origin, const Vec2 &destination, const Color4F &color)
|
||||
{
|
||||
ensureCapacityGLLine(2);
|
||||
|
@ -643,90 +646,77 @@ void DrawNode::drawDot(const Vec2 &pos, float radius, const Color4F &color)
|
|||
{
|
||||
unsigned int vertex_count = 2*3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
||||
V2F_C4B_T2F a = {Vec2(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) };
|
||||
V2F_C4B_T2F b = {Vec2(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) };
|
||||
V2F_C4B_T2F c = {Vec2(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) };
|
||||
V2F_C4B_T2F d = {Vec2(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) };
|
||||
|
||||
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||
V2F_C4B_T2F_Triangle triangle0 = {a, b, c};
|
||||
V2F_C4B_T2F_Triangle triangle1 = {a, c, d};
|
||||
triangles[0] = triangle0;
|
||||
triangles[1] = triangle1;
|
||||
|
||||
_bufferCount += vertex_count;
|
||||
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawRect(const Vec2 &lb, const Vec2 <, const Vec2 &rt, const Vec2& rb, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = 2*3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
||||
V2F_C4B_T2F a = {lb, Color4B(color), Tex2F(-1.0, -1.0) };
|
||||
V2F_C4B_T2F b = {lt, Color4B(color), Tex2F(-1.0, 1.0) };
|
||||
V2F_C4B_T2F c = {rt, Color4B(color), Tex2F( 1.0, 1.0) };
|
||||
V2F_C4B_T2F d = {rb, Color4B(color), Tex2F( 1.0, -1.0) };
|
||||
|
||||
|
||||
V2F_C4B_T2F a = {Vec2(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) };
|
||||
V2F_C4B_T2F b = {Vec2(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) };
|
||||
V2F_C4B_T2F c = {Vec2(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) };
|
||||
V2F_C4B_T2F d = {Vec2(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) };
|
||||
|
||||
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||
V2F_C4B_T2F_Triangle triangle0 = {a, b, c};
|
||||
V2F_C4B_T2F_Triangle triangle1 = {a, c, d};
|
||||
triangles[0] = triangle0;
|
||||
triangles[1] = triangle1;
|
||||
|
||||
|
||||
_bufferCount += vertex_count;
|
||||
|
||||
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawRect(const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Vec2& p4, const Color4F &color)
|
||||
{
|
||||
drawLine(Vec2(p1.x, p1.y), Vec2(p2.x, p2.y), color);
|
||||
drawLine(Vec2(p2.x, p2.y), Vec2(p3.x, p3.y), color);
|
||||
drawLine(Vec2(p3.x, p3.y), Vec2(p4.x, p4.y), color);
|
||||
drawLine(Vec2(p4.x, p4.y), Vec2(p1.x, p1.y), color);
|
||||
}
|
||||
|
||||
void DrawNode::drawSegment(const Vec2 &from, const Vec2 &to, float radius, const Color4F &color)
|
||||
{
|
||||
unsigned int vertex_count = 6*3;
|
||||
ensureCapacity(vertex_count);
|
||||
|
||||
Vec2 a = __v2f(from);
|
||||
Vec2 b = __v2f(to);
|
||||
|
||||
|
||||
Vec2 n = v2fnormalize(v2fperp(v2fsub(b, a)));
|
||||
Vec2 t = v2fperp(n);
|
||||
|
||||
Vec2 nw = v2fmult(n, radius);
|
||||
Vec2 tw = v2fmult(t, radius);
|
||||
Vec2 v0 = v2fsub(b, v2fadd(nw, tw));
|
||||
Vec2 v1 = v2fadd(b, v2fsub(nw, tw));
|
||||
Vec2 v2 = v2fsub(b, nw);
|
||||
Vec2 v3 = v2fadd(b, nw);
|
||||
Vec2 v4 = v2fsub(a, nw);
|
||||
Vec2 v5 = v2fadd(a, nw);
|
||||
Vec2 v6 = v2fsub(a, v2fsub(nw, tw));
|
||||
Vec2 v7 = v2fadd(a, v2fadd(nw, tw));
|
||||
|
||||
|
||||
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||
|
||||
|
||||
Vec2 a = __v2f(from);
|
||||
Vec2 b = __v2f(to);
|
||||
|
||||
|
||||
Vec2 n = v2fnormalize(v2fperp(v2fsub(b, a)));
|
||||
Vec2 t = v2fperp(n);
|
||||
|
||||
Vec2 nw = v2fmult(n, radius);
|
||||
Vec2 tw = v2fmult(t, radius);
|
||||
Vec2 v0 = v2fsub(b, v2fadd(nw, tw));
|
||||
Vec2 v1 = v2fadd(b, v2fsub(nw, tw));
|
||||
Vec2 v2 = v2fsub(b, nw);
|
||||
Vec2 v3 = v2fadd(b, nw);
|
||||
Vec2 v4 = v2fsub(a, nw);
|
||||
Vec2 v5 = v2fadd(a, nw);
|
||||
Vec2 v6 = v2fsub(a, v2fsub(nw, tw));
|
||||
Vec2 v7 = v2fadd(a, v2fadd(nw, tw));
|
||||
|
||||
|
||||
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||
|
||||
V2F_C4B_T2F_Triangle triangles0 = {
|
||||
{v0, Color4B(color), __t(v2fneg(v2fadd(n, t)))},
|
||||
{v1, Color4B(color), __t(v2fsub(n, t))},
|
||||
{v2, Color4B(color), __t(v2fneg(n))},
|
||||
};
|
||||
triangles[0] = triangles0;
|
||||
|
||||
triangles[0] = triangles0;
|
||||
|
||||
V2F_C4B_T2F_Triangle triangles1 = {
|
||||
{v3, Color4B(color), __t(n)},
|
||||
{v1, Color4B(color), __t(v2fsub(n, t))},
|
||||
{v2, Color4B(color), __t(v2fneg(n))},
|
||||
};
|
||||
triangles[1] = triangles1;
|
||||
|
||||
triangles[1] = triangles1;
|
||||
|
||||
V2F_C4B_T2F_Triangle triangles2 = {
|
||||
{v3, Color4B(color), __t(n)},
|
||||
{v4, Color4B(color), __t(v2fneg(n))},
|
||||
{v2, Color4B(color), __t(v2fneg(n))},
|
||||
};
|
||||
triangles[2] = triangles2;
|
||||
triangles[2] = triangles2;
|
||||
|
||||
V2F_C4B_T2F_Triangle triangles3 = {
|
||||
{v3, Color4B(color), __t(n)},
|
||||
|
@ -740,18 +730,18 @@ void DrawNode::drawSegment(const Vec2 &from, const Vec2 &to, float radius, const
|
|||
{v4, Color4B(color), __t(v2fneg(n)) },
|
||||
{v5, Color4B(color), __t(n)},
|
||||
};
|
||||
triangles[4] = triangles4;
|
||||
triangles[4] = triangles4;
|
||||
|
||||
V2F_C4B_T2F_Triangle triangles5 = {
|
||||
{v6, Color4B(color), __t(v2fsub(t, n))},
|
||||
{v7, Color4B(color), __t(v2fadd(n, t))},
|
||||
{v5, Color4B(color), __t(n)},
|
||||
};
|
||||
triangles[5] = triangles5;
|
||||
|
||||
_bufferCount += vertex_count;
|
||||
|
||||
_dirty = true;
|
||||
triangles[5] = triangles5;
|
||||
|
||||
_bufferCount += vertex_count;
|
||||
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
void DrawNode::drawPolygon(const Vec2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor)
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
void drawPoint(const Vec2& point, const float pointSize, const Color4F &color);
|
||||
|
||||
void drawPoints(const Vec2 *position, unsigned int numberOfPoints, const Color4F &color);
|
||||
void drawPoints(const Vec2 *position, unsigned int numberOfPoints, const float pointSize, const Color4F &color);
|
||||
|
||||
void drawLine(const Vec2 &origin, const Vec2 &destination, const Color4F &color);
|
||||
|
||||
|
@ -79,7 +80,7 @@ public:
|
|||
/** draw a dot at a position, with a given radius and color */
|
||||
void drawDot(const Vec2 &pos, float radius, const Color4F &color);
|
||||
|
||||
void drawRect(const Vec2 &lb, const Vec2 <, const Vec2 &rt, const Vec2& rb, const Color4F &color);
|
||||
void drawRect(const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Vec2& p4, const Color4F &color);
|
||||
|
||||
void drawSolidRect(const Vec2 &origin, const Vec2 &destination, const Color4F &color);
|
||||
|
||||
|
|
|
@ -124,8 +124,8 @@ void init()
|
|||
|
||||
void free()
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(s_shader);
|
||||
s_initialized = false;
|
||||
CC_SAFE_RELEASE_NULL(s_shader);
|
||||
s_initialized = false;
|
||||
}
|
||||
|
||||
void drawPoint(const Vec2& point)
|
||||
|
|
|
@ -102,5 +102,3 @@ const char * Font::getCurrentGlyphCollection() const
|
|||
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
||||
|
|
|
@ -85,17 +85,17 @@ typedef struct _BMFontPadding {
|
|||
|
||||
typedef struct _FontDefHashElement
|
||||
{
|
||||
unsigned int key; // key. Font Unicode value
|
||||
BMFontDef fontDef; // font definition
|
||||
UT_hash_handle hh;
|
||||
unsigned int key; // key. Font Unicode value
|
||||
BMFontDef fontDef; // font definition
|
||||
UT_hash_handle hh;
|
||||
} tFontDefHashElement;
|
||||
|
||||
// Equal function for targetSet.
|
||||
typedef struct _KerningHashElement
|
||||
{
|
||||
int key; // key for the hash. 16-bit for 1st element, 16-bit for 2nd element
|
||||
int amount;
|
||||
UT_hash_handle hh;
|
||||
int key; // key for the hash. 16-bit for 1st element, 16-bit for 2nd element
|
||||
int amount;
|
||||
UT_hash_handle hh;
|
||||
} tKerningHashElement;
|
||||
|
||||
/** @brief BMFontConfiguration has parsed configuration of the the .fnt file
|
||||
|
@ -147,7 +147,7 @@ public:
|
|||
std::set<unsigned int>* getCharacterSet() const;
|
||||
private:
|
||||
std::set<unsigned int>* parseConfigFile(const std::string& controlFile);
|
||||
std::set<unsigned int>* parseBinaryConfigFile(unsigned char* pData, unsigned long size, const std::string& controlFile);
|
||||
std::set<unsigned int>* parseBinaryConfigFile(unsigned char* pData, unsigned long size, const std::string& controlFile);
|
||||
void parseCharacterDefinition(std::string line, BMFontDef *characterDefinition);
|
||||
void parseInfoArguments(std::string line);
|
||||
void parseCommonArguments(std::string line);
|
||||
|
@ -274,7 +274,7 @@ std::set<unsigned int>* BMFontConfiguration::parseConfigFile(const std::string&
|
|||
{
|
||||
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(controlFile);
|
||||
|
||||
Data data = FileUtils::getInstance()->getDataFromFile(fullpath);
|
||||
Data data = FileUtils::getInstance()->getDataFromFile(fullpath);
|
||||
CCASSERT((!data.isNull() && data.getSize() > 0), "BMFontConfiguration::parseConfigFile | Open file error.");
|
||||
|
||||
if (memcmp("BMF", data.getBytes(), 3) == 0) {
|
||||
|
@ -369,28 +369,28 @@ std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char
|
|||
pData += 4; remains -= 4;
|
||||
|
||||
while (remains > 0)
|
||||
{
|
||||
{
|
||||
unsigned char blockId = pData[0]; pData += 1; remains -= 1;
|
||||
uint32_t blockSize = 0; memcpy(&blockSize, pData, 4);
|
||||
|
||||
pData += 4; remains -= 4;
|
||||
|
||||
if (blockId == 1)
|
||||
{
|
||||
{
|
||||
/*
|
||||
fontSize 2 int 0
|
||||
bitField 1 bits 2 bit 0: smooth, bit 1: unicode, bit 2: italic, bit 3: bold, bit 4: fixedHeigth, bits 5-7: reserved
|
||||
charSet 1 uint 3
|
||||
stretchH 2 uint 4
|
||||
aa 1 uint 6
|
||||
paddingUp 1 uint 7
|
||||
paddingRight 1 uint 8
|
||||
paddingDown 1 uint 9
|
||||
paddingLeft 1 uint 10
|
||||
spacingHoriz 1 uint 11
|
||||
spacingVert 1 uint 12
|
||||
outline 1 uint 13 added with version 2
|
||||
fontName n+1 string 14 null terminated string with length n
|
||||
fontSize 2 int 0
|
||||
bitField 1 bits 2 bit 0: smooth, bit 1: unicode, bit 2: italic, bit 3: bold, bit 4: fixedHeigth, bits 5-7: reserved
|
||||
charSet 1 uint 3
|
||||
stretchH 2 uint 4
|
||||
aa 1 uint 6
|
||||
paddingUp 1 uint 7
|
||||
paddingRight 1 uint 8
|
||||
paddingDown 1 uint 9
|
||||
paddingLeft 1 uint 10
|
||||
spacingHoriz 1 uint 11
|
||||
spacingVert 1 uint 12
|
||||
outline 1 uint 13 added with version 2
|
||||
fontName n+1 string 14 null terminated string with length n
|
||||
*/
|
||||
|
||||
_padding.top = (unsigned char)pData[7];
|
||||
|
@ -401,16 +401,16 @@ std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char
|
|||
else if (blockId == 2)
|
||||
{
|
||||
/*
|
||||
lineHeight 2 uint 0
|
||||
base 2 uint 2
|
||||
scaleW 2 uint 4
|
||||
scaleH 2 uint 6
|
||||
pages 2 uint 8
|
||||
bitField 1 bits 10 bits 0-6: reserved, bit 7: packed
|
||||
alphaChnl 1 uint 11
|
||||
redChnl 1 uint 12
|
||||
greenChnl 1 uint 13
|
||||
blueChnl 1 uint 14
|
||||
lineHeight 2 uint 0
|
||||
base 2 uint 2
|
||||
scaleW 2 uint 4
|
||||
scaleH 2 uint 6
|
||||
pages 2 uint 8
|
||||
bitField 1 bits 10 bits 0-6: reserved, bit 7: packed
|
||||
alphaChnl 1 uint 11
|
||||
redChnl 1 uint 12
|
||||
greenChnl 1 uint 13
|
||||
blueChnl 1 uint 14
|
||||
*/
|
||||
|
||||
uint16_t lineHeight = 0; memcpy(&lineHeight, pData, 2);
|
||||
|
@ -424,8 +424,8 @@ std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char
|
|||
uint16_t pages = 0; memcpy(&pages, pData + 8, 2);
|
||||
CCASSERT(pages == 1, "CCBitfontAtlas: only supports 1 page");
|
||||
}
|
||||
else if (blockId == 3)
|
||||
{
|
||||
else if (blockId == 3)
|
||||
{
|
||||
/*
|
||||
pageNames p*(n+1) strings 0 p null terminated strings, each with length n
|
||||
*/
|
||||
|
@ -438,22 +438,22 @@ std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char
|
|||
else if (blockId == 4)
|
||||
{
|
||||
/*
|
||||
id 4 uint 0+c*20 These fields are repeated until all characters have been described
|
||||
x 2 uint 4+c*20
|
||||
y 2 uint 6+c*20
|
||||
width 2 uint 8+c*20
|
||||
height 2 uint 10+c*20
|
||||
xoffset 2 int 12+c*20
|
||||
yoffset 2 int 14+c*20
|
||||
xadvance 2 int 16+c*20
|
||||
page 1 uint 18+c*20
|
||||
chnl 1 uint 19+c*20
|
||||
id 4 uint 0+c*20 These fields are repeated until all characters have been described
|
||||
x 2 uint 4+c*20
|
||||
y 2 uint 6+c*20
|
||||
width 2 uint 8+c*20
|
||||
height 2 uint 10+c*20
|
||||
xoffset 2 int 12+c*20
|
||||
yoffset 2 int 14+c*20
|
||||
xadvance 2 int 16+c*20
|
||||
page 1 uint 18+c*20
|
||||
chnl 1 uint 19+c*20
|
||||
*/
|
||||
|
||||
unsigned long count = blockSize / 20;
|
||||
|
||||
for (unsigned long i = 0; i < count; i++)
|
||||
{
|
||||
{
|
||||
tFontDefHashElement* element = (tFontDefHashElement*)malloc( sizeof(*element) );
|
||||
|
||||
uint32_t charId = 0; memcpy(&charId, pData + (i * 20), 4);
|
||||
|
@ -486,18 +486,17 @@ std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char
|
|||
validCharsString->insert(element->fontDef.charID);
|
||||
}
|
||||
}
|
||||
else if (blockId == 5) {
|
||||
else if (blockId == 5) {
|
||||
/*
|
||||
first 4 uint 0+c*10 These fields are repeated until all kerning pairs have been described
|
||||
second 4 uint 4+c*10
|
||||
amount 2 int 8+c*10
|
||||
first 4 uint 0+c*10 These fields are repeated until all kerning pairs have been described
|
||||
second 4 uint 4+c*10
|
||||
amount 2 int 8+c*10
|
||||
*/
|
||||
|
||||
unsigned long count = blockSize / 20;
|
||||
|
||||
for (unsigned long i = 0; i < count; i++)
|
||||
{
|
||||
|
||||
{
|
||||
uint32_t first = 0; memcpy(&first, pData + (i * 10), 4);
|
||||
uint32_t second = 0; memcpy(&second, pData + (i * 10) + 4, 4);
|
||||
int16_t amount = 0; memcpy(&amount, pData + (i * 10) + 8, 2);
|
||||
|
@ -693,12 +692,12 @@ FontFNT::FontFNT(BMFontConfiguration *theContfig, const Vec2& imageOffset /* = V
|
|||
:_configuration(theContfig)
|
||||
,_imageOffset(CC_POINT_PIXELS_TO_POINTS(imageOffset))
|
||||
{
|
||||
_configuration->retain();
|
||||
_configuration->retain();
|
||||
}
|
||||
|
||||
FontFNT::~FontFNT()
|
||||
{
|
||||
_configuration->release();
|
||||
_configuration->release();
|
||||
}
|
||||
|
||||
void FontFNT::purgeCachedData()
|
||||
|
|
|
@ -71,7 +71,7 @@ LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& cha
|
|||
bool LabelAtlas::initWithString(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
|
||||
{
|
||||
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(charMapFile);
|
||||
return initWithString(string, texture, itemWidth, itemHeight, startCharMap);
|
||||
return initWithString(string, texture, itemWidth, itemHeight, startCharMap);
|
||||
}
|
||||
|
||||
bool LabelAtlas::initWithString(const std::string& string, Texture2D* texture, int itemWidth, int itemHeight, int startCharMap)
|
||||
|
|
|
@ -680,7 +680,7 @@ LayerGradient* LayerGradient::create()
|
|||
|
||||
bool LayerGradient::init()
|
||||
{
|
||||
return initWithColor(Color4B(0, 0, 0, 255), Color4B(0, 0, 0, 255));
|
||||
return initWithColor(Color4B(0, 0, 0, 255), Color4B(0, 0, 0, 255));
|
||||
}
|
||||
|
||||
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end)
|
||||
|
|
|
@ -81,15 +81,15 @@ MenuItem* MenuItem::create( const ccMenuCallback& callback)
|
|||
// FIXME: deprecated
|
||||
bool MenuItem::initWithTarget(cocos2d::Ref *target, SEL_MenuHandler selector )
|
||||
{
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithCallback( std::bind(selector,target, std::placeholders::_1) );
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithCallback( std::bind(selector,target, std::placeholders::_1) );
|
||||
}
|
||||
|
||||
bool MenuItem::initWithCallback(const ccMenuCallback& callback)
|
||||
{
|
||||
setAnchorPoint(Vec2(0.5f, 0.5f));
|
||||
_callback = callback;
|
||||
_callback = callback;
|
||||
_enabled = true;
|
||||
_selected = false;
|
||||
return true;
|
||||
|
@ -101,8 +101,8 @@ MenuItem::~MenuItem()
|
|||
|
||||
void MenuItem::onExit()
|
||||
{
|
||||
Node::onExit();
|
||||
CC_SAFE_RELEASE(_target);
|
||||
Node::onExit();
|
||||
CC_SAFE_RELEASE(_target);
|
||||
}
|
||||
|
||||
void MenuItem::selected()
|
||||
|
@ -121,7 +121,7 @@ void MenuItem::activate()
|
|||
{
|
||||
if( _callback )
|
||||
{
|
||||
_callback(this);
|
||||
_callback(this);
|
||||
}
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (kScriptTypeNone != _scriptType)
|
||||
|
@ -159,14 +159,14 @@ bool MenuItem::isSelected() const
|
|||
// FIXME: deprecated
|
||||
void MenuItem::setTarget(Ref *target, SEL_MenuHandler selector)
|
||||
{
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
setCallback( std::bind( selector, target, std::placeholders::_1) );
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
setCallback( std::bind( selector, target, std::placeholders::_1) );
|
||||
}
|
||||
|
||||
void MenuItem::setCallback(const ccMenuCallback& callback)
|
||||
{
|
||||
_callback = callback;
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
std::string MenuItem::getDescription() const
|
||||
|
@ -223,9 +223,9 @@ MenuItemLabel* MenuItemLabel::create(Node *label)
|
|||
// FIXME:: deprecated
|
||||
bool MenuItemLabel::initWithLabel(Node* label, Ref* target, SEL_MenuHandler selector)
|
||||
{
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithLabel(label, std::bind(selector,target, std::placeholders::_1) );
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithLabel(label, std::bind(selector,target, std::placeholders::_1) );
|
||||
}
|
||||
|
||||
bool MenuItemLabel::initWithLabel(Node* label, const ccMenuCallback& callback)
|
||||
|
@ -345,9 +345,9 @@ MenuItemAtlasFont * MenuItemAtlasFont::create(const std::string& value, const st
|
|||
// FIXME:: deprecated
|
||||
bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, Ref* target, SEL_MenuHandler selector)
|
||||
{
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, std::bind(selector,target, std::placeholders::_1) );
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, std::bind(selector,target, std::placeholders::_1) );
|
||||
}
|
||||
|
||||
bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback)
|
||||
|
@ -431,9 +431,9 @@ bool MenuItemFont::initWithString(const std::string& value, Ref* target, SEL_Men
|
|||
{
|
||||
CCASSERT( !value.empty(), "Value length must be greater than 0");
|
||||
|
||||
_target = target;
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(target);
|
||||
return initWithString(value, std::bind(selector,target, std::placeholders::_1) );
|
||||
return initWithString(value, std::bind(selector,target, std::placeholders::_1) );
|
||||
}
|
||||
|
||||
bool MenuItemFont::initWithString(const std::string& value, const ccMenuCallback& callback)
|
||||
|
@ -580,9 +580,9 @@ MenuItemSprite * MenuItemSprite::create(Node *normalSprite, Node *selectedSprite
|
|||
// FIXME: deprecated
|
||||
bool MenuItemSprite::initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, Ref* target, SEL_MenuHandler selector)
|
||||
{
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, std::bind(selector,target, std::placeholders::_1) );
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, std::bind(selector,target, std::placeholders::_1) );
|
||||
}
|
||||
|
||||
bool MenuItemSprite::initWithNormalSprite(Node* normalSprite, Node* selectedSprite, Node* disabledSprite, const ccMenuCallback& callback)
|
||||
|
@ -760,9 +760,9 @@ MenuItemImage * MenuItemImage::create(const std::string& normalImage, const std:
|
|||
// FIXME:: deprecated
|
||||
bool MenuItemImage::initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, Ref* target, SEL_MenuHandler selector)
|
||||
{
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithNormalImage(normalImage, selectedImage, disabledImage, std::bind(selector,target, std::placeholders::_1) );
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithNormalImage(normalImage, selectedImage, disabledImage, std::bind(selector,target, std::placeholders::_1) );
|
||||
}
|
||||
bool MenuItemImage::initWithNormalImage(const std::string& normalImage, const std::string& selectedImage, const std::string& disabledImage, const ccMenuCallback& callback)
|
||||
{
|
||||
|
@ -877,9 +877,9 @@ MenuItemToggle * MenuItemToggle::create()
|
|||
// FIXME:: deprecated
|
||||
bool MenuItemToggle::initWithTarget(Ref* target, SEL_MenuHandler selector, MenuItem* item, va_list args)
|
||||
{
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithCallback(std::bind( selector, target, std::placeholders::_1), item, args);
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithCallback(std::bind( selector, target, std::placeholders::_1), item, args);
|
||||
}
|
||||
|
||||
bool MenuItemToggle::initWithCallback(const ccMenuCallback &callback, MenuItem *item, va_list args)
|
||||
|
|
|
@ -412,4 +412,3 @@ void MotionStreak::draw(Renderer *renderer, const Mat4 &transform, uint32_t flag
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ THE SOFTWARE.
|
|||
#define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__))
|
||||
#endif
|
||||
|
||||
extern int g_physicsSceneCount;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -125,6 +124,8 @@ Node::Node(void)
|
|||
, _physicsBody(nullptr)
|
||||
, _physicsScaleStartX(1.0f)
|
||||
, _physicsScaleStartY(1.0f)
|
||||
, _physicsRotation(0.0f)
|
||||
, _physicsTransformDirty(true)
|
||||
#endif
|
||||
, _displayedOpacity(255)
|
||||
, _realOpacity(255)
|
||||
|
@ -329,13 +330,6 @@ void Node::setRotation(float rotation)
|
|||
|
||||
_rotationZ_X = _rotationZ_Y = rotation;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (!_physicsBody || !_physicsBody->_rotationResetTag)
|
||||
{
|
||||
updatePhysicsBodyRotation(getScene());
|
||||
}
|
||||
#endif
|
||||
|
||||
updateRotationQuat();
|
||||
}
|
||||
|
@ -472,16 +466,6 @@ void Node::setScale(float scale)
|
|||
|
||||
_scaleX = _scaleY = _scaleZ = scale;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if(g_physicsSceneCount == 0)
|
||||
return;
|
||||
auto scene = getScene();
|
||||
if (!scene || scene->getPhysicsWorld())
|
||||
{
|
||||
updatePhysicsBodyTransform(scene);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// scaleX getter
|
||||
|
@ -499,17 +483,6 @@ void Node::setScale(float scaleX,float scaleY)
|
|||
_scaleX = scaleX;
|
||||
_scaleY = scaleY;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if(g_physicsSceneCount == 0)
|
||||
return;
|
||||
|
||||
auto scene = getScene();
|
||||
if (!scene || scene->getPhysicsWorld())
|
||||
{
|
||||
updatePhysicsBodyTransform(scene);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// scaleX setter
|
||||
|
@ -520,17 +493,6 @@ void Node::setScaleX(float scaleX)
|
|||
|
||||
_scaleX = scaleX;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if(g_physicsSceneCount == 0)
|
||||
return;
|
||||
|
||||
auto scene = getScene();
|
||||
if (!scene || scene->getPhysicsWorld())
|
||||
{
|
||||
updatePhysicsBodyTransform(scene);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// scaleY getter
|
||||
|
@ -570,17 +532,6 @@ void Node::setScaleY(float scaleY)
|
|||
|
||||
_scaleY = scaleY;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (g_physicsSceneCount == 0)
|
||||
return;
|
||||
|
||||
auto scene = getScene();
|
||||
if (!scene || scene->getPhysicsWorld())
|
||||
{
|
||||
updatePhysicsBodyTransform(scene);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -612,13 +563,6 @@ void Node::setPosition(float x, float y)
|
|||
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
_usingNormalizedPosition = false;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (!_physicsBody || !_physicsBody->_positionResetTag)
|
||||
{
|
||||
updatePhysicsBodyPosition(getScene());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Node::setPosition3D(const Vec3& position)
|
||||
|
@ -780,9 +724,9 @@ void Node::ignoreAnchorPointForPosition(bool newValue)
|
|||
{
|
||||
if (newValue != _ignoreAnchorPointForPosition)
|
||||
{
|
||||
_ignoreAnchorPointForPosition = newValue;
|
||||
_ignoreAnchorPointForPosition = newValue;
|
||||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// tag getter
|
||||
|
@ -1076,7 +1020,6 @@ void Node::addChildHelper(Node* child, int localZOrder, int tag, const std::stri
|
|||
auto scene = this->getScene();
|
||||
if (scene && scene->getPhysicsWorld())
|
||||
{
|
||||
child->updatePhysicsBodyTransform(scene);
|
||||
scene->addChildToPhysicsWorld(child);
|
||||
}
|
||||
#endif
|
||||
|
@ -1301,6 +1244,12 @@ void Node::visit()
|
|||
|
||||
uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody && _updateTransformFromPhysics)
|
||||
{
|
||||
updateTransformFromPhysics(parentTransform, parentFlags);
|
||||
}
|
||||
#endif
|
||||
if(_usingNormalizedPosition)
|
||||
{
|
||||
CCASSERT(_parent, "setNormalizedPosition() doesn't work with orphan nodes");
|
||||
|
@ -1756,8 +1705,8 @@ const Mat4& Node::getNodeToParentTransform() const
|
|||
|
||||
bool needsSkewMatrix = ( _skewX || _skewY );
|
||||
// Rotation values
|
||||
// Change rotation code to handle X and Y
|
||||
// If we skew with the exact same value for both x and y then we're simply just rotating
|
||||
// Change rotation code to handle X and Y
|
||||
// If we skew with the exact same value for both x and y then we're simply just rotating
|
||||
float cx = 1, sx = 0, cy = 1, sy = 0;
|
||||
if (_rotationZ_X != _rotationZ_Y || (! needsSkewMatrix && !_anchorPointInPoints.equals(Vec2::ZERO)))
|
||||
{
|
||||
|
@ -1880,7 +1829,7 @@ const Mat4& Node::getParentToNodeTransform() const
|
|||
{
|
||||
if ( _inverseDirty )
|
||||
{
|
||||
_inverse = _transform.getInversed();
|
||||
_inverse = getNodeToParentTransform().getInversed();
|
||||
_inverseDirty = false;
|
||||
}
|
||||
|
||||
|
@ -2023,87 +1972,6 @@ void Node::removeAllComponents()
|
|||
|
||||
// MARK: Physics
|
||||
|
||||
void Node::updatePhysicsBodyTransform(Scene* scene)
|
||||
{
|
||||
updatePhysicsBodyScale(scene);
|
||||
updatePhysicsBodyPosition(scene);
|
||||
updatePhysicsBodyRotation(scene);
|
||||
}
|
||||
|
||||
void Node::updatePhysicsBodyPosition(Scene* scene)
|
||||
{
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
if (scene && scene->getPhysicsWorld())
|
||||
{
|
||||
Vec2 pos = _parent == scene ? _position : scene->convertToNodeSpace(_parent->convertToWorldSpace(_position));
|
||||
_physicsBody->setPosition(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
_physicsBody->setPosition(_position);
|
||||
}
|
||||
}
|
||||
|
||||
for (Node* child : _children)
|
||||
{
|
||||
child->updatePhysicsBodyPosition(scene);
|
||||
}
|
||||
}
|
||||
|
||||
void Node::updatePhysicsBodyRotation(Scene* scene)
|
||||
{
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
if (scene != nullptr && scene->getPhysicsWorld() != nullptr)
|
||||
{
|
||||
float rotation = _rotationZ_X;
|
||||
for (Node* parent = _parent; parent != scene; parent = parent->_parent)
|
||||
{
|
||||
rotation += parent->getRotation();
|
||||
}
|
||||
_physicsBody->setRotation(rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
_physicsBody->setRotation(_rotationZ_X);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto child : _children)
|
||||
{
|
||||
child->updatePhysicsBodyRotation(scene);
|
||||
child->updatePhysicsBodyPosition(scene);
|
||||
}
|
||||
}
|
||||
|
||||
void Node::updatePhysicsBodyScale(Scene* scene)
|
||||
{
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
if (scene != nullptr && scene->getPhysicsWorld() != nullptr)
|
||||
{
|
||||
float scaleX = _scaleX / _physicsScaleStartX;
|
||||
float scaleY = _scaleY / _physicsScaleStartY;
|
||||
for (Node* parent = _parent; parent != scene; parent = parent->_parent)
|
||||
{
|
||||
scaleX *= parent->_scaleX;
|
||||
scaleY *= parent->_scaleY;
|
||||
}
|
||||
_physicsBody->setScale(scaleX, scaleY);
|
||||
}
|
||||
else
|
||||
{
|
||||
_physicsBody->setScale(_scaleX / _physicsScaleStartX, _scaleY / _physicsScaleStartY);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& child : _children)
|
||||
{
|
||||
child->updatePhysicsBodyScale(scene);
|
||||
}
|
||||
}
|
||||
|
||||
void Node::setPhysicsBody(PhysicsBody* body)
|
||||
{
|
||||
if (_physicsBody == body)
|
||||
|
@ -2111,9 +1979,17 @@ void Node::setPhysicsBody(PhysicsBody* body)
|
|||
return;
|
||||
}
|
||||
|
||||
if (body != nullptr)
|
||||
if (_physicsBody)
|
||||
{
|
||||
if (body->getNode() != nullptr)
|
||||
_physicsBody->removeFromWorld();
|
||||
_physicsBody->_node = nullptr;
|
||||
_physicsBody->release();
|
||||
_physicsBody = nullptr;
|
||||
}
|
||||
|
||||
if (body)
|
||||
{
|
||||
if (body->getNode())
|
||||
{
|
||||
body->getNode()->setPhysicsBody(nullptr);
|
||||
}
|
||||
|
@ -2128,64 +2004,77 @@ void Node::setPhysicsBody(PhysicsBody* body)
|
|||
CCLOG("Node warning: setPhysicsBody sets anchor point to Vec2::ANCHOR_MIDDLE.");
|
||||
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
PhysicsWorld* world = _physicsBody->getWorld();
|
||||
_physicsBody->removeFromWorld();
|
||||
_physicsBody->_node = nullptr;
|
||||
_physicsBody->release();
|
||||
|
||||
if (world != nullptr && body != nullptr)
|
||||
{
|
||||
world->addBody(body);
|
||||
}
|
||||
}
|
||||
|
||||
_physicsBody = body;
|
||||
_physicsScaleStartX = _scaleX;
|
||||
_physicsScaleStartY = _scaleY;
|
||||
|
||||
if (body != nullptr)
|
||||
{
|
||||
Node* node;
|
||||
Scene* scene = nullptr;
|
||||
for (node = this->getParent(); node != nullptr; node = node->getParent())
|
||||
{
|
||||
Scene* tmpScene = dynamic_cast<Scene*>(node);
|
||||
if (tmpScene != nullptr && tmpScene->getPhysicsWorld() != nullptr)
|
||||
{
|
||||
scene = tmpScene;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (scene != nullptr)
|
||||
|
||||
_physicsBody = body;
|
||||
_physicsScaleStartX = _scaleX;
|
||||
_physicsScaleStartY = _scaleY;
|
||||
|
||||
auto scene = getScene();
|
||||
if (scene && scene->getPhysicsWorld())
|
||||
{
|
||||
_physicsTransformDirty = true;
|
||||
scene->getPhysicsWorld()->addBody(body);
|
||||
}
|
||||
|
||||
updatePhysicsBodyTransform(scene);
|
||||
}
|
||||
}
|
||||
|
||||
PhysicsBody* Node::getPhysicsBody() const
|
||||
void Node::updatePhysicsBodyTransform(Scene* scene, const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY)
|
||||
{
|
||||
return _physicsBody;
|
||||
_updateTransformFromPhysics = false;
|
||||
auto flags = processParentFlags(parentTransform, parentFlags);
|
||||
_updateTransformFromPhysics = true;
|
||||
auto scaleX = parentScaleX * _scaleX;
|
||||
auto scaleY = parentScaleY * _scaleY;
|
||||
|
||||
if (_parent)
|
||||
{
|
||||
_physicsRotation = _parent->_physicsRotation + _rotationZ_X;
|
||||
}
|
||||
if (_physicsBody && ((flags & FLAGS_DIRTY_MASK) || _physicsTransformDirty))
|
||||
{
|
||||
_physicsTransformDirty = false;
|
||||
Vec3 vec3(_position.x, _position.y, 0);
|
||||
Vec3 ret;
|
||||
parentTransform.transformPoint(vec3, &ret);
|
||||
_physicsBody->setPosition(Vec2(ret.x, ret.y));
|
||||
_physicsBody->setScale(scaleX / _physicsScaleStartX, scaleY / _physicsScaleStartY);
|
||||
_physicsBody->setRotation(_physicsRotation);
|
||||
}
|
||||
|
||||
for (auto node : _children)
|
||||
{
|
||||
node->updatePhysicsBodyTransform(scene, _modelViewTransform, flags, scaleX, scaleY);
|
||||
}
|
||||
}
|
||||
|
||||
void Node::updateTransformFromPhysics(const Mat4& parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
auto& newPosition = _physicsBody->getPosition();
|
||||
auto& recordedPosition = _physicsBody->_recordedPosition;
|
||||
if (parentFlags || recordedPosition.x != newPosition.x || recordedPosition.y != newPosition.y)
|
||||
{
|
||||
recordedPosition = newPosition;
|
||||
Vec3 vec3(newPosition.x, newPosition.y, 0);
|
||||
Vec3 ret;
|
||||
parentTransform.getInversed().transformPoint(vec3, &ret);
|
||||
setPosition(ret.x, ret.y);
|
||||
}
|
||||
_physicsRotation = _physicsBody->getRotation();
|
||||
setRotation(_physicsRotation - _parent->_physicsRotation);
|
||||
}
|
||||
|
||||
#endif //CC_USE_PHYSICS
|
||||
|
||||
// MARK: Opacity and Color
|
||||
|
||||
GLubyte Node::getOpacity(void) const
|
||||
{
|
||||
return _realOpacity;
|
||||
return _realOpacity;
|
||||
}
|
||||
|
||||
GLubyte Node::getDisplayedOpacity() const
|
||||
{
|
||||
return _displayedOpacity;
|
||||
return _displayedOpacity;
|
||||
}
|
||||
|
||||
void Node::setOpacity(GLubyte opacity)
|
||||
|
@ -2197,7 +2086,7 @@ void Node::setOpacity(GLubyte opacity)
|
|||
|
||||
void Node::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||
{
|
||||
_displayedOpacity = _realOpacity * parentOpacity/255.0;
|
||||
_displayedOpacity = _realOpacity * parentOpacity/255.0;
|
||||
updateColor();
|
||||
|
||||
if (_cascadeOpacityEnabled)
|
||||
|
@ -2257,26 +2146,26 @@ void Node::disableCascadeOpacity()
|
|||
|
||||
const Color3B& Node::getColor(void) const
|
||||
{
|
||||
return _realColor;
|
||||
return _realColor;
|
||||
}
|
||||
|
||||
const Color3B& Node::getDisplayedColor() const
|
||||
{
|
||||
return _displayedColor;
|
||||
return _displayedColor;
|
||||
}
|
||||
|
||||
void Node::setColor(const Color3B& color)
|
||||
{
|
||||
_displayedColor = _realColor = color;
|
||||
|
||||
updateCascadeColor();
|
||||
_displayedColor = _realColor = color;
|
||||
|
||||
updateCascadeColor();
|
||||
}
|
||||
|
||||
void Node::updateDisplayedColor(const Color3B& parentColor)
|
||||
{
|
||||
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
||||
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
||||
_displayedColor.b = _realColor.b * parentColor.b/255.0;
|
||||
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
||||
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
||||
_displayedColor.b = _realColor.b * parentColor.b/255.0;
|
||||
updateColor();
|
||||
|
||||
if (_cascadeColorEnabled)
|
||||
|
@ -2314,7 +2203,7 @@ void Node::setCascadeColorEnabled(bool cascadeColorEnabled)
|
|||
|
||||
void Node::updateCascadeColor()
|
||||
{
|
||||
Color3B parentColor = Color3B::WHITE;
|
||||
Color3B parentColor = Color3B::WHITE;
|
||||
if (_parent && _parent->isCascadeColorEnabled())
|
||||
{
|
||||
parentColor = _parent->getDisplayedColor();
|
||||
|
|
|
@ -1533,13 +1533,16 @@ public:
|
|||
/**
|
||||
* get the PhysicsBody the sprite have
|
||||
*/
|
||||
PhysicsBody* getPhysicsBody() const;
|
||||
PhysicsBody* getPhysicsBody() const { return _physicsBody; }
|
||||
|
||||
/**
|
||||
* remove this node from physics world. it will remove all the physics bodies in it's children too.
|
||||
*/
|
||||
void removeFromPhysicsWorld();
|
||||
|
||||
void updateTransformFromPhysics(const Mat4& parentTransform, uint32_t parentFlags);
|
||||
|
||||
virtual void updatePhysicsBodyTransform(Scene* scene, const Mat4& parentTransform, uint32_t parentFlags, float parentScaleX, float parentScaleY);
|
||||
#endif
|
||||
|
||||
// overrides
|
||||
|
@ -1613,13 +1616,6 @@ protected:
|
|||
// update Rotation3D from quaternion
|
||||
void updateRotation3D();
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
void updatePhysicsBodyTransform(Scene* layer);
|
||||
virtual void updatePhysicsBodyPosition(Scene* layer);
|
||||
virtual void updatePhysicsBodyRotation(Scene* layer);
|
||||
virtual void updatePhysicsBodyScale(Scene* scene);
|
||||
#endif // CC_USE_PHYSICS
|
||||
|
||||
private:
|
||||
void addChildHelper(Node* child, int localZOrder, int tag, const std::string &name, bool setTag);
|
||||
|
||||
|
@ -1710,6 +1706,9 @@ protected:
|
|||
PhysicsBody* _physicsBody; ///< the physicsBody the node have
|
||||
float _physicsScaleStartX; ///< the scale x value when setPhysicsBody
|
||||
float _physicsScaleStartY; ///< the scale y value when setPhysicsBody
|
||||
float _physicsRotation;
|
||||
bool _physicsTransformDirty;
|
||||
bool _updateTransformFromPhysics;
|
||||
#endif
|
||||
|
||||
// opacity controls
|
||||
|
|
|
@ -1180,4 +1180,3 @@ void ParticleSystem::setScaleY(float newScaleY)
|
|||
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -523,8 +523,12 @@ void ParticleSystemQuad::setupVBO()
|
|||
|
||||
void ParticleSystemQuad::listenRendererRecreated(EventCustom* event)
|
||||
{
|
||||
//when comes to foreground in android, _buffersVBO and _VAOname is a wild handle
|
||||
//before recreating, we need to reset them to 0
|
||||
memset(_buffersVBO, 0, sizeof(_buffersVBO));
|
||||
if (Configuration::getInstance()->supportsShareableVAO())
|
||||
{
|
||||
_VAOname = 0;
|
||||
setupVBOandVAO();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -383,12 +383,12 @@ void RenderTexture::clearStencil(int stencilValue)
|
|||
void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
// override visit.
|
||||
// Don't call visit on its children
|
||||
// Don't call visit on its children
|
||||
if (!_visible || !isVisitableByVisitingCamera())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uint32_t flags = processParentFlags(parentTransform, parentFlags);
|
||||
|
||||
Director* director = Director::getInstance();
|
||||
|
|
|
@ -37,8 +37,6 @@ THE SOFTWARE.
|
|||
#include "physics/CCPhysicsWorld.h"
|
||||
#endif
|
||||
|
||||
int g_physicsSceneCount = 0;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
Scene::Scene()
|
||||
|
@ -60,10 +58,6 @@ Scene::Scene()
|
|||
Scene::~Scene()
|
||||
{
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsWorld)
|
||||
{
|
||||
g_physicsSceneCount--;
|
||||
}
|
||||
CC_SAFE_DELETE(_physicsWorld);
|
||||
#endif
|
||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_event);
|
||||
|
@ -132,6 +126,9 @@ void Scene::render(Renderer* renderer)
|
|||
const auto& transform = getNodeToParentTransform();
|
||||
for (const auto& camera : _cameras)
|
||||
{
|
||||
if (!camera->isVisible())
|
||||
continue;
|
||||
|
||||
Camera::_visitingCamera = camera;
|
||||
if (Camera::_visitingCamera->getCameraFlag() == CameraFlag::DEFAULT)
|
||||
{
|
||||
|
@ -177,15 +174,6 @@ void Scene::addChild(Node* child, int zOrder, const std::string &name)
|
|||
addChildToPhysicsWorld(child);
|
||||
}
|
||||
|
||||
void Scene::update(float delta)
|
||||
{
|
||||
Node::update(delta);
|
||||
if (nullptr != _physicsWorld && _physicsWorld->isAutoStep())
|
||||
{
|
||||
_physicsWorld->update(delta);
|
||||
}
|
||||
}
|
||||
|
||||
Scene* Scene::createWithPhysics()
|
||||
{
|
||||
Scene *ret = new (std::nothrow) Scene();
|
||||
|
@ -212,9 +200,7 @@ bool Scene::initWithPhysics()
|
|||
this->setContentSize(director->getWinSize());
|
||||
CC_BREAK_IF(! (_physicsWorld = PhysicsWorld::construct(*this)));
|
||||
|
||||
this->scheduleUpdate();
|
||||
// success
|
||||
g_physicsSceneCount += 1;
|
||||
ret = true;
|
||||
} while (0);
|
||||
return ret;
|
||||
|
|
|
@ -110,7 +110,6 @@ private:
|
|||
public:
|
||||
virtual void addChild(Node* child, int zOrder, int tag) override;
|
||||
virtual void addChild(Node* child, int zOrder, const std::string &name) override;
|
||||
virtual void update(float delta) override;
|
||||
inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; }
|
||||
static Scene *createWithPhysics();
|
||||
|
||||
|
|
|
@ -565,7 +565,7 @@ void Sprite::updateTransform(void)
|
|||
|
||||
// MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
|
||||
if (_textureAtlas)
|
||||
{
|
||||
{
|
||||
_textureAtlas->updateQuad(&_quad, _atlasIndex);
|
||||
}
|
||||
|
||||
|
@ -891,11 +891,11 @@ void Sprite::updateColor(void)
|
|||
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
|
||||
|
||||
// special opacity for premultiplied textures
|
||||
if (_opacityModifyRGB)
|
||||
if (_opacityModifyRGB)
|
||||
{
|
||||
color4.r *= _displayedOpacity/255.0f;
|
||||
color4.g *= _displayedOpacity/255.0f;
|
||||
color4.b *= _displayedOpacity/255.0f;
|
||||
color4.r *= _displayedOpacity/255.0f;
|
||||
color4.g *= _displayedOpacity/255.0f;
|
||||
color4.b *= _displayedOpacity/255.0f;
|
||||
}
|
||||
|
||||
_quad.bl.colors = color4;
|
||||
|
|
|
@ -367,8 +367,17 @@ void SpriteBatchNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t f
|
|||
return;
|
||||
}
|
||||
|
||||
for(const auto &child: _children)
|
||||
for (const auto &child : _children)
|
||||
{
|
||||
#if CC_USE_PHYSICS
|
||||
auto physicsBody = child->getPhysicsBody();
|
||||
if (physicsBody)
|
||||
{
|
||||
child->updateTransformFromPhysics(transform, flags);
|
||||
}
|
||||
#endif
|
||||
child->updateTransform();
|
||||
}
|
||||
|
||||
//Render as 3D object
|
||||
if (flags & FLAGS_RENDER_AS_3D)
|
||||
|
@ -659,22 +668,22 @@ void SpriteBatchNode::updateQuadFromSprite(Sprite *sprite, ssize_t index)
|
|||
CCASSERT(sprite != nullptr, "Argument must be non-nil");
|
||||
CCASSERT(dynamic_cast<Sprite*>(sprite) != nullptr, "CCSpriteBatchNode only supports Sprites as children");
|
||||
|
||||
// make needed room
|
||||
while (index >= _textureAtlas->getCapacity() || _textureAtlas->getCapacity() == _textureAtlas->getTotalQuads())
|
||||
// make needed room
|
||||
while (index >= _textureAtlas->getCapacity() || _textureAtlas->getCapacity() == _textureAtlas->getTotalQuads())
|
||||
{
|
||||
this->increaseAtlasCapacity();
|
||||
this->increaseAtlasCapacity();
|
||||
}
|
||||
|
||||
//
|
||||
// update the quad directly. Don't add the sprite to the scene graph
|
||||
//
|
||||
sprite->setBatchNode(this);
|
||||
//
|
||||
// update the quad directly. Don't add the sprite to the scene graph
|
||||
//
|
||||
sprite->setBatchNode(this);
|
||||
sprite->setAtlasIndex(index);
|
||||
|
||||
sprite->setDirty(true);
|
||||
|
||||
// UpdateTransform updates the textureAtlas quad
|
||||
sprite->updateTransform();
|
||||
sprite->setDirty(true);
|
||||
|
||||
// UpdateTransform updates the textureAtlas quad
|
||||
sprite->updateTransform();
|
||||
}
|
||||
|
||||
SpriteBatchNode * SpriteBatchNode::addSpriteWithoutQuad(Sprite*child, int z, int aTag)
|
||||
|
|
|
@ -196,4 +196,3 @@ Texture2D* SpriteFrame::getTexture()
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -428,4 +428,3 @@ SpriteFrame* SpriteFrameCache::getSpriteFrameByName(const std::string& name)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -288,13 +288,13 @@ Sprite* TMXLayer::reusedTileWithRect(Rect rect)
|
|||
else
|
||||
{
|
||||
// FIXME: HACK: Needed because if "batch node" is nil,
|
||||
// then the Sprite'squad will be reset
|
||||
// then the Sprite'squad will be reset
|
||||
_reusedTile->setBatchNode(nullptr);
|
||||
|
||||
// Re-init the sprite
|
||||
// Re-init the sprite
|
||||
_reusedTile->setTextureRect(rect, false, rect.size);
|
||||
|
||||
// restore the batch node
|
||||
// restore the batch node
|
||||
_reusedTile->setBatchNode(this);
|
||||
}
|
||||
|
||||
|
@ -732,4 +732,3 @@ std::string TMXLayer::getDescription() const
|
|||
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -263,4 +263,3 @@ std::string TMXTiledMap::getDescription() const
|
|||
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -712,4 +712,3 @@ void TMXMapInfo::textHandler(void *ctx, const char *ch, int len)
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -341,4 +341,3 @@ ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(Rende
|
|||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -408,11 +408,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
|
|||
<ClCompile Include="..\physics\CCPhysicsJoint.cpp" />
|
||||
<ClCompile Include="..\physics\CCPhysicsShape.cpp" />
|
||||
<ClCompile Include="..\physics\CCPhysicsWorld.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="..\platform\CCFileUtils.cpp" />
|
||||
<ClCompile Include="..\platform\CCGLView.cpp" />
|
||||
<ClCompile Include="..\platform\CCImage.cpp" />
|
||||
|
@ -820,15 +815,10 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.*
|
|||
<ClInclude Include="..\network\WebSocket.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsBody.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsContact.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsHelper.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsJoint.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsShape.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsWorld.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsHelper_chipmunk.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.h" />
|
||||
<ClInclude Include="..\platform\CCApplicationProtocol.h" />
|
||||
<ClInclude Include="..\platform\CCCommon.h" />
|
||||
<ClInclude Include="..\platform\CCDevice.h" />
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
<Filter Include="physics">
|
||||
<UniqueIdentifier>{08593631-5bf5-46aa-9436-62595c4f7bf6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="physics\chipmunk">
|
||||
<UniqueIdentifier>{aeadfa95-9c89-4212-98ae-89ad57db596a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="deprecated">
|
||||
<UniqueIdentifier>{0b1152b1-c732-4560-8629-87843b0fbd7c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
|
@ -264,21 +261,6 @@
|
|||
<ClCompile Include="..\physics\CCPhysicsWorld.cpp">
|
||||
<Filter>physics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\external\xxhash\xxhash.c">
|
||||
<Filter>external\xxhash</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1338,24 +1320,6 @@
|
|||
<ClInclude Include="..\physics\CCPhysicsWorld.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsHelper_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\external\xxhash\xxhash.h">
|
||||
<Filter>external\xxhash</Filter>
|
||||
</ClInclude>
|
||||
|
@ -2581,6 +2545,9 @@
|
|||
</ClInclude>
|
||||
<ClInclude Include="..\3d\CCFrustum.h" />
|
||||
<ClInclude Include="..\3d\CCPlane.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsHelper.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\math\Mat4.inl">
|
||||
|
|
|
@ -287,15 +287,10 @@
|
|||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\network\WebSocket.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsBody.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsContact.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsHelper.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsJoint.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsShape.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsWorld.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsHelper_chipmunk.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\CCApplication.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\CCApplicationProtocol.h" />
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\CCCommon.h" />
|
||||
|
@ -697,11 +692,6 @@
|
|||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsJoint.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsShape.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsWorld.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\CCFileUtils.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\CCGLView.cpp" />
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\CCImage.cpp" />
|
||||
|
|
|
@ -195,24 +195,6 @@
|
|||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\tinyxml2\tinyxml2.h">
|
||||
<Filter>external\tinyxml2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsHelper_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsBody.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
|
@ -1306,6 +1288,9 @@
|
|||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\allocator\CCAllocatorStrategyPool.h">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsHelper.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\cocos2d.cpp" />
|
||||
|
@ -1474,21 +1459,6 @@
|
|||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\..\external\tinyxml2\tinyxml2.cpp">
|
||||
<Filter>external\tinyxml2</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\physics\CCPhysicsBody.cpp">
|
||||
<Filter>physics</Filter>
|
||||
</ClCompile>
|
||||
|
@ -2479,9 +2449,6 @@
|
|||
<Filter Include="external\xxhash">
|
||||
<UniqueIdentifier>{9a5d5bc4-80f9-42aa-8865-c79711dfa7d6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="physics\chipmunk">
|
||||
<UniqueIdentifier>{97dd34cb-0d69-4ecd-bbf6-976cdf236d60}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="cocostudio\action">
|
||||
<UniqueIdentifier>{7345e280-b8a5-4d89-a27c-60cf351952d2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
|
|
|
@ -435,15 +435,10 @@
|
|||
<ClInclude Include="..\network\WebSocket.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsBody.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsContact.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsHelper.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsJoint.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsShape.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsWorld.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsHelper_chipmunk.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.h" />
|
||||
<ClInclude Include="..\platform\CCApplication.h" />
|
||||
<ClInclude Include="..\platform\CCApplicationProtocol.h" />
|
||||
<ClInclude Include="..\platform\CCCommon.h" />
|
||||
|
@ -918,11 +913,6 @@
|
|||
<ClCompile Include="..\physics\CCPhysicsJoint.cpp" />
|
||||
<ClCompile Include="..\physics\CCPhysicsShape.cpp" />
|
||||
<ClCompile Include="..\physics\CCPhysicsWorld.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.cpp" />
|
||||
<ClCompile Include="..\platform\CCFileUtils.cpp" />
|
||||
<ClCompile Include="..\platform\CCGLView.cpp" />
|
||||
<ClCompile Include="..\platform\CCImage.cpp" />
|
||||
|
|
|
@ -41,9 +41,6 @@
|
|||
<Filter Include="physics">
|
||||
<UniqueIdentifier>{a7501f5e-4fef-4f37-a646-ffe633008d9b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="physics\chipmunk">
|
||||
<UniqueIdentifier>{12ce37e2-709d-416e-a592-1c60b33fd6ce}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="platform">
|
||||
<UniqueIdentifier>{1850cae0-9e70-47af-87d5-c90f8343c06a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
|
@ -721,21 +718,6 @@
|
|||
<ClCompile Include="..\physics\CCPhysicsWorld.cpp">
|
||||
<Filter>physics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\platform\CCFileUtils.cpp">
|
||||
<Filter>platform</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1871,24 +1853,6 @@
|
|||
<ClInclude Include="..\physics\CCPhysicsWorld.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsBodyInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsContactInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsHelper_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsJointInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsShapeInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsWorldInfo_chipmunk.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\platform\CCApplication.h">
|
||||
<Filter>platform</Filter>
|
||||
</ClInclude>
|
||||
|
@ -2631,6 +2595,9 @@
|
|||
<ClInclude Include="..\base\allocator\CCAllocatorStrategyPool.h">
|
||||
<Filter>base\allocator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\CCPhysicsHelper.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\math\Mat4.inl">
|
||||
|
|
|
@ -1227,6 +1227,10 @@ bool Bundle3D::loadSkinDataBinary(SkinData* skindata)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Fix bug: check if the bone number is 0.
|
||||
if (boneNum == 0)
|
||||
return false;
|
||||
|
||||
// bone names and bind pos
|
||||
float bindpos[16];
|
||||
for (unsigned int i = 0; i < boneNum; i++)
|
||||
|
|
|
@ -179,11 +179,6 @@ physics/CCPhysicsContact.cpp \
|
|||
physics/CCPhysicsJoint.cpp \
|
||||
physics/CCPhysicsShape.cpp \
|
||||
physics/CCPhysicsWorld.cpp \
|
||||
physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp \
|
||||
physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp \
|
||||
physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp \
|
||||
physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp \
|
||||
physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp \
|
||||
../external/ConvertUTF/ConvertUTFWrapper.cpp \
|
||||
../external/ConvertUTF/ConvertUTF.c \
|
||||
../external/tinyxml2/tinyxml2.cpp \
|
||||
|
|
|
@ -65,6 +65,10 @@ THE SOFTWARE.
|
|||
#include "CCScriptSupport.h"
|
||||
#endif
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
#include "physics/CCPhysicsWorld.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
Position of the FPS
|
||||
|
||||
|
@ -259,12 +263,6 @@ void Director::drawScene()
|
|||
// calculate "global" dt
|
||||
calculateDeltaTime();
|
||||
|
||||
// skip one flame when _deltaTime equal to zero.
|
||||
if(_deltaTime < FLT_EPSILON)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_openGLView)
|
||||
{
|
||||
_openGLView->pollEvents();
|
||||
|
@ -291,6 +289,13 @@ void Director::drawScene()
|
|||
|
||||
if (_runningScene)
|
||||
{
|
||||
#if CC_USE_PHYSICS
|
||||
auto physicsWorld = _runningScene->getPhysicsWorld();
|
||||
if (physicsWorld && physicsWorld->isAutoStep())
|
||||
{
|
||||
physicsWorld->update(_deltaTime, false);
|
||||
}
|
||||
#endif
|
||||
//clear draw stats
|
||||
_renderer->clearDrawStats();
|
||||
|
||||
|
@ -990,7 +995,10 @@ void Director::reset()
|
|||
#pragma warning (push)
|
||||
#pragma warning (disable: 4996)
|
||||
#endif
|
||||
//it will crash clang static analyzer so hide it if __clang_analyzer__ defined
|
||||
#ifndef __clang_analyzer__
|
||||
DrawPrimitives::free();
|
||||
#endif
|
||||
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
||||
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
|
||||
#elif _MSC_VER >= 1400 //vs 2005 or higher
|
||||
|
|
|
@ -31,7 +31,7 @@ NS_CC_BEGIN
|
|||
|
||||
CC_DLL const char* cocos2dVersion()
|
||||
{
|
||||
return "cocos2d-x 3.4beta0";
|
||||
return "cocos2d-x 3.4";
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -87,7 +87,10 @@ void ccDrawInit()
|
|||
|
||||
void ccDrawFree()
|
||||
{
|
||||
//it will crash clang static analyzer so hide it if __clang_analyzer__ defined
|
||||
#ifndef __clang_analyzer__
|
||||
DrawPrimitives::free();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ccDrawPoint( const Vec2& point )
|
||||
|
|
|
@ -93,14 +93,14 @@ bool ActionTimeline::init()
|
|||
|
||||
void ActionTimeline::play(std::string name, bool loop)
|
||||
{
|
||||
if(_indexes.find(name) == _indexes.end())
|
||||
if (_animationInfos.find(name) == _animationInfos.end())
|
||||
{
|
||||
CCLOG("Cann't find action indexes for %s.", name.c_str());
|
||||
return;
|
||||
CCLOG("Can't find animation info for %s", name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
ActionIndexes& indexes = _indexes[name];
|
||||
gotoFrameAndPlay(indexes.startIndex, indexes.endIndex, loop);
|
||||
|
||||
AnimationInfo& index = _animationInfos[name];
|
||||
gotoFrameAndPlay(index.startIndex, index.endIndex, loop);
|
||||
}
|
||||
|
||||
void ActionTimeline::gotoFrameAndPlay(int startIndex)
|
||||
|
@ -278,26 +278,37 @@ void ActionTimeline::removeTimeline(Timeline* timeline)
|
|||
}
|
||||
}
|
||||
|
||||
void ActionTimeline::addIndexes(const ActionIndexes& indexes)
|
||||
|
||||
void ActionTimeline::addAnimationInfo(const AnimationInfo& animationInfo)
|
||||
{
|
||||
if(_indexes.find(indexes.name) != _indexes.end())
|
||||
if (_animationInfos.find(animationInfo.name) != _animationInfos.end())
|
||||
{
|
||||
CCLOG("ActionIndexes (%s) already exsists.", indexes.name.c_str());
|
||||
CCLOG("Animation (%s) already exists.", animationInfo.name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
_indexes[indexes.name] = indexes;
|
||||
|
||||
_animationInfos[animationInfo.name] = animationInfo;
|
||||
}
|
||||
|
||||
void ActionTimeline::removeIndexes(std::string name)
|
||||
void ActionTimeline::removeAnimationInfo(std::string animationName)
|
||||
{
|
||||
if(_indexes.find(name) == _indexes.end())
|
||||
if (_animationInfos.find(animationName) == _animationInfos.end())
|
||||
{
|
||||
CCLOG("ActionIndexes %s don't exsists.", name.c_str());
|
||||
CCLOG("AnimationInfo (%s) not exists.", animationName.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
_indexes.erase(name);
|
||||
|
||||
_animationInfos.erase(animationName);
|
||||
}
|
||||
|
||||
bool ActionTimeline::IsAnimationInfoExists(const std::string& animationName)
|
||||
{
|
||||
return _animationInfos.find(animationName) != _animationInfos.end();
|
||||
}
|
||||
|
||||
AnimationInfo ActionTimeline::getAnimationInfo(const std::string &animationName)
|
||||
{
|
||||
return _animationInfos.find(animationName)->second;
|
||||
}
|
||||
|
||||
void ActionTimeline::setFrameEventCallFunc(std::function<void(Frame *)> listener)
|
||||
|
@ -348,5 +359,4 @@ void ActionTimeline::stepToFrame(int frameIndex)
|
|||
_timelineList.at(i)->stepToFrame(frameIndex);
|
||||
}
|
||||
}
|
||||
|
||||
NS_TIMELINE_END
|
||||
|
|
|
@ -31,7 +31,7 @@ THE SOFTWARE.
|
|||
|
||||
NS_TIMELINE_BEGIN
|
||||
|
||||
struct ActionIndexes
|
||||
struct AnimationInfo
|
||||
{
|
||||
std::string name;
|
||||
int startIndex;
|
||||
|
@ -45,10 +45,10 @@ public:
|
|||
|
||||
virtual void setActionTag(int actionTag) { _actionTag = actionTag; }
|
||||
virtual int getActionTag() const { return _actionTag; }
|
||||
protected:
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
ActionTimelineData();
|
||||
virtual bool init(int actionTag);
|
||||
|
||||
protected:
|
||||
int _actionTag;
|
||||
};
|
||||
|
||||
|
@ -63,9 +63,9 @@ public:
|
|||
ActionTimeline();
|
||||
virtual ~ActionTimeline();
|
||||
|
||||
virtual void play(std::string animationName, bool loop);
|
||||
|
||||
virtual bool init();
|
||||
|
||||
virtual void play(std::string name, bool loop);
|
||||
|
||||
/** Goto the specified frame index, and start playing from this index.
|
||||
* @param startIndex The animation will play from this index.
|
||||
|
@ -97,7 +97,6 @@ public:
|
|||
* @param startIndex The animation will pause at this index.
|
||||
*/
|
||||
virtual void gotoFrameAndPause(int startIndex);
|
||||
|
||||
|
||||
/** Pause the animation. */
|
||||
virtual void pause();
|
||||
|
@ -132,12 +131,14 @@ public:
|
|||
/** add Timeline to ActionTimeline */
|
||||
virtual void addTimeline(Timeline* timeline);
|
||||
virtual void removeTimeline(Timeline* timeline);
|
||||
|
||||
/** add ActionIndexes */
|
||||
virtual void addIndexes(const ActionIndexes& indexes);
|
||||
virtual void removeIndexes(std::string name);
|
||||
|
||||
|
||||
virtual const cocos2d::Vector<Timeline*>& getTimelines() const { return _timelineList; }
|
||||
|
||||
/** AnimationInfo*/
|
||||
virtual void addAnimationInfo(const AnimationInfo& animationInfo);
|
||||
virtual void removeAnimationInfo(std::string animationName);
|
||||
virtual bool IsAnimationInfoExists(const std::string& animationName);
|
||||
virtual AnimationInfo getAnimationInfo(const std::string& animationName);
|
||||
|
||||
/** Set ActionTimeline's frame event callback function */
|
||||
void setFrameEventCallFunc(std::function<void(Frame *)> listener);
|
||||
|
@ -182,7 +183,7 @@ protected:
|
|||
|
||||
std::function<void(Frame*)> _frameEventListener;
|
||||
std::function<void()> _lastFrameListener;
|
||||
std::map<std::string, ActionIndexes> _indexes;
|
||||
std::map<std::string, AnimationInfo> _animationInfos;
|
||||
};
|
||||
|
||||
NS_TIMELINE_END
|
||||
|
|
|
@ -47,18 +47,16 @@ using namespace flatbuffers;
|
|||
namespace cocostudio {
|
||||
namespace timeline{
|
||||
|
||||
static const char* FrameType_VisibleFrame = "VisibleFrame";
|
||||
static const char* FrameType_PositionFrame = "PositionFrame";
|
||||
static const char* FrameType_ScaleFrame = "ScaleFrame";
|
||||
static const char* FrameType_RotationFrame = "RotationFrame";
|
||||
static const char* FrameType_SkewFrame = "SkewFrame";
|
||||
static const char* FrameType_RotationSkewFrame = "RotationSkewFrame";
|
||||
static const char* FrameType_AnchorFrame = "AnchorPointFrame";
|
||||
static const char* FrameType_InnerActionFrame = "InnerActionFrame";
|
||||
static const char* FrameType_ColorFrame = "ColorFrame";
|
||||
static const char* FrameType_TextureFrame = "TextureFrame";
|
||||
static const char* FrameType_EventFrame = "EventFrame";
|
||||
static const char* FrameType_ZOrderFrame = "ZOrderFrame";
|
||||
static const char* Property_VisibleForFrame = "VisibleForFrame";
|
||||
static const char* Property_Position = "Position";
|
||||
static const char* Property_Scale = "Scale";
|
||||
static const char* Property_RotationSkew = "RotationSkew";
|
||||
static const char* Property_CColor = "CColor";
|
||||
static const char* Property_FileData = "FileData";
|
||||
static const char* Property_FrameEvent = "FrameEvent";
|
||||
static const char* Property_Alpha = "Alpha";
|
||||
static const char* Property_ZOrder = "ZOrder";
|
||||
static const char* Property_ActionValue = "ActionValue";
|
||||
|
||||
static const char* ACTION = "action";
|
||||
static const char* DURATION = "duration";
|
||||
|
@ -108,6 +106,7 @@ void ActionTimelineCache::purge()
|
|||
void ActionTimelineCache::init()
|
||||
{
|
||||
using namespace std::placeholders;
|
||||
/*
|
||||
_funcs.insert(Pair(FrameType_VisibleFrame, std::bind(&ActionTimelineCache::loadVisibleFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_PositionFrame, std::bind(&ActionTimelineCache::loadPositionFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_ScaleFrame, std::bind(&ActionTimelineCache::loadScaleFrame, this, _1)));
|
||||
|
@ -120,6 +119,7 @@ void ActionTimelineCache::init()
|
|||
_funcs.insert(Pair(FrameType_TextureFrame, std::bind(&ActionTimelineCache::loadTextureFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_EventFrame, std::bind(&ActionTimelineCache::loadEventFrame, this, _1)));
|
||||
_funcs.insert(Pair(FrameType_ZOrderFrame, std::bind(&ActionTimelineCache::loadZOrderFrame, this, _1)));
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,18 @@ ActionTimeline* ActionTimelineCache::loadAnimationActionWithFlatBuffersFile(cons
|
|||
float speed = nodeAction->speed();
|
||||
action->setTimeSpeed(speed);
|
||||
|
||||
|
||||
auto animationlist = csparsebinary->animationList();
|
||||
int animationcount = animationlist->size();
|
||||
for (int i = 0; i < animationcount; i++)
|
||||
{
|
||||
auto animationdata = animationlist->Get(i);
|
||||
AnimationInfo info;
|
||||
info.name = animationdata->name()->c_str();
|
||||
info.startIndex = animationdata->startIndex();
|
||||
info.endIndex = animationdata->endIndex();
|
||||
action->addAnimationInfo(info);
|
||||
}
|
||||
|
||||
auto timelines = nodeAction->timeLines();
|
||||
int timelineLength = timelines->size();
|
||||
for (int i = 0; i < timelineLength; i++)
|
||||
|
@ -460,14 +471,14 @@ Timeline* ActionTimelineCache::loadTimelineWithFlatBuffers(const flatbuffers::Ti
|
|||
{
|
||||
Timeline* timeline = nullptr;
|
||||
|
||||
// get frame type
|
||||
std::string frameType = flatbuffers->frameType()->c_str();
|
||||
if(frameType == "")
|
||||
// property
|
||||
std::string property = flatbuffers->property()->c_str();
|
||||
if(property == "")
|
||||
return nullptr;
|
||||
|
||||
CCLOG("frameType = %s", frameType.c_str());
|
||||
CCLOG("property = %s", property.c_str());
|
||||
|
||||
if(frameType != "")
|
||||
if(property != "")
|
||||
{
|
||||
timeline = Timeline::create();
|
||||
|
||||
|
@ -482,68 +493,77 @@ Timeline* ActionTimelineCache::loadTimelineWithFlatBuffers(const flatbuffers::Ti
|
|||
auto frameFlatbuf = framesFlatbuf->Get(i);
|
||||
Frame* frame = nullptr;
|
||||
|
||||
if (frameType == FrameType_VisibleFrame)
|
||||
if (property == Property_VisibleForFrame)
|
||||
{
|
||||
auto visibleFrame = frameFlatbuf->visibleFrame();
|
||||
frame = loadVisibleFrameWithFlatBuffers(visibleFrame);
|
||||
auto boolFrame = frameFlatbuf->boolFrame();
|
||||
frame = loadVisibleFrameWithFlatBuffers(boolFrame);
|
||||
}
|
||||
else if (frameType == FrameType_ZOrderFrame)
|
||||
else if (property == Property_Position)
|
||||
{
|
||||
auto zOrderFrame = frameFlatbuf->zOrderFrame();
|
||||
frame = loadZOrderFrameWithFlatBuffers(zOrderFrame);
|
||||
}
|
||||
else if (frameType == FrameType_RotationSkewFrame)
|
||||
{
|
||||
auto rotationSkewFrame = frameFlatbuf->rotationSkewFrame();
|
||||
frame = loadRotationSkewFrameWithFlatBuffers(rotationSkewFrame);
|
||||
}
|
||||
else if (frameType == FrameType_EventFrame)
|
||||
{
|
||||
auto eventFrame = frameFlatbuf->eventFrame();
|
||||
frame = loadEventFrameWithFlatBuffers(eventFrame);
|
||||
}
|
||||
else if (frameType == FrameType_AnchorFrame)
|
||||
{
|
||||
auto anchorPointFrame = frameFlatbuf->anchorPointFrame();
|
||||
frame = loadAnchorPointFrameWithFlatBuffers(anchorPointFrame);
|
||||
}
|
||||
else if (frameType == FrameType_PositionFrame)
|
||||
{
|
||||
auto potisionFrame = frameFlatbuf->positionFrame();
|
||||
auto potisionFrame = frameFlatbuf->pointFrame();
|
||||
frame = loadPositionFrameWithFlatBuffers(potisionFrame);
|
||||
}
|
||||
else if (frameType == FrameType_ScaleFrame)
|
||||
else if (property == Property_Scale)
|
||||
{
|
||||
auto scaleFrame = frameFlatbuf->scaleFrame();
|
||||
frame = loadScaleFrameWithFlatBuffers(scaleFrame);
|
||||
}
|
||||
else if (frameType == FrameType_ColorFrame)
|
||||
else if (property == Property_RotationSkew)
|
||||
{
|
||||
auto scaleFrame = frameFlatbuf->scaleFrame();
|
||||
frame = loadRotationSkewFrameWithFlatBuffers(scaleFrame);
|
||||
}
|
||||
else if (property == Property_CColor)
|
||||
{
|
||||
auto colorFrame = frameFlatbuf->colorFrame();
|
||||
frame = loadColorFrameWithFlatBuffers(colorFrame);
|
||||
}
|
||||
else if (frameType == FrameType_TextureFrame)
|
||||
else if (property == Property_FrameEvent)
|
||||
{
|
||||
auto eventFrame = frameFlatbuf->eventFrame();
|
||||
frame = loadEventFrameWithFlatBuffers(eventFrame);
|
||||
}
|
||||
else if (property == Property_FileData)
|
||||
{
|
||||
auto textureFrame = frameFlatbuf->textureFrame();
|
||||
frame = loadTextureFrameWithFlatBuffers(textureFrame);
|
||||
}
|
||||
else if (property == Property_Alpha)
|
||||
{
|
||||
auto intFrame = frameFlatbuf->intFrame();
|
||||
frame = loadAlphaFrameWithFlatBuffers(intFrame);
|
||||
}
|
||||
else if (property == Property_ZOrder)
|
||||
{
|
||||
auto intFrame = frameFlatbuf->intFrame();
|
||||
frame = loadZOrderFrameWithFlatBuffers(intFrame);
|
||||
}
|
||||
else if (property == Property_ActionValue)
|
||||
{
|
||||
auto innerActionFrame = frameFlatbuf->innerActionFrame();
|
||||
frame = loadInnerActionFrameWithFlatBuffers(innerActionFrame);
|
||||
}
|
||||
|
||||
if (!frame)
|
||||
{
|
||||
CCLOG("frame is invalid.");
|
||||
continue;
|
||||
}
|
||||
timeline->addFrame(frame);
|
||||
}
|
||||
}
|
||||
|
||||
return timeline;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadVisibleFrameWithFlatBuffers(const flatbuffers::TimeLineBoolFrame *flatbuffers)
|
||||
|
||||
Frame* ActionTimelineCache::loadVisibleFrameWithFlatBuffers(const flatbuffers::BoolFrame *flatbuffers)
|
||||
{
|
||||
VisibleFrame* frame = VisibleFrame::create();
|
||||
|
||||
bool visible = flatbuffers->value();
|
||||
|
||||
frame->setVisible(visible);
|
||||
|
||||
CCLOG("visible = %d", visible);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
|
@ -552,81 +572,8 @@ Frame* ActionTimelineCache::loadVisibleFrameWithFlatBuffers(const flatbuffers::T
|
|||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadZOrderFrameWithFlatBuffers(const flatbuffers::TimeLineIntFrame *flatbuffers)
|
||||
{
|
||||
ZOrderFrame* frame = ZOrderFrame::create();
|
||||
|
||||
int zorder = flatbuffers->value();
|
||||
frame->setZOrder(zorder);
|
||||
|
||||
CCLOG("zorder = %d", zorder);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = flatbuffers->tween();
|
||||
frame->setTween(tween);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadRotationSkewFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers)
|
||||
{
|
||||
RotationSkewFrame* frame = RotationSkewFrame::create();
|
||||
|
||||
auto f_rotationSkew = flatbuffers->postion();
|
||||
Vec2 rotationSkew(f_rotationSkew->x(), f_rotationSkew->y());
|
||||
frame->setSkewX(rotationSkew.x);
|
||||
frame->setSkewY(rotationSkew.y);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = flatbuffers->tween();
|
||||
frame->setTween(tween);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadEventFrameWithFlatBuffers(const flatbuffers::TimeLineStringFrame *flatbuffers)
|
||||
{
|
||||
EventFrame* frame = EventFrame::create();
|
||||
|
||||
std::string event = flatbuffers->value()->c_str();
|
||||
|
||||
if (event != "")
|
||||
frame->setEvent(event);
|
||||
|
||||
CCLOG("event = %s", event.c_str());
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = flatbuffers->tween();
|
||||
frame->setTween(tween);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadAnchorPointFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers)
|
||||
{
|
||||
AnchorPointFrame* frame = AnchorPointFrame::create();
|
||||
|
||||
auto f_anchorPoint = flatbuffers->postion();
|
||||
Vec2 anchorPoint(f_anchorPoint->x(), f_anchorPoint->y());
|
||||
frame->setAnchorPoint(anchorPoint);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = flatbuffers->tween();
|
||||
frame->setTween(tween);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadPositionFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers)
|
||||
Frame* ActionTimelineCache::loadPositionFrameWithFlatBuffers(const flatbuffers::PointFrame *flatbuffers)
|
||||
{
|
||||
PositionFrame* frame = PositionFrame::create();
|
||||
|
||||
|
@ -643,12 +590,12 @@ Frame* ActionTimelineCache::loadPositionFrameWithFlatBuffers(const flatbuffers::
|
|||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadScaleFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers)
|
||||
Frame* ActionTimelineCache::loadScaleFrameWithFlatBuffers(const flatbuffers::ScaleFrame *flatbuffers)
|
||||
{
|
||||
ScaleFrame* frame = ScaleFrame::create();
|
||||
|
||||
auto f_scale = flatbuffers->postion();
|
||||
Vec2 scale(f_scale->x(), f_scale->y());
|
||||
auto f_scale = flatbuffers->scale();
|
||||
Vec2 scale(f_scale->scaleX(), f_scale->scaleY());
|
||||
frame->setScaleX(scale.x);
|
||||
frame->setScaleY(scale.y);
|
||||
|
||||
|
@ -661,16 +608,14 @@ Frame* ActionTimelineCache::loadScaleFrameWithFlatBuffers(const flatbuffers::Tim
|
|||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::TimeLineColorFrame *flatbuffers)
|
||||
Frame* ActionTimelineCache::loadRotationSkewFrameWithFlatBuffers(const flatbuffers::ScaleFrame *flatbuffers)
|
||||
{
|
||||
ColorFrame* frame = ColorFrame::create();
|
||||
RotationSkewFrame* frame = RotationSkewFrame::create();
|
||||
|
||||
auto f_color = flatbuffers->color();
|
||||
Color3B color(f_color->r(), f_color->g(), f_color->b());
|
||||
frame->setColor(color);
|
||||
|
||||
int alpha = f_color->a();
|
||||
frame->setAlpha(alpha);
|
||||
auto f_scale = flatbuffers->scale();
|
||||
Vec2 rotationSkew(f_scale->scaleX(), f_scale->scaleY());
|
||||
frame->setSkewX(rotationSkew.x);
|
||||
frame->setSkewY(rotationSkew.y);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
@ -681,7 +626,24 @@ Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::Tim
|
|||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::TimeLineTextureFrame *flatbuffers)
|
||||
Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::ColorFrame *flatbuffers)
|
||||
{
|
||||
ColorFrame* frame = ColorFrame::create();
|
||||
|
||||
auto f_color = flatbuffers->color();
|
||||
Color3B color(f_color->r(), f_color->g(), f_color->b());
|
||||
frame->setColor(color);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = flatbuffers->tween();
|
||||
frame->setTween(tween);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::TextureFrame *flatbuffers)
|
||||
{
|
||||
std::string path = "";
|
||||
int resourceType = 0;
|
||||
|
@ -689,7 +651,7 @@ Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::T
|
|||
|
||||
TextureFrame* frame = TextureFrame::create();
|
||||
|
||||
auto fileNameData = flatbuffers->fileNameData();
|
||||
auto fileNameData = flatbuffers->textureFile();
|
||||
|
||||
resourceType = fileNameData->resourceType();
|
||||
switch (resourceType)
|
||||
|
@ -727,7 +689,6 @@ Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::T
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
frame->setTextureName(path);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
|
@ -739,6 +700,85 @@ Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::T
|
|||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadEventFrameWithFlatBuffers(const flatbuffers::EventFrame *flatbuffers)
|
||||
{
|
||||
EventFrame* frame = EventFrame::create();
|
||||
|
||||
std::string event = flatbuffers->value()->c_str();
|
||||
|
||||
if (event != "")
|
||||
frame->setEvent(event);
|
||||
|
||||
CCLOG("event = %s", event.c_str());
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = flatbuffers->tween();
|
||||
frame->setTween(tween);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadAlphaFrameWithFlatBuffers(const flatbuffers::IntFrame *flatbuffers)
|
||||
{
|
||||
AlphaFrame* frame = AlphaFrame::create();
|
||||
|
||||
int alpha = flatbuffers->value();
|
||||
|
||||
frame->setAlpha(alpha);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = flatbuffers->tween();
|
||||
frame->setTween(tween);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadZOrderFrameWithFlatBuffers(const flatbuffers::IntFrame *flatbuffers)
|
||||
{
|
||||
ZOrderFrame* frame = ZOrderFrame::create();
|
||||
|
||||
int zorder = flatbuffers->value();
|
||||
|
||||
frame->setZOrder(zorder);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = flatbuffers->tween();
|
||||
frame->setTween(tween);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadInnerActionFrameWithFlatBuffers(const flatbuffers::InnerActionFrame *flatbuffers)
|
||||
{
|
||||
InnerActionFrame* frame = InnerActionFrame::create();
|
||||
|
||||
InnerActionType innerActionType = (InnerActionType)flatbuffers->innerActionType();
|
||||
|
||||
std::string currentAnimationFrame = flatbuffers->currentAniamtionName()->c_str();
|
||||
|
||||
int singleFrameIndex = flatbuffers->singleFrameIndex();
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = flatbuffers->tween();
|
||||
frame->setTween(tween);
|
||||
|
||||
frame->setInnerActionType(innerActionType);
|
||||
frame->setSingleFrameIndex(singleFrameIndex);
|
||||
|
||||
frame->setEnterWithName(true);
|
||||
frame->setAnimationName(currentAnimationFrame);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersForSimulator(const std::string& fileName)
|
||||
{
|
||||
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
||||
|
@ -758,6 +798,18 @@ ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersForSimulator(con
|
|||
float speed = nodeAction->speed();
|
||||
action->setTimeSpeed(speed);
|
||||
|
||||
auto animationlist = csparsebinary->animationList();
|
||||
int animationcount = animationlist->size();
|
||||
for (int i = 0; i < animationcount; i++)
|
||||
{
|
||||
auto animationdata = animationlist->Get(i);
|
||||
AnimationInfo info;
|
||||
info.name = animationdata->name()->c_str();
|
||||
info.startIndex = animationdata->startIndex();
|
||||
info.endIndex = animationdata->endIndex();
|
||||
action->addAnimationInfo(info);
|
||||
}
|
||||
|
||||
auto timeLines = nodeAction->timeLines();
|
||||
int timelineLength = timeLines->size();
|
||||
for (int i = 0; i < timelineLength; i++)
|
||||
|
|
|
@ -38,12 +38,14 @@ namespace flatbuffers
|
|||
|
||||
struct NodeAction;
|
||||
struct TimeLine;
|
||||
struct TimeLineBoolFrame;
|
||||
struct TimeLineIntFrame;
|
||||
struct TimeLineStringFrame;
|
||||
struct TimeLinePointFrame;
|
||||
struct TimeLineColorFrame;
|
||||
struct TimeLineTextureFrame;
|
||||
struct PointFrame;
|
||||
struct ScaleFrame;
|
||||
struct ColorFrame;
|
||||
struct TextureFrame;
|
||||
struct EventFrame;
|
||||
struct IntFrame;
|
||||
struct BoolFrame;
|
||||
struct InnerActionFrame;
|
||||
}
|
||||
|
||||
NS_TIMELINE_BEGIN
|
||||
|
@ -54,7 +56,8 @@ class Frame;
|
|||
|
||||
class CC_STUDIO_DLL ActionTimelineCache
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
/** Gets the singleton */
|
||||
static ActionTimelineCache* getInstance();
|
||||
|
||||
|
@ -100,16 +103,17 @@ protected:
|
|||
|
||||
|
||||
Timeline* loadTimelineWithFlatBuffers(const flatbuffers::TimeLine* flatbuffers);
|
||||
|
||||
Frame* loadVisibleFrameWithFlatBuffers (const flatbuffers::TimeLineBoolFrame* flatbuffers);
|
||||
Frame* loadZOrderFrameWithFlatBuffers (const flatbuffers::TimeLineIntFrame* flatbuffers);
|
||||
Frame* loadRotationSkewFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers);
|
||||
Frame* loadEventFrameWithFlatBuffers (const flatbuffers::TimeLineStringFrame* flatbuffers);
|
||||
Frame* loadAnchorPointFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers);
|
||||
Frame* loadPositionFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers);
|
||||
Frame* loadScaleFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers);
|
||||
Frame* loadColorFrameWithFlatBuffers (const flatbuffers::TimeLineColorFrame* flatbuffers);
|
||||
Frame* loadTextureFrameWithFlatBuffers (const flatbuffers::TimeLineTextureFrame* flatbuffers);
|
||||
|
||||
Frame* loadVisibleFrameWithFlatBuffers (const flatbuffers::BoolFrame* flatbuffers);
|
||||
Frame* loadPositionFrameWithFlatBuffers (const flatbuffers::PointFrame* flatbuffers);
|
||||
Frame* loadScaleFrameWithFlatBuffers (const flatbuffers::ScaleFrame* flatbuffers);
|
||||
Frame* loadRotationSkewFrameWithFlatBuffers (const flatbuffers::ScaleFrame* flatbuffers);
|
||||
Frame* loadColorFrameWithFlatBuffers (const flatbuffers::ColorFrame* flatbuffers);
|
||||
Frame* loadTextureFrameWithFlatBuffers (const flatbuffers::TextureFrame* flatbuffers);
|
||||
Frame* loadEventFrameWithFlatBuffers (const flatbuffers::EventFrame* flatbuffers);
|
||||
Frame* loadAlphaFrameWithFlatBuffers (const flatbuffers::IntFrame* flatbuffers);
|
||||
Frame* loadZOrderFrameWithFlatBuffers (const flatbuffers::IntFrame* flatbuffers);
|
||||
Frame* loadInnerActionFrameWithFlatBuffers (const flatbuffers::InnerActionFrame* flatbuffers);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ THE SOFTWARE.
|
|||
#include "CCActionTimeline.h"
|
||||
#include "2d/CCSpriteFrameCache.h"
|
||||
#include "2d/CCSpriteFrame.h"
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
|
@ -451,6 +453,8 @@ Frame* AnchorPointFrame::clone()
|
|||
|
||||
|
||||
// InnerActionFrame
|
||||
const std::string InnerActionFrame::AnimationAllName = "-- ALL --";
|
||||
|
||||
InnerActionFrame* InnerActionFrame::create()
|
||||
{
|
||||
InnerActionFrame* frame = new (std::nothrow) InnerActionFrame();
|
||||
|
@ -464,22 +468,103 @@ InnerActionFrame* InnerActionFrame::create()
|
|||
}
|
||||
|
||||
InnerActionFrame::InnerActionFrame()
|
||||
: _innerActionType(LoopAction)
|
||||
, _startFrameIndex(0)
|
||||
: _innerActionType(InnerActionType::SingleFrame)
|
||||
, _startFrameIndex(0)
|
||||
, _endFrameIndex(0)
|
||||
, _singleFrameIndex(0)
|
||||
, _enterWithName(false)
|
||||
, _animationName("")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
int start = _startFrameIndex;
|
||||
int end = _endFrameIndex;
|
||||
auto actiontimeline = static_cast<ActionTimeline*>(_node->getActionByTag(_node->getTag()));
|
||||
if (InnerActionType::SingleFrame == _innerActionType)
|
||||
{
|
||||
actiontimeline->gotoFrameAndPause(_singleFrameIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_enterWithName)
|
||||
{
|
||||
if (_animationName == AnimationAllName)
|
||||
{
|
||||
start = 0;
|
||||
end = actiontimeline->getDuration();
|
||||
}
|
||||
else if(actiontimeline->IsAnimationInfoExists(_animationName))
|
||||
{
|
||||
AnimationInfo info = actiontimeline->getAnimationInfo(_animationName);
|
||||
start = info.startIndex;
|
||||
end = info.endIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Animation %s not exists!", _animationName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (InnerActionType::NoLoopAction == _innerActionType)
|
||||
{
|
||||
actiontimeline->gotoFrameAndPlay(start, end, false);
|
||||
}
|
||||
else if (InnerActionType::LoopAction == _innerActionType)
|
||||
{
|
||||
actiontimeline->gotoFrameAndPlay(start, end, true);
|
||||
}
|
||||
}
|
||||
|
||||
void InnerActionFrame::setStartFrameIndex(int frameIndex) throw()
|
||||
{
|
||||
if(_enterWithName)
|
||||
{
|
||||
CCLOG(" cannot set start when enter frame with name. setEnterWithName false firstly!");
|
||||
throw std::exception();
|
||||
}
|
||||
_startFrameIndex = frameIndex;
|
||||
}
|
||||
|
||||
|
||||
void InnerActionFrame::setEndFrameIndex(int frameIndex) throw()
|
||||
{
|
||||
if(_enterWithName)
|
||||
{
|
||||
CCLOG(" cannot set end when enter frame with name. setEnterWithName false firstly!");
|
||||
throw std::exception();
|
||||
}
|
||||
_endFrameIndex = frameIndex;
|
||||
}
|
||||
|
||||
void InnerActionFrame::setAnimationName(const std::string& animationName) throw()
|
||||
{
|
||||
if(!_enterWithName)
|
||||
{
|
||||
CCLOG(" cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!");
|
||||
throw std::exception();
|
||||
}
|
||||
_animationName = animationName;
|
||||
|
||||
}
|
||||
|
||||
Frame* InnerActionFrame::clone()
|
||||
{
|
||||
InnerActionFrame* frame = InnerActionFrame::create();
|
||||
frame->setInnerActionType(_innerActionType);
|
||||
frame->setStartFrameIndex(_startFrameIndex);
|
||||
|
||||
frame->setSingleFrameIndex(_singleFrameIndex);
|
||||
if(_enterWithName)
|
||||
{
|
||||
frame->setEnterWithName(true);
|
||||
frame->setAnimationName(_animationName);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame->setStartFrameIndex(_startFrameIndex);
|
||||
frame->setEndFrameIndex(_endFrameIndex);
|
||||
}
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
|
@ -548,6 +633,51 @@ Frame* ColorFrame::clone()
|
|||
return frame;
|
||||
}
|
||||
|
||||
// AlphaFrame
|
||||
AlphaFrame* AlphaFrame::create()
|
||||
{
|
||||
AlphaFrame* frame = new (std::nothrow) AlphaFrame();
|
||||
if (frame)
|
||||
{
|
||||
frame->autorelease();
|
||||
return frame;
|
||||
}
|
||||
CC_SAFE_DELETE(frame);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AlphaFrame::AlphaFrame()
|
||||
: _alpha(255)
|
||||
{
|
||||
}
|
||||
|
||||
void AlphaFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
_node->setOpacity(_alpha);
|
||||
|
||||
if (_tween)
|
||||
{
|
||||
_betweenAlpha = static_cast<AlphaFrame*>(nextFrame)->_alpha - _alpha;
|
||||
}
|
||||
}
|
||||
|
||||
void AlphaFrame::apply(float percent)
|
||||
{
|
||||
if (_tween)
|
||||
{
|
||||
GLubyte alpha = _alpha + _betweenAlpha * percent;
|
||||
_node->setOpacity(alpha);
|
||||
}
|
||||
}
|
||||
|
||||
Frame* AlphaFrame::clone()
|
||||
{
|
||||
AlphaFrame* frame = AlphaFrame::create();
|
||||
frame->setAlpha(_alpha);
|
||||
frame->cloneProperty(this);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
// EventFrame
|
||||
EventFrame* EventFrame::create()
|
||||
|
|
|
@ -255,6 +255,8 @@ enum InnerActionType
|
|||
class CC_STUDIO_DLL InnerActionFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static const std::string AnimationAllName;
|
||||
|
||||
static InnerActionFrame* create();
|
||||
InnerActionFrame();
|
||||
|
||||
|
@ -263,13 +265,27 @@ public:
|
|||
|
||||
inline void setInnerActionType(InnerActionType type) { _innerActionType = type; }
|
||||
inline InnerActionType getInnerActionType() const { return _innerActionType; }
|
||||
|
||||
inline void setStartFrameIndex(int frameIndex) { _startFrameIndex = frameIndex; }
|
||||
|
||||
inline void setEnterWithName(bool isEnterWithName) { _enterWithName = isEnterWithName;}
|
||||
|
||||
void setStartFrameIndex(int frameIndex) throw();
|
||||
inline int getStartFrameIndex() const { return _startFrameIndex; }
|
||||
|
||||
void setEndFrameIndex(int frameIndex) throw();
|
||||
inline int getEndFrameIndex() const { return _endFrameIndex; }
|
||||
|
||||
void setAnimationName(const std::string& animationNamed) throw();
|
||||
|
||||
inline void setSingleFrameIndex(int frameIndex) { _singleFrameIndex = frameIndex;}
|
||||
inline int getSingleFrameIndex() const { return _singleFrameIndex;}
|
||||
|
||||
protected:
|
||||
InnerActionType _innerActionType;
|
||||
int _startFrameIndex;
|
||||
int _endFrameIndex;
|
||||
int _singleFrameIndex;
|
||||
std::string _animationName;
|
||||
bool _enterWithName;
|
||||
};
|
||||
|
||||
|
||||
|
@ -299,6 +315,23 @@ protected:
|
|||
int _betweenBlue;
|
||||
};
|
||||
|
||||
class CC_STUDIO_DLL AlphaFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static AlphaFrame* create();
|
||||
AlphaFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setAlpha(GLubyte alpha) { _alpha = alpha; }
|
||||
inline GLubyte getAlpha() const { return _alpha; }
|
||||
|
||||
protected:
|
||||
GLubyte _alpha;
|
||||
int _betweenAlpha;
|
||||
};
|
||||
|
||||
class CC_STUDIO_DLL EventFrame : public Frame
|
||||
{
|
||||
|
|
|
@ -145,11 +145,7 @@ void Timeline::binarySearchKeyFrame(int frameIndex)
|
|||
needEnterFrame = true;
|
||||
|
||||
_fromIndex = 0;
|
||||
|
||||
if(length > 1)
|
||||
_toIndex = 1;
|
||||
else
|
||||
_toIndex = 0;
|
||||
_toIndex = 0;
|
||||
|
||||
from = to = _frames.at(0);
|
||||
_currentKeyFrameIndex = 0;
|
||||
|
|
|
@ -181,7 +181,7 @@ CSLoader::CSLoader()
|
|||
, _jsonPath("")
|
||||
, _monoCocos2dxVersion("")
|
||||
, _rootNode(nullptr)
|
||||
, _csBuildID("2.0.8.0")
|
||||
, _csBuildID("2.1.0.0")
|
||||
{
|
||||
CREATE_CLASS_NODE_READER_INFO(NodeReader);
|
||||
CREATE_CLASS_NODE_READER_INFO(SingleNodeReader);
|
||||
|
@ -285,6 +285,7 @@ ActionTimeline* CSLoader::createTimeline(const std::string &filename)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
ActionTimelineNode* CSLoader::createActionTimelineNode(const std::string& filename)
|
||||
{
|
||||
Node* root = createNode(filename);
|
||||
|
@ -308,6 +309,7 @@ ActionTimelineNode* CSLoader::createActionTimelineNode(const std::string& filena
|
|||
|
||||
return node;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -833,29 +835,16 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree)
|
|||
CCLOG("filePath = %s", filePath.c_str());
|
||||
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
|
||||
{
|
||||
|
||||
Node* root = createNodeWithFlatBuffersFile(filePath);
|
||||
reader->setPropsWithFlatBuffers(root, options->data());
|
||||
|
||||
bool isloop = projectNodeOptions->isLoop();
|
||||
bool isautoplay = projectNodeOptions->isAutoPlay();
|
||||
|
||||
|
||||
node = createNodeWithFlatBuffersFile(filePath);
|
||||
reader->setPropsWithFlatBuffers(node, options->data());
|
||||
|
||||
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
|
||||
if (action)
|
||||
{
|
||||
root->runAction(action);
|
||||
if (isautoplay)
|
||||
{
|
||||
action->gotoFrameAndPlay(0, isloop);
|
||||
}
|
||||
else
|
||||
{
|
||||
action->gotoFrameAndPause(0);
|
||||
}
|
||||
node->runAction(action);
|
||||
}
|
||||
|
||||
node = ActionTimelineNode::create(root, action);
|
||||
node->setName(root->getName());
|
||||
|
||||
}
|
||||
}
|
||||
else if (classname == "SimpleAudio")
|
||||
|
@ -1182,22 +1171,11 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
|
|||
{
|
||||
node = createNodeWithFlatBuffersForSimulator(filePath);
|
||||
reader->setPropsWithFlatBuffers(node, options->data());
|
||||
|
||||
bool isloop = projectNodeOptions->isLoop();
|
||||
bool isautoplay = projectNodeOptions->isAutoPlay();
|
||||
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
|
||||
|
||||
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath);
|
||||
if (action)
|
||||
{
|
||||
node->runAction(action);
|
||||
action->gotoFrameAndPlay(0);
|
||||
if (isautoplay)
|
||||
{
|
||||
action->gotoFrameAndPlay(0, isloop);
|
||||
}
|
||||
else
|
||||
{
|
||||
action->gotoFrameAndPause(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,8 +77,10 @@ public:
|
|||
static cocos2d::Node* createNode(const std::string& filename);
|
||||
static cocostudio::timeline::ActionTimeline* createTimeline(const std::string& filename);
|
||||
|
||||
/*
|
||||
static cocostudio::timeline::ActionTimelineNode* createActionTimelineNode(const std::string& filename);
|
||||
static cocostudio::timeline::ActionTimelineNode* createActionTimelineNode(const std::string& filename, int startIndex, int endIndex, bool loop);
|
||||
*/
|
||||
|
||||
cocos2d::Node* createNodeFromJson(const std::string& filename);
|
||||
cocos2d::Node* loadNodeWithFile(const std::string& fileName);
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace cocostudio {
|
|||
class CC_STUDIO_DLL ComRender : public cocos2d::Component
|
||||
{
|
||||
DECLARE_CLASS_COMPONENT_INFO
|
||||
protected:
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,8 @@ if(WINDOWS AND BUILD_SHARED_LIBS)
|
|||
ADD_DEFINITIONS (-D_USRSTUDIODLL)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
|
||||
|
||||
set(COCOS_CS_SRC
|
||||
|
||||
editor-support/cocostudio/CCActionFrame.cpp
|
||||
|
|
|
@ -33,15 +33,18 @@ struct ListViewOptions;
|
|||
struct ProjectNodeOptions;
|
||||
struct ComponentOptions;
|
||||
struct ComAudioOptions;
|
||||
struct AnimationInfo;
|
||||
struct NodeAction;
|
||||
struct TimeLine;
|
||||
struct Frame;
|
||||
struct TimeLineBoolFrame;
|
||||
struct TimeLineIntFrame;
|
||||
struct TimeLineStringFrame;
|
||||
struct TimeLinePointFrame;
|
||||
struct TimeLineColorFrame;
|
||||
struct TimeLineTextureFrame;
|
||||
struct PointFrame;
|
||||
struct ScaleFrame;
|
||||
struct ColorFrame;
|
||||
struct TextureFrame;
|
||||
struct EventFrame;
|
||||
struct IntFrame;
|
||||
struct BoolFrame;
|
||||
struct InnerActionFrame;
|
||||
struct RotationSkew;
|
||||
struct Position;
|
||||
struct Scale;
|
||||
|
@ -177,7 +180,8 @@ struct CSParseBinary : private flatbuffers::Table {
|
|||
const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *texturePngs() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(6); }
|
||||
const NodeTree *nodeTree() const { return GetPointer<const NodeTree *>(8); }
|
||||
const NodeAction *action() const { return GetPointer<const NodeAction *>(10); }
|
||||
const flatbuffers::String *version() const { return GetPointer<const flatbuffers::String *>(12); }
|
||||
const flatbuffers::Vector<flatbuffers::Offset<AnimationInfo>> *animationList() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<AnimationInfo>> *>(12); }
|
||||
const flatbuffers::String *version() const { return GetPointer<const flatbuffers::String *>(14); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* textures */) &&
|
||||
|
@ -190,7 +194,10 @@ struct CSParseBinary : private flatbuffers::Table {
|
|||
verifier.VerifyTable(nodeTree()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* action */) &&
|
||||
verifier.VerifyTable(action()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* version */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* animationList */) &&
|
||||
verifier.Verify(animationList()) &&
|
||||
verifier.VerifyVectorOfTables(animationList()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 14 /* version */) &&
|
||||
verifier.Verify(version()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
|
@ -203,11 +210,12 @@ struct CSParseBinaryBuilder {
|
|||
void add_texturePngs(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> texturePngs) { fbb_.AddOffset(6, texturePngs); }
|
||||
void add_nodeTree(flatbuffers::Offset<NodeTree> nodeTree) { fbb_.AddOffset(8, nodeTree); }
|
||||
void add_action(flatbuffers::Offset<NodeAction> action) { fbb_.AddOffset(10, action); }
|
||||
void add_version(flatbuffers::Offset<flatbuffers::String> version) { fbb_.AddOffset(12, version); }
|
||||
void add_animationList(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<AnimationInfo>>> animationList) { fbb_.AddOffset(12, animationList); }
|
||||
void add_version(flatbuffers::Offset<flatbuffers::String> version) { fbb_.AddOffset(14, version); }
|
||||
CSParseBinaryBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
CSParseBinaryBuilder &operator=(const CSParseBinaryBuilder &);
|
||||
flatbuffers::Offset<CSParseBinary> Finish() {
|
||||
auto o = flatbuffers::Offset<CSParseBinary>(fbb_.EndTable(start_, 5));
|
||||
auto o = flatbuffers::Offset<CSParseBinary>(fbb_.EndTable(start_, 6));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
@ -217,9 +225,11 @@ inline flatbuffers::Offset<CSParseBinary> CreateCSParseBinary(flatbuffers::FlatB
|
|||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> texturePngs = 0,
|
||||
flatbuffers::Offset<NodeTree> nodeTree = 0,
|
||||
flatbuffers::Offset<NodeAction> action = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<AnimationInfo>>> animationList = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> version = 0) {
|
||||
CSParseBinaryBuilder builder_(_fbb);
|
||||
builder_.add_version(version);
|
||||
builder_.add_animationList(animationList);
|
||||
builder_.add_action(action);
|
||||
builder_.add_nodeTree(nodeTree);
|
||||
builder_.add_texturePngs(texturePngs);
|
||||
|
@ -1675,16 +1685,12 @@ inline flatbuffers::Offset<ListViewOptions> CreateListViewOptions(flatbuffers::F
|
|||
struct ProjectNodeOptions : private flatbuffers::Table {
|
||||
const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); }
|
||||
const flatbuffers::String *fileName() const { return GetPointer<const flatbuffers::String *>(6); }
|
||||
uint8_t isLoop() const { return GetField<uint8_t>(8, 1); }
|
||||
uint8_t isAutoPlay() const { return GetField<uint8_t>(10, 1); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
|
||||
verifier.VerifyTable(nodeOptions()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* fileName */) &&
|
||||
verifier.Verify(fileName()) &&
|
||||
VerifyField<uint8_t>(verifier, 8 /* isLoop */) &&
|
||||
VerifyField<uint8_t>(verifier, 10 /* isAutoPlay */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -1694,26 +1700,20 @@ struct ProjectNodeOptionsBuilder {
|
|||
flatbuffers::uoffset_t start_;
|
||||
void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); }
|
||||
void add_fileName(flatbuffers::Offset<flatbuffers::String> fileName) { fbb_.AddOffset(6, fileName); }
|
||||
void add_isLoop(uint8_t isLoop) { fbb_.AddElement<uint8_t>(8, isLoop, 1); }
|
||||
void add_isAutoPlay(uint8_t isAutoPlay) { fbb_.AddElement<uint8_t>(10, isAutoPlay, 1); }
|
||||
ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &);
|
||||
flatbuffers::Offset<ProjectNodeOptions> Finish() {
|
||||
auto o = flatbuffers::Offset<ProjectNodeOptions>(fbb_.EndTable(start_, 4));
|
||||
auto o = flatbuffers::Offset<ProjectNodeOptions>(fbb_.EndTable(start_, 2));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<ProjectNodeOptions> CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<WidgetOptions> nodeOptions = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> fileName = 0,
|
||||
uint8_t isLoop = 1,
|
||||
uint8_t isAutoPlay = 1) {
|
||||
flatbuffers::Offset<flatbuffers::String> fileName = 0) {
|
||||
ProjectNodeOptionsBuilder builder_(_fbb);
|
||||
builder_.add_fileName(fileName);
|
||||
builder_.add_nodeOptions(nodeOptions);
|
||||
builder_.add_isAutoPlay(isAutoPlay);
|
||||
builder_.add_isLoop(isLoop);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
|
@ -1814,10 +1814,50 @@ inline flatbuffers::Offset<ComAudioOptions> CreateComAudioOptions(flatbuffers::F
|
|||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct AnimationInfo : private flatbuffers::Table {
|
||||
const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(4); }
|
||||
int32_t startIndex() const { return GetField<int32_t>(6, 0); }
|
||||
int32_t endIndex() const { return GetField<int32_t>(8, 0); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* name */) &&
|
||||
verifier.Verify(name()) &&
|
||||
VerifyField<int32_t>(verifier, 6 /* startIndex */) &&
|
||||
VerifyField<int32_t>(verifier, 8 /* endIndex */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct AnimationInfoBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(4, name); }
|
||||
void add_startIndex(int32_t startIndex) { fbb_.AddElement<int32_t>(6, startIndex, 0); }
|
||||
void add_endIndex(int32_t endIndex) { fbb_.AddElement<int32_t>(8, endIndex, 0); }
|
||||
AnimationInfoBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
AnimationInfoBuilder &operator=(const AnimationInfoBuilder &);
|
||||
flatbuffers::Offset<AnimationInfo> Finish() {
|
||||
auto o = flatbuffers::Offset<AnimationInfo>(fbb_.EndTable(start_, 3));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<AnimationInfo> CreateAnimationInfo(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::String> name = 0,
|
||||
int32_t startIndex = 0,
|
||||
int32_t endIndex = 0) {
|
||||
AnimationInfoBuilder builder_(_fbb);
|
||||
builder_.add_endIndex(endIndex);
|
||||
builder_.add_startIndex(startIndex);
|
||||
builder_.add_name(name);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct NodeAction : private flatbuffers::Table {
|
||||
int32_t duration() const { return GetField<int32_t>(4, 0); }
|
||||
float speed() const { return GetField<float>(6, 0); }
|
||||
const flatbuffers::Vector<flatbuffers::Offset<TimeLine>> *timeLines() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<TimeLine>> *>(8); }
|
||||
const flatbuffers::String *currentAnimationName() const { return GetPointer<const flatbuffers::String *>(10); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* duration */) &&
|
||||
|
@ -1825,6 +1865,8 @@ struct NodeAction : private flatbuffers::Table {
|
|||
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* timeLines */) &&
|
||||
verifier.Verify(timeLines()) &&
|
||||
verifier.VerifyVectorOfTables(timeLines()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* currentAnimationName */) &&
|
||||
verifier.Verify(currentAnimationName()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -1835,10 +1877,11 @@ struct NodeActionBuilder {
|
|||
void add_duration(int32_t duration) { fbb_.AddElement<int32_t>(4, duration, 0); }
|
||||
void add_speed(float speed) { fbb_.AddElement<float>(6, speed, 0); }
|
||||
void add_timeLines(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<TimeLine>>> timeLines) { fbb_.AddOffset(8, timeLines); }
|
||||
void add_currentAnimationName(flatbuffers::Offset<flatbuffers::String> currentAnimationName) { fbb_.AddOffset(10, currentAnimationName); }
|
||||
NodeActionBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
NodeActionBuilder &operator=(const NodeActionBuilder &);
|
||||
flatbuffers::Offset<NodeAction> Finish() {
|
||||
auto o = flatbuffers::Offset<NodeAction>(fbb_.EndTable(start_, 3));
|
||||
auto o = flatbuffers::Offset<NodeAction>(fbb_.EndTable(start_, 4));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
@ -1846,8 +1889,10 @@ struct NodeActionBuilder {
|
|||
inline flatbuffers::Offset<NodeAction> CreateNodeAction(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t duration = 0,
|
||||
float speed = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<TimeLine>>> timeLines = 0) {
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<TimeLine>>> timeLines = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> currentAnimationName = 0) {
|
||||
NodeActionBuilder builder_(_fbb);
|
||||
builder_.add_currentAnimationName(currentAnimationName);
|
||||
builder_.add_timeLines(timeLines);
|
||||
builder_.add_speed(speed);
|
||||
builder_.add_duration(duration);
|
||||
|
@ -1855,13 +1900,13 @@ inline flatbuffers::Offset<NodeAction> CreateNodeAction(flatbuffers::FlatBufferB
|
|||
}
|
||||
|
||||
struct TimeLine : private flatbuffers::Table {
|
||||
const flatbuffers::String *frameType() const { return GetPointer<const flatbuffers::String *>(4); }
|
||||
const flatbuffers::String *property() const { return GetPointer<const flatbuffers::String *>(4); }
|
||||
int32_t actionTag() const { return GetField<int32_t>(6, 0); }
|
||||
const flatbuffers::Vector<flatbuffers::Offset<Frame>> *frames() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Frame>> *>(8); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* frameType */) &&
|
||||
verifier.Verify(frameType()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* property */) &&
|
||||
verifier.Verify(property()) &&
|
||||
VerifyField<int32_t>(verifier, 6 /* actionTag */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* frames */) &&
|
||||
verifier.Verify(frames()) &&
|
||||
|
@ -1873,7 +1918,7 @@ struct TimeLine : private flatbuffers::Table {
|
|||
struct TimeLineBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_frameType(flatbuffers::Offset<flatbuffers::String> frameType) { fbb_.AddOffset(4, frameType); }
|
||||
void add_property(flatbuffers::Offset<flatbuffers::String> property) { fbb_.AddOffset(4, property); }
|
||||
void add_actionTag(int32_t actionTag) { fbb_.AddElement<int32_t>(6, actionTag, 0); }
|
||||
void add_frames(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Frame>>> frames) { fbb_.AddOffset(8, frames); }
|
||||
TimeLineBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
|
@ -1885,46 +1930,43 @@ struct TimeLineBuilder {
|
|||
};
|
||||
|
||||
inline flatbuffers::Offset<TimeLine> CreateTimeLine(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::String> frameType = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> property = 0,
|
||||
int32_t actionTag = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Frame>>> frames = 0) {
|
||||
TimeLineBuilder builder_(_fbb);
|
||||
builder_.add_frames(frames);
|
||||
builder_.add_actionTag(actionTag);
|
||||
builder_.add_frameType(frameType);
|
||||
builder_.add_property(property);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Frame : private flatbuffers::Table {
|
||||
const TimeLineBoolFrame *visibleFrame() const { return GetPointer<const TimeLineBoolFrame *>(4); }
|
||||
const TimeLineIntFrame *zOrderFrame() const { return GetPointer<const TimeLineIntFrame *>(6); }
|
||||
const TimeLinePointFrame *rotationSkewFrame() const { return GetPointer<const TimeLinePointFrame *>(8); }
|
||||
const TimeLineStringFrame *eventFrame() const { return GetPointer<const TimeLineStringFrame *>(10); }
|
||||
const TimeLinePointFrame *anchorPointFrame() const { return GetPointer<const TimeLinePointFrame *>(12); }
|
||||
const TimeLinePointFrame *positionFrame() const { return GetPointer<const TimeLinePointFrame *>(14); }
|
||||
const TimeLinePointFrame *scaleFrame() const { return GetPointer<const TimeLinePointFrame *>(16); }
|
||||
const TimeLineColorFrame *colorFrame() const { return GetPointer<const TimeLineColorFrame *>(18); }
|
||||
const TimeLineTextureFrame *textureFrame() const { return GetPointer<const TimeLineTextureFrame *>(20); }
|
||||
const PointFrame *pointFrame() const { return GetPointer<const PointFrame *>(4); }
|
||||
const ScaleFrame *scaleFrame() const { return GetPointer<const ScaleFrame *>(6); }
|
||||
const ColorFrame *colorFrame() const { return GetPointer<const ColorFrame *>(8); }
|
||||
const TextureFrame *textureFrame() const { return GetPointer<const TextureFrame *>(10); }
|
||||
const EventFrame *eventFrame() const { return GetPointer<const EventFrame *>(12); }
|
||||
const IntFrame *intFrame() const { return GetPointer<const IntFrame *>(14); }
|
||||
const BoolFrame *boolFrame() const { return GetPointer<const BoolFrame *>(16); }
|
||||
const InnerActionFrame *innerActionFrame() const { return GetPointer<const InnerActionFrame *>(18); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* visibleFrame */) &&
|
||||
verifier.VerifyTable(visibleFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* zOrderFrame */) &&
|
||||
verifier.VerifyTable(zOrderFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* rotationSkewFrame */) &&
|
||||
verifier.VerifyTable(rotationSkewFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* eventFrame */) &&
|
||||
verifier.VerifyTable(eventFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* anchorPointFrame */) &&
|
||||
verifier.VerifyTable(anchorPointFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 14 /* positionFrame */) &&
|
||||
verifier.VerifyTable(positionFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 16 /* scaleFrame */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* pointFrame */) &&
|
||||
verifier.VerifyTable(pointFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* scaleFrame */) &&
|
||||
verifier.VerifyTable(scaleFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 18 /* colorFrame */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* colorFrame */) &&
|
||||
verifier.VerifyTable(colorFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 20 /* textureFrame */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* textureFrame */) &&
|
||||
verifier.VerifyTable(textureFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* eventFrame */) &&
|
||||
verifier.VerifyTable(eventFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 14 /* intFrame */) &&
|
||||
verifier.VerifyTable(intFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 16 /* boolFrame */) &&
|
||||
verifier.VerifyTable(boolFrame()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 18 /* innerActionFrame */) &&
|
||||
verifier.VerifyTable(innerActionFrame()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -1932,123 +1974,197 @@ struct Frame : private flatbuffers::Table {
|
|||
struct FrameBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_visibleFrame(flatbuffers::Offset<TimeLineBoolFrame> visibleFrame) { fbb_.AddOffset(4, visibleFrame); }
|
||||
void add_zOrderFrame(flatbuffers::Offset<TimeLineIntFrame> zOrderFrame) { fbb_.AddOffset(6, zOrderFrame); }
|
||||
void add_rotationSkewFrame(flatbuffers::Offset<TimeLinePointFrame> rotationSkewFrame) { fbb_.AddOffset(8, rotationSkewFrame); }
|
||||
void add_eventFrame(flatbuffers::Offset<TimeLineStringFrame> eventFrame) { fbb_.AddOffset(10, eventFrame); }
|
||||
void add_anchorPointFrame(flatbuffers::Offset<TimeLinePointFrame> anchorPointFrame) { fbb_.AddOffset(12, anchorPointFrame); }
|
||||
void add_positionFrame(flatbuffers::Offset<TimeLinePointFrame> positionFrame) { fbb_.AddOffset(14, positionFrame); }
|
||||
void add_scaleFrame(flatbuffers::Offset<TimeLinePointFrame> scaleFrame) { fbb_.AddOffset(16, scaleFrame); }
|
||||
void add_colorFrame(flatbuffers::Offset<TimeLineColorFrame> colorFrame) { fbb_.AddOffset(18, colorFrame); }
|
||||
void add_textureFrame(flatbuffers::Offset<TimeLineTextureFrame> textureFrame) { fbb_.AddOffset(20, textureFrame); }
|
||||
void add_pointFrame(flatbuffers::Offset<PointFrame> pointFrame) { fbb_.AddOffset(4, pointFrame); }
|
||||
void add_scaleFrame(flatbuffers::Offset<ScaleFrame> scaleFrame) { fbb_.AddOffset(6, scaleFrame); }
|
||||
void add_colorFrame(flatbuffers::Offset<ColorFrame> colorFrame) { fbb_.AddOffset(8, colorFrame); }
|
||||
void add_textureFrame(flatbuffers::Offset<TextureFrame> textureFrame) { fbb_.AddOffset(10, textureFrame); }
|
||||
void add_eventFrame(flatbuffers::Offset<EventFrame> eventFrame) { fbb_.AddOffset(12, eventFrame); }
|
||||
void add_intFrame(flatbuffers::Offset<IntFrame> intFrame) { fbb_.AddOffset(14, intFrame); }
|
||||
void add_boolFrame(flatbuffers::Offset<BoolFrame> boolFrame) { fbb_.AddOffset(16, boolFrame); }
|
||||
void add_innerActionFrame(flatbuffers::Offset<InnerActionFrame> innerActionFrame) { fbb_.AddOffset(18, innerActionFrame); }
|
||||
FrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
FrameBuilder &operator=(const FrameBuilder &);
|
||||
flatbuffers::Offset<Frame> Finish() {
|
||||
auto o = flatbuffers::Offset<Frame>(fbb_.EndTable(start_, 9));
|
||||
auto o = flatbuffers::Offset<Frame>(fbb_.EndTable(start_, 8));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<Frame> CreateFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<TimeLineBoolFrame> visibleFrame = 0,
|
||||
flatbuffers::Offset<TimeLineIntFrame> zOrderFrame = 0,
|
||||
flatbuffers::Offset<TimeLinePointFrame> rotationSkewFrame = 0,
|
||||
flatbuffers::Offset<TimeLineStringFrame> eventFrame = 0,
|
||||
flatbuffers::Offset<TimeLinePointFrame> anchorPointFrame = 0,
|
||||
flatbuffers::Offset<TimeLinePointFrame> positionFrame = 0,
|
||||
flatbuffers::Offset<TimeLinePointFrame> scaleFrame = 0,
|
||||
flatbuffers::Offset<TimeLineColorFrame> colorFrame = 0,
|
||||
flatbuffers::Offset<TimeLineTextureFrame> textureFrame = 0) {
|
||||
flatbuffers::Offset<PointFrame> pointFrame = 0,
|
||||
flatbuffers::Offset<ScaleFrame> scaleFrame = 0,
|
||||
flatbuffers::Offset<ColorFrame> colorFrame = 0,
|
||||
flatbuffers::Offset<TextureFrame> textureFrame = 0,
|
||||
flatbuffers::Offset<EventFrame> eventFrame = 0,
|
||||
flatbuffers::Offset<IntFrame> intFrame = 0,
|
||||
flatbuffers::Offset<BoolFrame> boolFrame = 0,
|
||||
flatbuffers::Offset<InnerActionFrame> innerActionFrame = 0) {
|
||||
FrameBuilder builder_(_fbb);
|
||||
builder_.add_innerActionFrame(innerActionFrame);
|
||||
builder_.add_boolFrame(boolFrame);
|
||||
builder_.add_intFrame(intFrame);
|
||||
builder_.add_eventFrame(eventFrame);
|
||||
builder_.add_textureFrame(textureFrame);
|
||||
builder_.add_colorFrame(colorFrame);
|
||||
builder_.add_scaleFrame(scaleFrame);
|
||||
builder_.add_positionFrame(positionFrame);
|
||||
builder_.add_anchorPointFrame(anchorPointFrame);
|
||||
builder_.add_eventFrame(eventFrame);
|
||||
builder_.add_rotationSkewFrame(rotationSkewFrame);
|
||||
builder_.add_zOrderFrame(zOrderFrame);
|
||||
builder_.add_visibleFrame(visibleFrame);
|
||||
builder_.add_pointFrame(pointFrame);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct TimeLineBoolFrame : private flatbuffers::Table {
|
||||
struct PointFrame : private flatbuffers::Table {
|
||||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
uint8_t value() const { return GetField<uint8_t>(8, 0); }
|
||||
const Position *postion() const { return GetStruct<const Position *>(8); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<uint8_t>(verifier, 8 /* value */) &&
|
||||
VerifyField<Position>(verifier, 8 /* postion */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TimeLineBoolFrameBuilder {
|
||||
struct PointFrameBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_value(uint8_t value) { fbb_.AddElement<uint8_t>(8, value, 0); }
|
||||
TimeLineBoolFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
TimeLineBoolFrameBuilder &operator=(const TimeLineBoolFrameBuilder &);
|
||||
flatbuffers::Offset<TimeLineBoolFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<TimeLineBoolFrame>(fbb_.EndTable(start_, 3));
|
||||
void add_postion(const Position *postion) { fbb_.AddStruct(8, postion); }
|
||||
PointFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
PointFrameBuilder &operator=(const PointFrameBuilder &);
|
||||
flatbuffers::Offset<PointFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<PointFrame>(fbb_.EndTable(start_, 3));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<TimeLineBoolFrame> CreateTimeLineBoolFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
inline flatbuffers::Offset<PointFrame> CreatePointFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
uint8_t value = 0) {
|
||||
TimeLineBoolFrameBuilder builder_(_fbb);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_value(value);
|
||||
builder_.add_tween(tween);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct TimeLineIntFrame : private flatbuffers::Table {
|
||||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
int32_t value() const { return GetField<int32_t>(8, 0); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<int32_t>(verifier, 8 /* value */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TimeLineIntFrameBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_value(int32_t value) { fbb_.AddElement<int32_t>(8, value, 0); }
|
||||
TimeLineIntFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
TimeLineIntFrameBuilder &operator=(const TimeLineIntFrameBuilder &);
|
||||
flatbuffers::Offset<TimeLineIntFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<TimeLineIntFrame>(fbb_.EndTable(start_, 3));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<TimeLineIntFrame> CreateTimeLineIntFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
int32_t value = 0) {
|
||||
TimeLineIntFrameBuilder builder_(_fbb);
|
||||
builder_.add_value(value);
|
||||
const Position *postion = 0) {
|
||||
PointFrameBuilder builder_(_fbb);
|
||||
builder_.add_postion(postion);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct TimeLineStringFrame : private flatbuffers::Table {
|
||||
struct ScaleFrame : private flatbuffers::Table {
|
||||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const Scale *scale() const { return GetStruct<const Scale *>(8); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<Scale>(verifier, 8 /* scale */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct ScaleFrameBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_scale(const Scale *scale) { fbb_.AddStruct(8, scale); }
|
||||
ScaleFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
ScaleFrameBuilder &operator=(const ScaleFrameBuilder &);
|
||||
flatbuffers::Offset<ScaleFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<ScaleFrame>(fbb_.EndTable(start_, 3));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<ScaleFrame> CreateScaleFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
const Scale *scale = 0) {
|
||||
ScaleFrameBuilder builder_(_fbb);
|
||||
builder_.add_scale(scale);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct ColorFrame : private flatbuffers::Table {
|
||||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const Color *color() const { return GetStruct<const Color *>(8); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<Color>(verifier, 8 /* color */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct ColorFrameBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_color(const Color *color) { fbb_.AddStruct(8, color); }
|
||||
ColorFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
ColorFrameBuilder &operator=(const ColorFrameBuilder &);
|
||||
flatbuffers::Offset<ColorFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<ColorFrame>(fbb_.EndTable(start_, 3));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<ColorFrame> CreateColorFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
const Color *color = 0) {
|
||||
ColorFrameBuilder builder_(_fbb);
|
||||
builder_.add_color(color);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct TextureFrame : private flatbuffers::Table {
|
||||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const ResourceData *textureFile() const { return GetPointer<const ResourceData *>(8); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* textureFile */) &&
|
||||
verifier.VerifyTable(textureFile()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TextureFrameBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_textureFile(flatbuffers::Offset<ResourceData> textureFile) { fbb_.AddOffset(8, textureFile); }
|
||||
TextureFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
TextureFrameBuilder &operator=(const TextureFrameBuilder &);
|
||||
flatbuffers::Offset<TextureFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<TextureFrame>(fbb_.EndTable(start_, 3));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<TextureFrame> CreateTextureFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
flatbuffers::Offset<ResourceData> textureFile = 0) {
|
||||
TextureFrameBuilder builder_(_fbb);
|
||||
builder_.add_textureFile(textureFile);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct EventFrame : private flatbuffers::Table {
|
||||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const flatbuffers::String *value() const { return GetPointer<const flatbuffers::String *>(8); }
|
||||
|
@ -2062,141 +2178,151 @@ struct TimeLineStringFrame : private flatbuffers::Table {
|
|||
}
|
||||
};
|
||||
|
||||
struct TimeLineStringFrameBuilder {
|
||||
struct EventFrameBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_value(flatbuffers::Offset<flatbuffers::String> value) { fbb_.AddOffset(8, value); }
|
||||
TimeLineStringFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
TimeLineStringFrameBuilder &operator=(const TimeLineStringFrameBuilder &);
|
||||
flatbuffers::Offset<TimeLineStringFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<TimeLineStringFrame>(fbb_.EndTable(start_, 3));
|
||||
EventFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
EventFrameBuilder &operator=(const EventFrameBuilder &);
|
||||
flatbuffers::Offset<EventFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<EventFrame>(fbb_.EndTable(start_, 3));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<TimeLineStringFrame> CreateTimeLineStringFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
inline flatbuffers::Offset<EventFrame> CreateEventFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
flatbuffers::Offset<flatbuffers::String> value = 0) {
|
||||
TimeLineStringFrameBuilder builder_(_fbb);
|
||||
EventFrameBuilder builder_(_fbb);
|
||||
builder_.add_value(value);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct TimeLinePointFrame : private flatbuffers::Table {
|
||||
struct IntFrame : private flatbuffers::Table {
|
||||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const Position *postion() const { return GetStruct<const Position *>(8); }
|
||||
int32_t value() const { return GetField<int32_t>(8, 0); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<Position>(verifier, 8 /* postion */) &&
|
||||
VerifyField<int32_t>(verifier, 8 /* value */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TimeLinePointFrameBuilder {
|
||||
struct IntFrameBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_postion(const Position *postion) { fbb_.AddStruct(8, postion); }
|
||||
TimeLinePointFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
TimeLinePointFrameBuilder &operator=(const TimeLinePointFrameBuilder &);
|
||||
flatbuffers::Offset<TimeLinePointFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<TimeLinePointFrame>(fbb_.EndTable(start_, 3));
|
||||
void add_value(int32_t value) { fbb_.AddElement<int32_t>(8, value, 0); }
|
||||
IntFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
IntFrameBuilder &operator=(const IntFrameBuilder &);
|
||||
flatbuffers::Offset<IntFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<IntFrame>(fbb_.EndTable(start_, 3));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<TimeLinePointFrame> CreateTimeLinePointFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
inline flatbuffers::Offset<IntFrame> CreateIntFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
const Position *postion = 0) {
|
||||
TimeLinePointFrameBuilder builder_(_fbb);
|
||||
builder_.add_postion(postion);
|
||||
int32_t value = 0) {
|
||||
IntFrameBuilder builder_(_fbb);
|
||||
builder_.add_value(value);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct TimeLineColorFrame : private flatbuffers::Table {
|
||||
struct BoolFrame : private flatbuffers::Table {
|
||||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const Color *color() const { return GetStruct<const Color *>(8); }
|
||||
uint8_t value() const { return GetField<uint8_t>(8, 1); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<Color>(verifier, 8 /* color */) &&
|
||||
VerifyField<uint8_t>(verifier, 8 /* value */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TimeLineColorFrameBuilder {
|
||||
struct BoolFrameBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_color(const Color *color) { fbb_.AddStruct(8, color); }
|
||||
TimeLineColorFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
TimeLineColorFrameBuilder &operator=(const TimeLineColorFrameBuilder &);
|
||||
flatbuffers::Offset<TimeLineColorFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<TimeLineColorFrame>(fbb_.EndTable(start_, 3));
|
||||
void add_value(uint8_t value) { fbb_.AddElement<uint8_t>(8, value, 1); }
|
||||
BoolFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
BoolFrameBuilder &operator=(const BoolFrameBuilder &);
|
||||
flatbuffers::Offset<BoolFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<BoolFrame>(fbb_.EndTable(start_, 3));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<TimeLineColorFrame> CreateTimeLineColorFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
inline flatbuffers::Offset<BoolFrame> CreateBoolFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
const Color *color = 0) {
|
||||
TimeLineColorFrameBuilder builder_(_fbb);
|
||||
builder_.add_color(color);
|
||||
uint8_t value = 1) {
|
||||
BoolFrameBuilder builder_(_fbb);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_value(value);
|
||||
builder_.add_tween(tween);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct TimeLineTextureFrame : private flatbuffers::Table {
|
||||
struct InnerActionFrame : private flatbuffers::Table {
|
||||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const ResourceData *fileNameData() const { return GetPointer<const ResourceData *>(8); }
|
||||
int32_t innerActionType() const { return GetField<int32_t>(8, 0); }
|
||||
const flatbuffers::String *currentAniamtionName() const { return GetPointer<const flatbuffers::String *>(10); }
|
||||
int32_t singleFrameIndex() const { return GetField<int32_t>(12, 0); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* fileNameData */) &&
|
||||
verifier.VerifyTable(fileNameData()) &&
|
||||
VerifyField<int32_t>(verifier, 8 /* innerActionType */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* currentAniamtionName */) &&
|
||||
verifier.Verify(currentAniamtionName()) &&
|
||||
VerifyField<int32_t>(verifier, 12 /* singleFrameIndex */) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct TimeLineTextureFrameBuilder {
|
||||
struct InnerActionFrameBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_fileNameData(flatbuffers::Offset<ResourceData> fileNameData) { fbb_.AddOffset(8, fileNameData); }
|
||||
TimeLineTextureFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
TimeLineTextureFrameBuilder &operator=(const TimeLineTextureFrameBuilder &);
|
||||
flatbuffers::Offset<TimeLineTextureFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<TimeLineTextureFrame>(fbb_.EndTable(start_, 3));
|
||||
void add_innerActionType(int32_t innerActionType) { fbb_.AddElement<int32_t>(8, innerActionType, 0); }
|
||||
void add_currentAniamtionName(flatbuffers::Offset<flatbuffers::String> currentAniamtionName) { fbb_.AddOffset(10, currentAniamtionName); }
|
||||
void add_singleFrameIndex(int32_t singleFrameIndex) { fbb_.AddElement<int32_t>(12, singleFrameIndex, 0); }
|
||||
InnerActionFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
InnerActionFrameBuilder &operator=(const InnerActionFrameBuilder &);
|
||||
flatbuffers::Offset<InnerActionFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<InnerActionFrame>(fbb_.EndTable(start_, 5));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<TimeLineTextureFrame> CreateTimeLineTextureFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
inline flatbuffers::Offset<InnerActionFrame> CreateInnerActionFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
flatbuffers::Offset<ResourceData> fileNameData = 0) {
|
||||
TimeLineTextureFrameBuilder builder_(_fbb);
|
||||
builder_.add_fileNameData(fileNameData);
|
||||
int32_t innerActionType = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> currentAniamtionName = 0,
|
||||
int32_t singleFrameIndex = 0) {
|
||||
InnerActionFrameBuilder builder_(_fbb);
|
||||
builder_.add_singleFrameIndex(singleFrameIndex);
|
||||
builder_.add_currentAniamtionName(currentAniamtionName);
|
||||
builder_.add_innerActionType(innerActionType);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
return builder_.Finish();
|
||||
|
|
|
@ -68,15 +68,16 @@ using namespace flatbuffers;
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
static const char* FrameType_VisibleFrame = "VisibleFrame";
|
||||
static const char* FrameType_PositionFrame = "PositionFrame";
|
||||
static const char* FrameType_ScaleFrame = "ScaleFrame";
|
||||
static const char* FrameType_RotationSkewFrame = "RotationSkewFrame";
|
||||
static const char* FrameType_AnchorFrame = "AnchorPointFrame";
|
||||
static const char* FrameType_ColorFrame = "ColorFrame";
|
||||
static const char* FrameType_TextureFrame = "TextureFrame";
|
||||
static const char* FrameType_EventFrame = "EventFrame";
|
||||
static const char* FrameType_ZOrderFrame = "ZOrderFrame";
|
||||
static const char* Property_VisibleForFrame = "VisibleForFrame";
|
||||
static const char* Property_Position = "Position";
|
||||
static const char* Property_Scale = "Scale";
|
||||
static const char* Property_RotationSkew = "RotationSkew";
|
||||
static const char* Property_CColor = "CColor";
|
||||
static const char* Property_FileData = "FileData";
|
||||
static const char* Property_FrameEvent = "FrameEvent";
|
||||
static const char* Property_Alpha = "Alpha";
|
||||
static const char* Property_ZOrder = "ZOrder";
|
||||
static const char* Property_ActionValue = "ActionValue";
|
||||
|
||||
static FlatBuffersSerialize* _instanceFlatBuffersSerialize = nullptr;
|
||||
|
||||
|
@ -232,7 +233,7 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str
|
|||
|
||||
Offset<NodeTree> nodeTree;
|
||||
Offset<NodeAction> aciton;
|
||||
|
||||
std::vector<Offset<flatbuffers::AnimationInfo>> animationInfos;
|
||||
|
||||
const tinyxml2::XMLElement* child = element->FirstChildElement();
|
||||
|
||||
|
@ -250,15 +251,26 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str
|
|||
const tinyxml2::XMLElement* objectData = child;
|
||||
nodeTree = createNodeTree(objectData, rootType);
|
||||
}
|
||||
|
||||
else if (name == "AnimationList") // animation list
|
||||
{
|
||||
const tinyxml2::XMLElement* animationinfoElement = child->FirstChildElement();
|
||||
while (animationinfoElement)
|
||||
{
|
||||
auto animationinfo = createAnimationInfo(animationinfoElement);
|
||||
animationInfos.push_back(animationinfo);
|
||||
animationinfoElement = animationinfoElement->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
|
||||
|
||||
auto csparsebinary = CreateCSParseBinary(*_builder,
|
||||
_builder->CreateVector(_textures),
|
||||
_builder->CreateVector(_texturePngs),
|
||||
nodeTree,
|
||||
aciton,
|
||||
_builder->CreateVector(animationInfos),
|
||||
_builder->CreateString(_csdVersion));
|
||||
_builder->Finish(csparsebinary);
|
||||
|
||||
|
@ -514,6 +526,7 @@ Offset<NodeAction> FlatBuffersSerialize::createNodeAction(const tinyxml2::XMLEle
|
|||
{
|
||||
int duration = 0;
|
||||
float speed = 0.0f;
|
||||
std::string currentAnimationName = "";
|
||||
|
||||
// CCLOG("animation name = %s", objectData->Name());
|
||||
|
||||
|
@ -534,6 +547,10 @@ Offset<NodeAction> FlatBuffersSerialize::createNodeAction(const tinyxml2::XMLEle
|
|||
{
|
||||
speed = atof(value.c_str());
|
||||
}
|
||||
else if (name == "ActivedAnimationName")
|
||||
{
|
||||
currentAnimationName = value.c_str();
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
@ -552,13 +569,43 @@ Offset<NodeAction> FlatBuffersSerialize::createNodeAction(const tinyxml2::XMLEle
|
|||
return CreateNodeAction(*_builder,
|
||||
duration,
|
||||
speed,
|
||||
_builder->CreateVector(timelines));
|
||||
_builder->CreateVector(timelines),
|
||||
_builder->CreateString(currentAnimationName));
|
||||
}
|
||||
|
||||
|
||||
Offset<flatbuffers::AnimationInfo> FlatBuffersSerialize::createAnimationInfo(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
std::string infoName = "";
|
||||
int startIndex = 0;
|
||||
int endIndex = 0;
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string attriname = attribute->Name();
|
||||
std::string attrivalue = attribute->Value();
|
||||
if (attriname == "Name")
|
||||
{
|
||||
infoName = attrivalue;
|
||||
}
|
||||
else if (attriname == "StartIndex")
|
||||
{
|
||||
startIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (attriname == "EndIndex")
|
||||
{
|
||||
endIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
return CreateAnimationInfo(*_builder, _builder->CreateString(infoName), startIndex, endIndex);
|
||||
}
|
||||
|
||||
Offset<TimeLine> FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int actionTag = 0;
|
||||
std::string frameType = "";
|
||||
std::string property = "";
|
||||
|
||||
// TimelineData attrsibutes
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
|
@ -571,9 +618,9 @@ Offset<TimeLine> FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement
|
|||
{
|
||||
actionTag = atoi(value.c_str());
|
||||
}
|
||||
else if (name == "FrameType")
|
||||
else if (name == "Property")
|
||||
{
|
||||
frameType = value;
|
||||
property = value;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
|
@ -587,210 +634,113 @@ Offset<TimeLine> FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement
|
|||
{
|
||||
Offset<flatbuffers::Frame> frame;
|
||||
|
||||
if (frameType == FrameType_VisibleFrame)
|
||||
if (property == Property_VisibleForFrame)
|
||||
{
|
||||
auto visibleFrame = createTimeLineBoolFrame(frameElement);
|
||||
auto boolFrame = createBoolFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
visibleFrame);
|
||||
}
|
||||
else if (frameType == FrameType_ZOrderFrame)
|
||||
{
|
||||
auto zOrderFrame = createTimeLineIntFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // VisibleFrame
|
||||
zOrderFrame);
|
||||
}
|
||||
else if (frameType == FrameType_RotationSkewFrame)
|
||||
{
|
||||
auto rotationSkewFrame = createTimeLinePointFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // VisibleFrame
|
||||
0, // ZOrderFrame
|
||||
rotationSkewFrame);
|
||||
}
|
||||
else if (frameType == FrameType_EventFrame)
|
||||
{
|
||||
auto eventFrame = createTimeLineStringFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // VisibleFrame
|
||||
0, // ZOrderFrame
|
||||
0, // RotationSkewFrame
|
||||
eventFrame);
|
||||
}
|
||||
else if (frameType == FrameType_AnchorFrame)
|
||||
{
|
||||
auto anchorPointFrame = createTimeLinePointFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // VisibleFrame
|
||||
0, // ZOrderFrame
|
||||
0, // RotationSkewFrame
|
||||
0, // PointFrame
|
||||
0, // ScaleFrame
|
||||
0, // ColorFrame
|
||||
0, // TextureFrame
|
||||
0, // EventFrame
|
||||
anchorPointFrame);
|
||||
0, // IntFrame
|
||||
boolFrame);
|
||||
}
|
||||
else if (frameType == FrameType_PositionFrame)
|
||||
else if (property == Property_Position)
|
||||
{
|
||||
auto positionFrame = createTimeLinePointFrame(frameElement);
|
||||
auto pointFrame = createPointFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // VisibleFrame
|
||||
0, // ZOrderFrame
|
||||
0, // RotationSkewFrame
|
||||
0, // EventFrame
|
||||
0, // AnchorPointFrame
|
||||
positionFrame);
|
||||
pointFrame);
|
||||
}
|
||||
else if (frameType == FrameType_ScaleFrame)
|
||||
else if (property == Property_Scale)
|
||||
{
|
||||
auto scaleFrame = createTimeLinePointFrame(frameElement);
|
||||
auto scaleFrame = createScaleFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // VisibleFrame
|
||||
0, // ZOrderFrame
|
||||
0, // RotationSkewFrame
|
||||
0, // EventFrame
|
||||
0, // AnchorPointFrame
|
||||
0, // PositionFrame
|
||||
0, // PointFrame
|
||||
scaleFrame);
|
||||
}
|
||||
else if (frameType == FrameType_ColorFrame)
|
||||
else if (property == Property_RotationSkew)
|
||||
{
|
||||
auto colorFrame = createTimeLineColorFrame(frameElement);
|
||||
auto scaleFrame = createScaleFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // VisibleFrame
|
||||
0, // ZOrderFrame
|
||||
0, // RotationSkewFrame
|
||||
0, // EventFrame
|
||||
0, // AnchorPointFrame
|
||||
0, // PositionFrame
|
||||
0, // PointFrame
|
||||
scaleFrame);
|
||||
}
|
||||
else if (property == Property_CColor)
|
||||
{
|
||||
auto colorFrame = createColorFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // PointFrame
|
||||
0, // ScaleFrame
|
||||
colorFrame);
|
||||
}
|
||||
else if (frameType == FrameType_TextureFrame)
|
||||
else if (property == Property_FileData)
|
||||
{
|
||||
auto textureFrame = createTimeLineTextureFrame(frameElement);
|
||||
auto textureFrame = createTextureFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // VisibleFrame
|
||||
0, // ZOrderFrame
|
||||
0, // RotationSkewFrame
|
||||
0, // EventFrame
|
||||
0, // AnchorPointFrame
|
||||
0, // PositionFrame
|
||||
0, // PointFrame
|
||||
0, // ScaleFrame
|
||||
0, // ColorFrame
|
||||
textureFrame);
|
||||
}
|
||||
else if (property == Property_FrameEvent)
|
||||
{
|
||||
auto eventFrame = createEventFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // PointFrame
|
||||
0, // ScaleFrame
|
||||
0, // ColorFrame
|
||||
0, // TextureFrame
|
||||
eventFrame);
|
||||
}
|
||||
else if (property == Property_Alpha)
|
||||
{
|
||||
auto intFrame = createIntFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // PointFrame
|
||||
0, // ScaleFrame
|
||||
0, // ColorFrame
|
||||
0, // TextureFrame
|
||||
0, // EventFrame
|
||||
intFrame);
|
||||
}
|
||||
else if (property == Property_ZOrder)
|
||||
{
|
||||
auto intFrame = createIntFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // PointFrame
|
||||
0, // ScaleFrame
|
||||
0, // ColorFrame
|
||||
0, // TextureFrame
|
||||
0, // EventFrame
|
||||
intFrame);
|
||||
}
|
||||
else if (property == Property_ActionValue)
|
||||
{
|
||||
auto innerActionFrame = createInnerActionFrame(frameElement);
|
||||
frame = CreateFrame(*_builder,
|
||||
0, // PointFrame
|
||||
0, // ScaleFrame
|
||||
0, // ColorFrame
|
||||
0, // TextureFrame
|
||||
0, // EventFrame
|
||||
0, // IntFrame
|
||||
0, // BoolFrame
|
||||
innerActionFrame);
|
||||
}
|
||||
|
||||
frames.push_back(frame);
|
||||
|
||||
frameElement = frameElement->NextSiblingElement();
|
||||
}
|
||||
|
||||
return CreateTimeLine(*_builder,
|
||||
_builder->CreateString(frameType),
|
||||
_builder->CreateString(property),
|
||||
actionTag,
|
||||
_builder->CreateVector(frames));
|
||||
}
|
||||
|
||||
Offset<TimeLineBoolFrame> FlatBuffersSerialize::createTimeLineBoolFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
bool value = false;
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string name = attribute->Name();
|
||||
std::string attrivalue = attribute->Value();
|
||||
|
||||
if (name == "Value")
|
||||
{
|
||||
value = (attrivalue == "True") ? true : false;
|
||||
}
|
||||
else if (name == "FrameIndex")
|
||||
{
|
||||
frameIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "Tween")
|
||||
{
|
||||
tween = atoi(attrivalue.c_str());
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
return CreateTimeLineBoolFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
value);
|
||||
}
|
||||
|
||||
Offset<TimeLineIntFrame> FlatBuffersSerialize::createTimeLineIntFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
int value = 0;
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string name = attribute->Name();
|
||||
std::string attrivalue = attribute->Value();
|
||||
|
||||
if (name == "Value") // to be gonna modify
|
||||
{
|
||||
value = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "FrameIndex")
|
||||
{
|
||||
frameIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "Tween")
|
||||
{
|
||||
tween = (attrivalue == "True") ? true : false;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
return CreateTimeLineIntFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
value);
|
||||
}
|
||||
|
||||
Offset<TimeLineStringFrame> FlatBuffersSerialize::createTimeLineStringFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
std::string value = "";
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string name = attribute->Name();
|
||||
std::string attrivalue = attribute->Value();
|
||||
|
||||
if (name == "Value") // to be gonna modify
|
||||
{
|
||||
value = attrivalue;
|
||||
}
|
||||
else if (name == "FrameIndex")
|
||||
{
|
||||
frameIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "Tween")
|
||||
{
|
||||
tween = (attrivalue == "True") ? true : false;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
return CreateTimeLineStringFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
_builder->CreateString(value));
|
||||
}
|
||||
|
||||
Offset<TimeLinePointFrame> FlatBuffersSerialize::createTimeLinePointFrame(const tinyxml2::XMLElement *objectData)
|
||||
Offset<flatbuffers::PointFrame> FlatBuffersSerialize::createPointFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
|
@ -824,17 +774,57 @@ Offset<TimeLinePointFrame> FlatBuffersSerialize::createTimeLinePointFrame(const
|
|||
|
||||
Position f_position(position.x, position.y);
|
||||
|
||||
return CreateTimeLinePointFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
&f_position);
|
||||
return CreatePointFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
&f_position);
|
||||
}
|
||||
|
||||
Offset<TimeLineColorFrame> FlatBuffersSerialize::createTimeLineColorFrame(const tinyxml2::XMLElement *objectData)
|
||||
Offset<flatbuffers::ScaleFrame> FlatBuffersSerialize::createScaleFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
Color4B color;
|
||||
Vec2 scale;
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string name = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
|
||||
if (name == "X")
|
||||
{
|
||||
scale.x = atof(value.c_str());
|
||||
}
|
||||
else if (name == "Y")
|
||||
{
|
||||
scale.y = atof(value.c_str());
|
||||
}
|
||||
else if (name == "FrameIndex")
|
||||
{
|
||||
frameIndex = atoi(value.c_str());
|
||||
}
|
||||
else if (name == "Tween")
|
||||
{
|
||||
tween = (value == "True") ? true : false;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
Scale f_scale(scale.x, scale.y);
|
||||
|
||||
return CreateScaleFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
&f_scale);
|
||||
}
|
||||
|
||||
Offset<flatbuffers::ColorFrame> FlatBuffersSerialize::createColorFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
Color3B color;
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
|
@ -846,10 +836,6 @@ Offset<TimeLineColorFrame> FlatBuffersSerialize::createTimeLineColorFrame(const
|
|||
{
|
||||
frameIndex = atoi(value.c_str());
|
||||
}
|
||||
else if (name == "Alpha")
|
||||
{
|
||||
color.a = atoi(value.c_str());
|
||||
}
|
||||
else if (name == "Tween")
|
||||
{
|
||||
tween = (value == "True") ? true : false;
|
||||
|
@ -879,7 +865,7 @@ Offset<TimeLineColorFrame> FlatBuffersSerialize::createTimeLineColorFrame(const
|
|||
else if (name == "B")
|
||||
{
|
||||
color.b = atoi(value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
@ -887,85 +873,244 @@ Offset<TimeLineColorFrame> FlatBuffersSerialize::createTimeLineColorFrame(const
|
|||
child = child->NextSiblingElement();
|
||||
}
|
||||
|
||||
Color f_color(color.a, color.r, color.g, color.b);
|
||||
Color f_color(255, color.r, color.g, color.b);
|
||||
|
||||
return CreateTimeLineColorFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
&f_color);
|
||||
return CreateColorFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
&f_color);
|
||||
}
|
||||
|
||||
Offset<TimeLineTextureFrame> FlatBuffersSerialize::createTimeLineTextureFrame(const tinyxml2::XMLElement *objectData)
|
||||
Offset<flatbuffers::TextureFrame> FlatBuffersSerialize::createTextureFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
|
||||
std::string path = "";
|
||||
std::string plistFile = "";
|
||||
int resourceType = 0;
|
||||
|
||||
std::string texture = "";
|
||||
std::string texturePng = "";
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
std::string attriname = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
|
||||
std::string path = "";
|
||||
std::string plistFile = "";
|
||||
int resourceType = 0;
|
||||
if (attriname == "FrameIndex")
|
||||
{
|
||||
frameIndex = atoi(value.c_str());
|
||||
}
|
||||
else if (attriname == "Tween")
|
||||
{
|
||||
tween = (value == "True") ? true : false;
|
||||
}
|
||||
|
||||
std::string texture = "";
|
||||
std::string texturePng = "";
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
|
||||
while (child)
|
||||
{
|
||||
attribute = child->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string attriname = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
|
||||
if (attriname == "FrameIndex")
|
||||
if (attriname == "Path")
|
||||
{
|
||||
frameIndex = atoi(value.c_str());
|
||||
path = value;
|
||||
}
|
||||
else if (attriname == "Tween")
|
||||
else if (attriname == "Type")
|
||||
{
|
||||
tween = (value == "True") ? true : false;
|
||||
resourceType = getResourceType(value);
|
||||
}
|
||||
else if (attriname == "Plist")
|
||||
{
|
||||
plistFile = value;
|
||||
texture = value;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
|
||||
while (child)
|
||||
if (resourceType == 1)
|
||||
{
|
||||
attribute = child->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string attriname = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
|
||||
if (attriname == "Path")
|
||||
{
|
||||
path = value;
|
||||
}
|
||||
else if (attriname == "Type")
|
||||
{
|
||||
resourceType = getResourceType(value);
|
||||
}
|
||||
else if (attriname == "Plist")
|
||||
{
|
||||
plistFile = value;
|
||||
texture = value;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
if (resourceType == 1)
|
||||
{
|
||||
_textures.push_back(_builder->CreateString(texture));
|
||||
}
|
||||
|
||||
child = child->NextSiblingElement();
|
||||
_textures.push_back(_builder->CreateString(texture));
|
||||
}
|
||||
|
||||
return CreateTimeLineTextureFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
CreateResourceData(*_builder,
|
||||
_builder->CreateString(path),
|
||||
_builder->CreateString(plistFile),
|
||||
resourceType));
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
|
||||
return CreateTextureFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
CreateResourceData(*_builder,
|
||||
_builder->CreateString(path),
|
||||
_builder->CreateString(plistFile),
|
||||
resourceType));
|
||||
}
|
||||
|
||||
Offset<flatbuffers::EventFrame> FlatBuffersSerialize::createEventFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
std::string value = "";
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string name = attribute->Name();
|
||||
std::string attrivalue = attribute->Value();
|
||||
|
||||
if (name == "Value") // to be gonna modify
|
||||
{
|
||||
value = attrivalue;
|
||||
}
|
||||
else if (name == "FrameIndex")
|
||||
{
|
||||
frameIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "Tween")
|
||||
{
|
||||
tween = (attrivalue == "True") ? true : false;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
return CreateEventFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
_builder->CreateString(value));
|
||||
}
|
||||
|
||||
Offset<flatbuffers::IntFrame> FlatBuffersSerialize::createIntFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
int value = 0;
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string name = attribute->Name();
|
||||
std::string attrivalue = attribute->Value();
|
||||
|
||||
if (name == "Value") // to be gonna modify
|
||||
{
|
||||
value = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "FrameIndex")
|
||||
{
|
||||
frameIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "Tween")
|
||||
{
|
||||
tween = (attrivalue == "True") ? true : false;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
return CreateIntFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
value);
|
||||
}
|
||||
|
||||
Offset<flatbuffers::BoolFrame> FlatBuffersSerialize::createBoolFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
bool value = true;
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string name = attribute->Name();
|
||||
std::string attrivalue = attribute->Value();
|
||||
|
||||
if (name == "Value")
|
||||
{
|
||||
value = (attrivalue == "True") ? true : false;
|
||||
}
|
||||
else if (name == "FrameIndex")
|
||||
{
|
||||
frameIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "Tween")
|
||||
{
|
||||
tween = (attrivalue == "True") ? true : false;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
return CreateBoolFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
value);
|
||||
}
|
||||
|
||||
Offset<flatbuffers::InnerActionFrame> FlatBuffersSerialize::createInnerActionFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
int innerActionType = 0;
|
||||
std::string currentAniamtionName = "";
|
||||
int singleFrameIndex = 0;
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string name = attribute->Name();
|
||||
std::string attrivalue = attribute->Value();
|
||||
|
||||
if (name == "InnerActionType")
|
||||
{
|
||||
if (attrivalue == "LoopAction")
|
||||
{
|
||||
innerActionType = 0;
|
||||
}
|
||||
else if (attrivalue == "NoLoopAction")
|
||||
{
|
||||
innerActionType = 1;
|
||||
}
|
||||
else if (attrivalue == "SingleFrame")
|
||||
{
|
||||
innerActionType = 2;
|
||||
}
|
||||
}
|
||||
else if (name == "CurrentAniamtionName")
|
||||
{
|
||||
currentAniamtionName = attrivalue;
|
||||
}
|
||||
else if (name == "SingleFrameIndex")
|
||||
{
|
||||
singleFrameIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "FrameIndex")
|
||||
{
|
||||
frameIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "Tween")
|
||||
{
|
||||
tween = (attrivalue == "True") ? true : false;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
return CreateInnerActionFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
innerActionType,
|
||||
_builder->CreateString(currentAniamtionName),
|
||||
singleFrameIndex);
|
||||
}
|
||||
|
||||
/* create flat buffers with XML */
|
||||
|
@ -1005,7 +1150,7 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato
|
|||
if (attribute)
|
||||
_csdVersion = attribute->Value();
|
||||
}
|
||||
|
||||
|
||||
if (strcmp("Content", element->Name()) == 0)
|
||||
{
|
||||
const tinyxml2::XMLAttribute* attribute = element->FirstAttribute();
|
||||
|
@ -1040,7 +1185,7 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato
|
|||
|
||||
Offset<NodeTree> nodeTree;
|
||||
Offset<NodeAction> aciton;
|
||||
|
||||
std::vector<Offset<flatbuffers::AnimationInfo> > animationInfos;
|
||||
|
||||
const tinyxml2::XMLElement* child = element->FirstChildElement();
|
||||
|
||||
|
@ -1058,6 +1203,16 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato
|
|||
const tinyxml2::XMLElement* objectData = child;
|
||||
nodeTree = createNodeTreeForSimulator(objectData, rootType);
|
||||
}
|
||||
else if (name == "AnimationList") // animation list
|
||||
{
|
||||
const tinyxml2::XMLElement* animationinfoElement = child->FirstChildElement();
|
||||
while (animationinfoElement)
|
||||
{
|
||||
auto animationinfo = createAnimationInfo(animationinfoElement);
|
||||
animationInfos.push_back(animationinfo);
|
||||
animationinfoElement = animationinfoElement->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
|
||||
child = child->NextSiblingElement();
|
||||
}
|
||||
|
@ -1067,8 +1222,9 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato
|
|||
_builder->CreateVector(_texturePngs),
|
||||
nodeTree,
|
||||
aciton,
|
||||
_builder->CreateVector(animationInfos),
|
||||
_builder->CreateString(_csdVersion));
|
||||
_builder->Finish(csparsebinary);
|
||||
_builder->Finish(csparsebinary);
|
||||
|
||||
_textures.clear();
|
||||
_texturePngs.clear();
|
||||
|
@ -1190,26 +1346,6 @@ Offset<ProjectNodeOptions> FlatBuffersSerialize::createProjectNodeOptionsForSimu
|
|||
|
||||
std::string filename = "";
|
||||
|
||||
|
||||
bool isloop = true;
|
||||
bool isAutoPlay = true;
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string attriname = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
if (attriname == "IsLoop")
|
||||
{
|
||||
isloop = (value == "True") ? true : false;
|
||||
|
||||
}
|
||||
else if (attriname == "IsAutoPlay")
|
||||
{
|
||||
isAutoPlay = (value == "True") ? true : false;
|
||||
}
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
// FileData
|
||||
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
|
||||
while (child)
|
||||
|
@ -1218,19 +1354,19 @@ Offset<ProjectNodeOptions> FlatBuffersSerialize::createProjectNodeOptionsForSimu
|
|||
|
||||
if (name == "FileData")
|
||||
{
|
||||
const tinyxml2::XMLAttribute* attributeFileData = child->FirstAttribute();
|
||||
const tinyxml2::XMLAttribute* attribute = child->FirstAttribute();
|
||||
|
||||
while (attributeFileData)
|
||||
while (attribute)
|
||||
{
|
||||
name = attributeFileData->Name();
|
||||
std::string value = attributeFileData->Value();
|
||||
name = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
|
||||
if (name == "Path")
|
||||
{
|
||||
filename = value;
|
||||
}
|
||||
|
||||
attributeFileData = attributeFileData->Next();
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1239,9 +1375,7 @@ Offset<ProjectNodeOptions> FlatBuffersSerialize::createProjectNodeOptionsForSimu
|
|||
|
||||
return CreateProjectNodeOptions(*_builder,
|
||||
nodeOptions,
|
||||
_builder->CreateString(filename),
|
||||
isloop,
|
||||
isAutoPlay);
|
||||
_builder->CreateString(filename));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,16 +65,18 @@ namespace flatbuffers
|
|||
|
||||
struct TextAtlasOptions;
|
||||
|
||||
|
||||
struct NodeAction;
|
||||
struct AnimationInfo;
|
||||
struct TimeLine;
|
||||
struct Frame;
|
||||
struct TimeLineBoolFrame;
|
||||
struct TimeLineIntFrame;
|
||||
struct TimeLineStringFrame;
|
||||
struct TimeLinePointFrame;
|
||||
struct TimeLineColorFrame;
|
||||
struct TimeLineTextureFrame;
|
||||
struct PointFrame;
|
||||
struct ScaleFrame;
|
||||
struct ColorFrame;
|
||||
struct TextureFrame;
|
||||
struct EventFrame;
|
||||
struct IntFrame;
|
||||
struct BoolFrame;
|
||||
struct InnerActionFrame;
|
||||
}
|
||||
|
||||
namespace tinyxml2
|
||||
|
@ -109,13 +111,18 @@ public:
|
|||
|
||||
// NodeAction
|
||||
flatbuffers::Offset<flatbuffers::NodeAction> createNodeAction(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::TimeLine> createTimeLine(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::TimeLineBoolFrame> createTimeLineBoolFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::TimeLineIntFrame> createTimeLineIntFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::TimeLineStringFrame> createTimeLineStringFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::TimeLinePointFrame> createTimeLinePointFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::TimeLineColorFrame> createTimeLineColorFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::TimeLineTextureFrame> createTimeLineTextureFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::TimeLine> createTimeLine(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::PointFrame> createPointFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::ScaleFrame> createScaleFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::ColorFrame> createColorFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::TextureFrame> createTextureFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::EventFrame> createEventFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::IntFrame> createIntFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::BoolFrame> createBoolFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::InnerActionFrame> createInnerActionFrame(const tinyxml2::XMLElement* objectData);
|
||||
|
||||
//Animation Info
|
||||
flatbuffers::Offset<flatbuffers::AnimationInfo> createAnimationInfo(const tinyxml2::XMLElement* objectData);
|
||||
/**/
|
||||
|
||||
int getResourceType(std::string key);
|
||||
|
@ -126,7 +133,7 @@ public:
|
|||
flatbuffers::FlatBufferBuilder* createFlatBuffersWithXMLFileForSimulator(const std::string& xmlFileName);
|
||||
flatbuffers::Offset<flatbuffers::NodeTree> createNodeTreeForSimulator(const tinyxml2::XMLElement* objectData,
|
||||
std::string classType);
|
||||
flatbuffers::Offset<flatbuffers::ProjectNodeOptions> createProjectNodeOptionsForSimulator(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::ProjectNodeOptions> createProjectNodeOptionsForSimulator(const tinyxml2::XMLElement* objectData);
|
||||
/**/
|
||||
std::string getCsdVersion() { return _csdVersion; }
|
||||
|
||||
|
|
|
@ -69,26 +69,6 @@ namespace cocostudio
|
|||
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
|
||||
|
||||
std::string filename = "";
|
||||
bool isloop = true;
|
||||
bool isAutoPlay = true;
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
std::string attriname = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
|
||||
if (attriname == "IsLoop")
|
||||
{
|
||||
isloop = (value == "True") ? true : false;
|
||||
}
|
||||
else if (attriname == "IsAutoPlay")
|
||||
{
|
||||
isAutoPlay = (value == "True") ? true : false;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
// FileData
|
||||
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
|
||||
|
@ -98,12 +78,12 @@ namespace cocostudio
|
|||
|
||||
if (name == "FileData")
|
||||
{
|
||||
const tinyxml2::XMLAttribute* attributeFileData = child->FirstAttribute();
|
||||
const tinyxml2::XMLAttribute* attribute = child->FirstAttribute();
|
||||
|
||||
while (attributeFileData)
|
||||
while (attribute)
|
||||
{
|
||||
name = attributeFileData->Name();
|
||||
std::string value = attributeFileData->Value();
|
||||
name = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
|
||||
if (name == "Path")
|
||||
{
|
||||
|
@ -112,7 +92,7 @@ namespace cocostudio
|
|||
filename = convert;
|
||||
}
|
||||
|
||||
attributeFileData = attributeFileData->Next();
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,9 +101,7 @@ namespace cocostudio
|
|||
|
||||
auto options = CreateProjectNodeOptions(*builder,
|
||||
nodeOptions,
|
||||
builder->CreateString(filename),
|
||||
isloop,
|
||||
isAutoPlay);
|
||||
builder->CreateString(filename));
|
||||
|
||||
return *(Offset<Table>*)(&options);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
@property (readonly) NSInteger getDataTime;
|
||||
|
||||
@property (readonly) NSInteger responseCode;
|
||||
@property (readonly) NSString *statusString;
|
||||
|
||||
@property (strong) NSError *responseError;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
@synthesize responseData;
|
||||
@synthesize getDataTime;
|
||||
@synthesize responseCode;
|
||||
@synthesize statusString;
|
||||
@synthesize responseError;
|
||||
@synthesize conn;
|
||||
@synthesize finish;
|
||||
|
@ -73,7 +74,20 @@
|
|||
responseHeader = [[httpResponse allHeaderFields] copy];
|
||||
|
||||
responseCode = httpResponse.statusCode;
|
||||
if (responseCode != 200)
|
||||
statusString = [[NSHTTPURLResponse localizedStringForStatusCode:responseCode] copy];
|
||||
if(responseCode == 200)
|
||||
statusString = @"OK";
|
||||
|
||||
/*The individual values of the numeric status codes defined for HTTP/1.1
|
||||
| “200” ; OK
|
||||
| “201” ; Created
|
||||
| “202” ; Accepted
|
||||
| “203” ; Non-Authoritative Information
|
||||
| “204” ; No Content
|
||||
| “205” ; Reset Content
|
||||
| “206” ; Partial Content
|
||||
*/
|
||||
if (responseCode >= 200 && responseCode < 300)
|
||||
{// something went wrong, abort the whole thing
|
||||
|
||||
[connection cancel];
|
||||
|
|
|
@ -187,9 +187,13 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream
|
|||
}
|
||||
}
|
||||
|
||||
NSString* requestData = [NSString stringWithUTF8String:request->getRequestData()];
|
||||
NSData *postData = [requestData dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[nsrequest setHTTPBody:postData];
|
||||
char* requestDataBuffer = request->getRequestData();
|
||||
if (nullptr != requestDataBuffer && 0 != strlen(requestDataBuffer))
|
||||
{
|
||||
NSString* requestData = [NSString stringWithUTF8String:requestDataBuffer];
|
||||
NSData *postData = [requestData dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[nsrequest setHTTPBody:postData];
|
||||
}
|
||||
}
|
||||
|
||||
//read cookie propertities from file and set cookie
|
||||
|
@ -275,6 +279,7 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream
|
|||
|
||||
//handle response header
|
||||
NSMutableString *header = [NSMutableString new];
|
||||
[header appendFormat:@"HTTP/1.1 %ld %@\n", httpAsynConn.responseCode, httpAsynConn.statusString];
|
||||
for (id key in httpAsynConn.responseHeader)
|
||||
{
|
||||
[header appendFormat:@"%@: %@\n", key, [httpAsynConn.responseHeader objectForKey:key]];
|
||||
|
|
|
@ -31,16 +31,10 @@
|
|||
#include "chipmunk.h"
|
||||
|
||||
#include "2d/CCScene.h"
|
||||
|
||||
#include "physics/CCPhysicsShape.h"
|
||||
#include "physics/CCPhysicsJoint.h"
|
||||
#include "physics/CCPhysicsWorld.h"
|
||||
|
||||
#include "chipmunk/CCPhysicsBodyInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsJointInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsWorldInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsShapeInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsHelper_chipmunk.h"
|
||||
#include "CCPhysicsShape.h"
|
||||
#include "CCPhysicsJoint.h"
|
||||
#include "CCPhysicsWorld.h"
|
||||
#include "CCPhysicsHelper.h"
|
||||
|
||||
static inline void cpBodyUpdateVelocityWithoutGravity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt)
|
||||
{
|
||||
|
@ -59,7 +53,7 @@ namespace
|
|||
PhysicsBody::PhysicsBody()
|
||||
: _node(nullptr)
|
||||
, _world(nullptr)
|
||||
, _info(nullptr)
|
||||
, _cpBody(nullptr)
|
||||
, _dynamic(true)
|
||||
, _enabled(true)
|
||||
, _rotationEnabled(true)
|
||||
|
@ -74,9 +68,10 @@ PhysicsBody::PhysicsBody()
|
|||
, _linearDamping(0.0f)
|
||||
, _angularDamping(0.0f)
|
||||
, _tag(0)
|
||||
, _positionResetTag(false)
|
||||
, _rotationResetTag(false)
|
||||
, _rotationOffset(0)
|
||||
, _recordedPosition(Vec2::ZERO)
|
||||
, _recordedRotation(0.0f)
|
||||
, _recordedAngle(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -91,7 +86,10 @@ PhysicsBody::~PhysicsBody()
|
|||
delete joint;
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE(_info);
|
||||
if (_cpBody)
|
||||
{
|
||||
cpBodyFree(_cpBody);
|
||||
}
|
||||
}
|
||||
|
||||
PhysicsBody* PhysicsBody::create()
|
||||
|
@ -255,12 +253,9 @@ bool PhysicsBody::init()
|
|||
{
|
||||
do
|
||||
{
|
||||
_info = new (std::nothrow) PhysicsBodyInfo();
|
||||
CC_BREAK_IF(_info == nullptr);
|
||||
_cpBody = cpBodyNew(PhysicsHelper::float2cpfloat(_mass), PhysicsHelper::float2cpfloat(_moment));
|
||||
|
||||
_info->setBody(cpBodyNew(PhysicsHelper::float2cpfloat(_mass), PhysicsHelper::float2cpfloat(_moment)));
|
||||
|
||||
CC_BREAK_IF(_info->getBody() == nullptr);
|
||||
CC_BREAK_IF(_cpBody == nullptr);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
@ -283,33 +278,32 @@ void PhysicsBody::setDynamic(bool dynamic)
|
|||
if (dynamic != _dynamic)
|
||||
{
|
||||
_dynamic = dynamic;
|
||||
auto body = _info->getBody();
|
||||
if (dynamic)
|
||||
{
|
||||
if (_world && body->CP_PRIVATE(space))
|
||||
if (_world && _cpBody->CP_PRIVATE(space))
|
||||
{
|
||||
cpSpaceConvertBodyToDynamic(_world->_info->getSpace(), body, _mass, _moment);
|
||||
cpSpaceAddBody(_world->_info->getSpace(), body);
|
||||
cpSpaceConvertBodyToDynamic(_world->_cpSpace, _cpBody, _mass, _moment);
|
||||
cpSpaceAddBody(_world->_cpSpace, _cpBody);
|
||||
}
|
||||
else
|
||||
{
|
||||
cpBodySetMass(body, _mass);
|
||||
cpBodySetMoment(body, _moment);
|
||||
body->CP_PRIVATE(node).idleTime = 0.0f;
|
||||
cpBodySetMass(_cpBody, _mass);
|
||||
cpBodySetMoment(_cpBody, _moment);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_world && body->CP_PRIVATE(space))
|
||||
if (_world && _cpBody->CP_PRIVATE(space))
|
||||
{
|
||||
cpSpaceRemoveBody(_world->_info->getSpace(), body);
|
||||
cpSpaceConvertBodyToStatic(_world->_info->getSpace(), body);
|
||||
cpSpaceRemoveBody(_world->_cpSpace, _cpBody);
|
||||
cpSpaceConvertBodyToStatic(_world->_cpSpace, _cpBody);
|
||||
}
|
||||
else
|
||||
{
|
||||
cpBodySetMass(body, PHYSICS_INFINITY);
|
||||
cpBodySetMoment(body, PHYSICS_INFINITY);
|
||||
body->CP_PRIVATE(node).idleTime = (cpFloat)INFINITY;
|
||||
cpBodySetMass(_cpBody, PHYSICS_INFINITY);
|
||||
cpBodySetMoment(_cpBody, PHYSICS_INFINITY);
|
||||
cpBodySetVel(_cpBody, cpvzero);
|
||||
cpBodySetAngVel(_cpBody, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -319,7 +313,7 @@ void PhysicsBody::setRotationEnable(bool enable)
|
|||
{
|
||||
if (_rotationEnabled != enable)
|
||||
{
|
||||
cpBodySetMoment(_info->getBody(), enable ? _moment : PHYSICS_INFINITY);
|
||||
cpBodySetMoment(_cpBody, enable ? _moment : PHYSICS_INFINITY);
|
||||
_rotationEnabled = enable;
|
||||
}
|
||||
}
|
||||
|
@ -330,30 +324,25 @@ void PhysicsBody::setGravityEnable(bool enable)
|
|||
|
||||
if (enable)
|
||||
{
|
||||
_info->getBody()->velocity_func = cpBodyUpdateVelocity;
|
||||
_cpBody->velocity_func = cpBodyUpdateVelocity;
|
||||
}
|
||||
else
|
||||
{
|
||||
_info->getBody()->velocity_func = cpBodyUpdateVelocityWithoutGravity;
|
||||
_cpBody->velocity_func = cpBodyUpdateVelocityWithoutGravity;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsBody::setPosition(const Vec2& position)
|
||||
{
|
||||
cpBodySetPos(_info->getBody(), PhysicsHelper::point2cpv(position + _positionOffset));
|
||||
_recordedPosition = position;
|
||||
cpBodySetPos(_cpBody, PhysicsHelper::point2cpv(position + _positionOffset));
|
||||
}
|
||||
|
||||
void PhysicsBody::setRotation(float rotation)
|
||||
{
|
||||
cpBodySetAngle(_info->getBody(), -PhysicsHelper::float2cpfloat((rotation + _rotationOffset) * (M_PI / 180.0f)));
|
||||
}
|
||||
|
||||
void PhysicsBody::setScale(float scale)
|
||||
{
|
||||
for (auto shape : _shapes)
|
||||
{
|
||||
shape->setScale(scale);
|
||||
}
|
||||
_recordedRotation = rotation;
|
||||
_recordedAngle = - (rotation + _rotationOffset) * (M_PI / 180.0);
|
||||
cpBodySetAngle(_cpBody, _recordedAngle);
|
||||
}
|
||||
|
||||
void PhysicsBody::setScale(float scaleX, float scaleY)
|
||||
|
@ -364,31 +353,21 @@ void PhysicsBody::setScale(float scaleX, float scaleY)
|
|||
}
|
||||
}
|
||||
|
||||
void PhysicsBody::setScaleX(float scaleX)
|
||||
const Vec2& PhysicsBody::getPosition()
|
||||
{
|
||||
for (auto shape : _shapes)
|
||||
{
|
||||
shape->setScaleX(scaleX);
|
||||
_latestPosition.x = _cpBody->p.x - _positionOffset.x;
|
||||
_latestPosition.y = _cpBody->p.y - _positionOffset.y;
|
||||
|
||||
return _latestPosition;
|
||||
}
|
||||
|
||||
float PhysicsBody::getRotation()
|
||||
{
|
||||
if (_recordedAngle != cpBodyGetAngle(_cpBody)) {
|
||||
_recordedAngle = cpBodyGetAngle(_cpBody);
|
||||
_recordedRotation = - _recordedAngle * 180.0 / M_PI - _rotationOffset;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsBody::setScaleY(float scaleY)
|
||||
{
|
||||
for (auto shape : _shapes)
|
||||
{
|
||||
shape->setScaleY(scaleY);
|
||||
}
|
||||
}
|
||||
|
||||
Vec2 PhysicsBody::getPosition() const
|
||||
{
|
||||
cpVect vec = cpBodyGetPos(_info->getBody());
|
||||
return PhysicsHelper::cpv2point(vec) - _positionOffset;
|
||||
}
|
||||
|
||||
float PhysicsBody::getRotation() const
|
||||
{
|
||||
return -PhysicsHelper::cpfloat2float(cpBodyGetAngle(_info->getBody()) * (180.0f / M_PI)) - _rotationOffset;
|
||||
return _recordedRotation;
|
||||
}
|
||||
|
||||
PhysicsShape* PhysicsBody::addShape(PhysicsShape* shape, bool addMassAndMoment/* = true*/)
|
||||
|
@ -409,7 +388,7 @@ PhysicsShape* PhysicsBody::addShape(PhysicsShape* shape, bool addMassAndMoment/*
|
|||
addMoment(shape->getMoment());
|
||||
}
|
||||
|
||||
if (_world != nullptr)
|
||||
if (_world && _cpBody->CP_PRIVATE(space))
|
||||
{
|
||||
_world->addShape(shape);
|
||||
}
|
||||
|
@ -429,13 +408,13 @@ void PhysicsBody::applyForce(const Vect& force, const Vec2& offset)
|
|||
{
|
||||
if (_dynamic && _mass != PHYSICS_INFINITY)
|
||||
{
|
||||
cpBodyApplyForce(_info->getBody(), PhysicsHelper::point2cpv(force), PhysicsHelper::point2cpv(offset));
|
||||
cpBodyApplyForce(_cpBody, PhysicsHelper::point2cpv(force), PhysicsHelper::point2cpv(offset));
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsBody::resetForces()
|
||||
{
|
||||
cpBodyResetForces(_info->getBody());
|
||||
cpBodyResetForces(_cpBody);
|
||||
}
|
||||
|
||||
void PhysicsBody::applyImpulse(const Vect& impulse)
|
||||
|
@ -445,12 +424,12 @@ void PhysicsBody::applyImpulse(const Vect& impulse)
|
|||
|
||||
void PhysicsBody::applyImpulse(const Vect& impulse, const Vec2& offset)
|
||||
{
|
||||
cpBodyApplyImpulse(_info->getBody(), PhysicsHelper::point2cpv(impulse), PhysicsHelper::point2cpv(offset));
|
||||
cpBodyApplyImpulse(_cpBody, PhysicsHelper::point2cpv(impulse), PhysicsHelper::point2cpv(offset));
|
||||
}
|
||||
|
||||
void PhysicsBody::applyTorque(float torque)
|
||||
{
|
||||
cpBodySetTorque(_info->getBody(), PhysicsHelper::float2cpfloat(torque));
|
||||
cpBodySetTorque(_cpBody, PhysicsHelper::float2cpfloat(torque));
|
||||
}
|
||||
|
||||
void PhysicsBody::setMass(float mass)
|
||||
|
@ -481,7 +460,7 @@ void PhysicsBody::setMass(float mass)
|
|||
// the static body's mass and moment is always infinity
|
||||
if (_dynamic)
|
||||
{
|
||||
cpBodySetMass(_info->getBody(), _mass);
|
||||
cpBodySetMass(_cpBody, _mass);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,7 +506,7 @@ void PhysicsBody::addMass(float mass)
|
|||
// the static body's mass and moment is always infinity
|
||||
if (_dynamic)
|
||||
{
|
||||
cpBodySetMass(_info->getBody(), _mass);
|
||||
cpBodySetMass(_cpBody, _mass);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -569,7 +548,7 @@ void PhysicsBody::addMoment(float moment)
|
|||
// the static body's mass and moment is always infinity
|
||||
if (_rotationEnabled && _dynamic)
|
||||
{
|
||||
cpBodySetMoment(_info->getBody(), PhysicsHelper::float2cpfloat(_moment));
|
||||
cpBodySetMoment(_cpBody, PhysicsHelper::float2cpfloat(_moment));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -581,22 +560,22 @@ void PhysicsBody::setVelocity(const Vec2& velocity)
|
|||
return;
|
||||
}
|
||||
|
||||
cpBodySetVel(_info->getBody(), PhysicsHelper::point2cpv(velocity));
|
||||
cpBodySetVel(_cpBody, PhysicsHelper::point2cpv(velocity));
|
||||
}
|
||||
|
||||
Vec2 PhysicsBody::getVelocity()
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpBodyGetVel(_info->getBody()));
|
||||
return PhysicsHelper::cpv2point(cpBodyGetVel(_cpBody));
|
||||
}
|
||||
|
||||
Vec2 PhysicsBody::getVelocityAtLocalPoint(const Vec2& point)
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpBodyGetVelAtLocalPoint(_info->getBody(), PhysicsHelper::point2cpv(point)));
|
||||
return PhysicsHelper::cpv2point(cpBodyGetVelAtLocalPoint(_cpBody, PhysicsHelper::point2cpv(point)));
|
||||
}
|
||||
|
||||
Vec2 PhysicsBody::getVelocityAtWorldPoint(const Vec2& point)
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpBodyGetVelAtWorldPoint(_info->getBody(), PhysicsHelper::point2cpv(point)));
|
||||
return PhysicsHelper::cpv2point(cpBodyGetVelAtWorldPoint(_cpBody, PhysicsHelper::point2cpv(point)));
|
||||
}
|
||||
|
||||
void PhysicsBody::setAngularVelocity(float velocity)
|
||||
|
@ -607,32 +586,32 @@ void PhysicsBody::setAngularVelocity(float velocity)
|
|||
return;
|
||||
}
|
||||
|
||||
cpBodySetAngVel(_info->getBody(), PhysicsHelper::float2cpfloat(velocity));
|
||||
cpBodySetAngVel(_cpBody, PhysicsHelper::float2cpfloat(velocity));
|
||||
}
|
||||
|
||||
float PhysicsBody::getAngularVelocity()
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpBodyGetAngVel(_info->getBody()));
|
||||
return PhysicsHelper::cpfloat2float(cpBodyGetAngVel(_cpBody));
|
||||
}
|
||||
|
||||
void PhysicsBody::setVelocityLimit(float limit)
|
||||
{
|
||||
cpBodySetVelLimit(_info->getBody(), PhysicsHelper::float2cpfloat(limit));
|
||||
cpBodySetVelLimit(_cpBody, PhysicsHelper::float2cpfloat(limit));
|
||||
}
|
||||
|
||||
float PhysicsBody::getVelocityLimit()
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpBodyGetVelLimit(_info->getBody()));
|
||||
return PhysicsHelper::cpfloat2float(cpBodyGetVelLimit(_cpBody));
|
||||
}
|
||||
|
||||
void PhysicsBody::setAngularVelocityLimit(float limit)
|
||||
{
|
||||
cpBodySetAngVelLimit(_info->getBody(), PhysicsHelper::float2cpfloat(limit));
|
||||
cpBodySetAngVelLimit(_cpBody, PhysicsHelper::float2cpfloat(limit));
|
||||
}
|
||||
|
||||
float PhysicsBody::getAngularVelocityLimit()
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpBodyGetAngVelLimit(_info->getBody()));
|
||||
return PhysicsHelper::cpfloat2float(cpBodyGetAngVelLimit(_cpBody));
|
||||
}
|
||||
|
||||
void PhysicsBody::setMoment(float moment)
|
||||
|
@ -643,7 +622,7 @@ void PhysicsBody::setMoment(float moment)
|
|||
// the static body's mass and moment is always infinity
|
||||
if (_rotationEnabled && _dynamic)
|
||||
{
|
||||
cpBodySetMoment(_info->getBody(), PhysicsHelper::float2cpfloat(_moment));
|
||||
cpBodySetMoment(_cpBody, PhysicsHelper::float2cpfloat(_moment));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -755,52 +734,30 @@ void PhysicsBody::setEnable(bool enable)
|
|||
|
||||
bool PhysicsBody::isResting() const
|
||||
{
|
||||
return CP_PRIVATE(_info->getBody()->node).root != ((cpBody*)0);
|
||||
return CP_PRIVATE(_cpBody->node).root != ((cpBody*)0);
|
||||
}
|
||||
|
||||
void PhysicsBody::setResting(bool rest) const
|
||||
{
|
||||
if (rest && !isResting())
|
||||
{
|
||||
cpBodySleep(_info->getBody());
|
||||
cpBodySleep(_cpBody);
|
||||
}else if(!rest && isResting())
|
||||
{
|
||||
cpBodyActivate(_info->getBody());
|
||||
cpBodyActivate(_cpBody);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsBody::update(float delta)
|
||||
{
|
||||
if (_node != nullptr)
|
||||
if (_node)
|
||||
{
|
||||
for (auto shape : _shapes)
|
||||
{
|
||||
shape->update(delta);
|
||||
}
|
||||
|
||||
Node* parent = _node->getParent();
|
||||
Node* scene = &_world->getScene();
|
||||
|
||||
Vec2 position = parent != scene ? parent->convertToNodeSpace(scene->convertToWorldSpace(getPosition())) : getPosition();
|
||||
float rotation = getRotation();
|
||||
for (; parent != scene; parent = parent->getParent())
|
||||
{
|
||||
rotation -= parent->getRotation();
|
||||
}
|
||||
|
||||
_positionResetTag = true;
|
||||
_rotationResetTag = true;
|
||||
_node->setPosition(position);
|
||||
_node->setRotation(rotation);
|
||||
_positionResetTag = false;
|
||||
_rotationResetTag = false;
|
||||
|
||||
// damping compute
|
||||
if (_isDamping && _dynamic && !isResting())
|
||||
{
|
||||
_info->getBody()->v.x *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f);
|
||||
_info->getBody()->v.y *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f);
|
||||
_info->getBody()->w *= cpfclamp(1.0f - delta * _angularDamping, 0.0f, 1.0f);
|
||||
_cpBody->v.x *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f);
|
||||
_cpBody->v.y *= cpfclamp(1.0f - delta * _linearDamping, 0.0f, 1.0f);
|
||||
_cpBody->w *= cpfclamp(1.0f - delta * _angularDamping, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -895,11 +852,6 @@ void PhysicsBody::setPositionOffset(const Vec2& position)
|
|||
}
|
||||
}
|
||||
|
||||
Vec2 PhysicsBody::getPositionOffset() const
|
||||
{
|
||||
return _positionOffset;
|
||||
}
|
||||
|
||||
void PhysicsBody::setRotationOffset(float rotation)
|
||||
{
|
||||
if (std::abs(_rotationOffset - rotation) > 0.5f)
|
||||
|
@ -910,19 +862,14 @@ void PhysicsBody::setRotationOffset(float rotation)
|
|||
}
|
||||
}
|
||||
|
||||
float PhysicsBody::getRotationOffset() const
|
||||
{
|
||||
return _rotationOffset;
|
||||
}
|
||||
|
||||
Vec2 PhysicsBody::world2Local(const Vec2& point)
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpBodyWorld2Local(_info->getBody(), PhysicsHelper::point2cpv(point)));
|
||||
return PhysicsHelper::cpv2point(cpBodyWorld2Local(_cpBody, PhysicsHelper::point2cpv(point)));
|
||||
}
|
||||
|
||||
Vec2 PhysicsBody::local2World(const Vec2& point)
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpBodyLocal2World(_info->getBody(), PhysicsHelper::point2cpv(point)));
|
||||
return PhysicsHelper::cpv2point(cpBodyLocal2World(_cpBody, PhysicsHelper::point2cpv(point)));
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -33,13 +33,14 @@
|
|||
#include "physics/CCPhysicsShape.h"
|
||||
#include "base/CCVector.h"
|
||||
|
||||
struct cpBody;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Node;
|
||||
class Sprite;
|
||||
class PhysicsWorld;
|
||||
class PhysicsJoint;
|
||||
class PhysicsBodyInfo;
|
||||
|
||||
typedef Vec2 Vect;
|
||||
|
||||
|
@ -188,18 +189,18 @@ public:
|
|||
int getGroup() const;
|
||||
|
||||
/** get the body position. */
|
||||
Vec2 getPosition() const;
|
||||
const Vec2& getPosition();
|
||||
/** get the body rotation. */
|
||||
float getRotation() const;
|
||||
float getRotation();
|
||||
|
||||
/** set body position offset, it's the position witch relative to node */
|
||||
void setPositionOffset(const Vec2& position);
|
||||
/** get body position offset. */
|
||||
Vec2 getPositionOffset() const;
|
||||
const Vec2& getPositionOffset() const { return _positionOffset; }
|
||||
/** set body rotation offset, it's the rotation witch relative to node */
|
||||
void setRotationOffset(float rotation);
|
||||
/** set the body rotation offset */
|
||||
float getRotationOffset() const;
|
||||
float getRotationOffset() const { return _rotationOffset; }
|
||||
|
||||
/**
|
||||
* @brief test the body is dynamic or not.
|
||||
|
@ -296,6 +297,8 @@ public:
|
|||
Vec2 world2Local(const Vec2& point);
|
||||
/** convert the local point to world */
|
||||
Vec2 local2World(const Vec2& point);
|
||||
|
||||
cpBody* getCPBody() { return _cpBody; }
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -303,10 +306,7 @@ protected:
|
|||
|
||||
virtual void setPosition(const Vec2& position);
|
||||
virtual void setRotation(float rotation);
|
||||
virtual void setScale(float scale);
|
||||
virtual void setScale(float scaleX, float scaleY);
|
||||
virtual void setScaleX(float scaleX);
|
||||
virtual void setScaleY(float scaleY);
|
||||
|
||||
void update(float delta);
|
||||
|
||||
|
@ -322,7 +322,7 @@ protected:
|
|||
std::vector<PhysicsJoint*> _joints;
|
||||
Vector<PhysicsShape*> _shapes;
|
||||
PhysicsWorld* _world;
|
||||
PhysicsBodyInfo* _info;
|
||||
cpBody* _cpBody;
|
||||
bool _dynamic;
|
||||
bool _enabled;
|
||||
bool _rotationEnabled;
|
||||
|
@ -338,10 +338,12 @@ protected:
|
|||
float _angularDamping;
|
||||
int _tag;
|
||||
|
||||
bool _positionResetTag; /// To avoid reset the body position when body invoke Node::setPosition().
|
||||
bool _rotationResetTag; /// To avoid reset the body rotation when body invoke Node::setRotation().
|
||||
Vec2 _recordedPosition;
|
||||
Vec2 _latestPosition;
|
||||
Vec2 _positionOffset;
|
||||
float _rotationOffset;
|
||||
float _recordedRotation;
|
||||
double _recordedAngle;
|
||||
|
||||
friend class PhysicsWorld;
|
||||
friend class PhysicsShape;
|
||||
|
|
|
@ -25,11 +25,8 @@
|
|||
#if CC_USE_PHYSICS
|
||||
#include "chipmunk.h"
|
||||
|
||||
#include "physics/CCPhysicsBody.h"
|
||||
|
||||
#include "chipmunk/CCPhysicsContactInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsHelper_chipmunk.h"
|
||||
|
||||
#include "CCPhysicsBody.h"
|
||||
#include "CCPhysicsHelper.h"
|
||||
#include "base/CCEventCustom.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
@ -42,7 +39,6 @@ PhysicsContact::PhysicsContact()
|
|||
, _shapeA(nullptr)
|
||||
, _shapeB(nullptr)
|
||||
, _eventCode(EventCode::NONE)
|
||||
, _info(nullptr)
|
||||
, _notificationEnable(true)
|
||||
, _result(true)
|
||||
, _data(nullptr)
|
||||
|
@ -55,7 +51,6 @@ PhysicsContact::PhysicsContact()
|
|||
|
||||
PhysicsContact::~PhysicsContact()
|
||||
{
|
||||
CC_SAFE_DELETE(_info);
|
||||
CC_SAFE_DELETE(_contactData);
|
||||
CC_SAFE_DELETE(_preContactData);
|
||||
}
|
||||
|
@ -78,8 +73,6 @@ bool PhysicsContact::init(PhysicsShape* a, PhysicsShape* b)
|
|||
{
|
||||
CC_BREAK_IF(a == nullptr || b == nullptr);
|
||||
|
||||
CC_BREAK_IF(!(_info = new (std::nothrow) PhysicsContactInfo(this)));
|
||||
|
||||
_shapeA = a;
|
||||
_shapeB = b;
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ class PhysicsShape;
|
|||
class PhysicsBody;
|
||||
class PhysicsWorld;
|
||||
|
||||
class PhysicsContactInfo;
|
||||
|
||||
typedef Vec2 Vect;
|
||||
|
||||
typedef struct CC_DLL PhysicsContactData
|
||||
|
@ -112,7 +110,6 @@ private:
|
|||
PhysicsShape* _shapeA;
|
||||
PhysicsShape* _shapeB;
|
||||
EventCode _eventCode;
|
||||
PhysicsContactInfo* _info;
|
||||
bool _notificationEnable;
|
||||
bool _result;
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCPHYSICS_HELPER_CHIPMUNK_H__
|
||||
#define __CCPHYSICS_HELPER_CHIPMUNK_H__
|
||||
#ifndef __CCPHYSICS_HELPER_H__
|
||||
#define __CCPHYSICS_HELPER_H__
|
||||
|
||||
#include "base/ccConfig.h"
|
||||
#if CC_USE_PHYSICS
|
||||
|
@ -70,4 +70,4 @@ public:
|
|||
NS_CC_END
|
||||
|
||||
#endif // CC_USE_PHYSICS
|
||||
#endif // __CCPHYSICS_HELPER_CHIPMUNK_H__
|
||||
#endif // __CCPHYSICS_HELPER_H__
|
File diff suppressed because it is too large
Load Diff
|
@ -31,13 +31,13 @@
|
|||
#include "base/CCRef.h"
|
||||
#include "math/CCGeometry.h"
|
||||
|
||||
struct cpConstraint;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Node;
|
||||
class PhysicsBody;
|
||||
class PhysicsWorld;
|
||||
class PhysicsJointInfo;
|
||||
class PhysicsBodyInfo;
|
||||
|
||||
/*
|
||||
* @brief An PhysicsJoint object connects two physics bodies together.
|
||||
|
@ -62,63 +62,62 @@ public:
|
|||
void setCollisionEnable(bool enable);
|
||||
/** Remove the joint from the world */
|
||||
void removeFormWorld();
|
||||
/** Distory the joint*/
|
||||
static void destroy(PhysicsJoint* joint);
|
||||
|
||||
|
||||
/** Set the max force between two bodies */
|
||||
void setMaxForce(float force);
|
||||
/** Get the max force setting */
|
||||
float getMaxForce() const;
|
||||
|
||||
float getMaxForce() const { return _maxForce; }
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b);
|
||||
|
||||
/**
|
||||
* PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. so this method is use for subclasses to catch the bodyInfo from PhysicsBody.
|
||||
*/
|
||||
PhysicsBodyInfo* getBodyInfo(PhysicsBody* body) const;
|
||||
Node* getBodyNode(PhysicsBody* body) const;
|
||||
|
||||
protected:
|
||||
|
||||
bool initJoint();
|
||||
virtual bool createConstraints() { return false; }
|
||||
|
||||
std::vector<cpConstraint*> _cpConstraints;
|
||||
PhysicsBody* _bodyA;
|
||||
PhysicsBody* _bodyB;
|
||||
PhysicsWorld* _world;
|
||||
PhysicsJointInfo* _info;
|
||||
|
||||
bool _enable;
|
||||
bool _collisionEnable;
|
||||
bool _destoryMark;
|
||||
int _tag;
|
||||
|
||||
float _maxForce;
|
||||
|
||||
bool _initDirty;
|
||||
|
||||
friend class PhysicsBody;
|
||||
friend class PhysicsWorld;
|
||||
friend class PhysicsDebugDraw;
|
||||
};
|
||||
|
||||
/*
|
||||
* @brief A fixed joint fuses the two bodies together at a reference point. Fixed joints are useful for creating complex shapes that can be broken apart later.
|
||||
*/
|
||||
* @brief A fixed joint fuses the two bodies together at a reference point. Fixed joints are useful for creating complex shapes that can be broken apart later.
|
||||
*/
|
||||
class CC_DLL PhysicsJointFixed : public PhysicsJoint
|
||||
{
|
||||
public:
|
||||
static PhysicsJointFixed* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr);
|
||||
|
||||
|
||||
virtual bool createConstraints() override;
|
||||
|
||||
protected:
|
||||
PhysicsJointFixed() {}
|
||||
virtual ~PhysicsJointFixed() {}
|
||||
|
||||
Vec2 _anchr;
|
||||
};
|
||||
|
||||
/*
|
||||
* @brief A limit joint imposes a maximum distance between the two bodies, as if they were connected by a rope.
|
||||
*/
|
||||
* @brief A limit joint imposes a maximum distance between the two bodies, as if they were connected by a rope.
|
||||
*/
|
||||
class CC_DLL PhysicsJointLimit : public PhysicsJoint
|
||||
{
|
||||
public:
|
||||
static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2);
|
||||
static PhysicsJointLimit* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float min, float max);
|
||||
|
||||
|
||||
Vec2 getAnchr1() const;
|
||||
void setAnchr1(const Vec2& anchr1);
|
||||
Vec2 getAnchr2() const;
|
||||
|
@ -127,29 +126,37 @@ public:
|
|||
void setMin(float min);
|
||||
float getMax() const;
|
||||
void setMax(float max);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float min, float max);
|
||||
|
||||
|
||||
virtual bool createConstraints() override;
|
||||
|
||||
protected:
|
||||
PhysicsJointLimit() {}
|
||||
virtual ~PhysicsJointLimit() {}
|
||||
|
||||
Vec2 _anchr1;
|
||||
Vec2 _anchr2;
|
||||
float _min;
|
||||
float _max;
|
||||
};
|
||||
|
||||
/*
|
||||
* @brief A pin joint allows the two bodies to independently rotate around the anchor point as if pinned together.
|
||||
*/
|
||||
* @brief A pin joint allows the two bodies to independently rotate around the anchor point as if pinned together.
|
||||
*/
|
||||
class CC_DLL PhysicsJointPin : public PhysicsJoint
|
||||
{
|
||||
public:
|
||||
static PhysicsJointPin* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr);
|
||||
|
||||
static PhysicsJointPin* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& pivot);
|
||||
static PhysicsJointPin* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2);
|
||||
|
||||
virtual bool createConstraints() override;
|
||||
|
||||
protected:
|
||||
PhysicsJointPin() {}
|
||||
virtual ~PhysicsJointPin() {}
|
||||
|
||||
bool _useSpecificAnchr;
|
||||
Vec2 _anchr1;
|
||||
Vec2 _anchr2;
|
||||
};
|
||||
|
||||
/** Set the fixed distance with two bodies */
|
||||
|
@ -157,16 +164,17 @@ class CC_DLL PhysicsJointDistance : public PhysicsJoint
|
|||
{
|
||||
public:
|
||||
static PhysicsJointDistance* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2);
|
||||
|
||||
|
||||
float getDistance() const;
|
||||
void setDistance(float distance);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2);
|
||||
|
||||
virtual bool createConstraints() override;
|
||||
|
||||
protected:
|
||||
PhysicsJointDistance() {}
|
||||
virtual ~PhysicsJointDistance() {}
|
||||
|
||||
Vec2 _anchr1;
|
||||
Vec2 _anchr2;
|
||||
};
|
||||
|
||||
/** Connecting two physics bodies together with a spring. */
|
||||
|
@ -184,13 +192,16 @@ public:
|
|||
void setStiffness(float stiffness);
|
||||
float getDamping() const;
|
||||
void setDamping(float damping);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& anchr1, const Vec2& anchr2, float stiffness, float damping);
|
||||
|
||||
virtual bool createConstraints() override;
|
||||
|
||||
protected:
|
||||
PhysicsJointSpring() {}
|
||||
virtual ~PhysicsJointSpring() {}
|
||||
|
||||
Vec2 _anchr1;
|
||||
Vec2 _anchr2;
|
||||
float _stiffness;
|
||||
float _damping;
|
||||
};
|
||||
|
||||
/** Attach body a to a line, and attach body b to a dot */
|
||||
|
@ -198,20 +209,22 @@ class CC_DLL PhysicsJointGroove : public PhysicsJoint
|
|||
{
|
||||
public:
|
||||
static PhysicsJointGroove* construct(PhysicsBody* a, PhysicsBody* b, const Vec2& grooveA, const Vec2& grooveB, const Vec2& anchr2);
|
||||
|
||||
|
||||
Vec2 getGrooveA() const;
|
||||
void setGrooveA(const Vec2& grooveA);
|
||||
Vec2 getGrooveB() const;
|
||||
void setGrooveB(const Vec2& grooveB);
|
||||
Vec2 getAnchr2() const;
|
||||
void setAnchr2(const Vec2& anchr2);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, const Vec2& grooveA, const Vec2& grooveB, const Vec2& anchr);
|
||||
|
||||
virtual bool createConstraints() override;
|
||||
|
||||
protected:
|
||||
PhysicsJointGroove() {}
|
||||
virtual ~PhysicsJointGroove() {}
|
||||
|
||||
Vec2 _grooveA;
|
||||
Vec2 _grooveB;
|
||||
Vec2 _anchr2;
|
||||
};
|
||||
|
||||
/** Likes a spring joint, but works with rotary */
|
||||
|
@ -219,20 +232,21 @@ class CC_DLL PhysicsJointRotarySpring : public PhysicsJoint
|
|||
{
|
||||
public:
|
||||
static PhysicsJointRotarySpring* construct(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping);
|
||||
|
||||
|
||||
float getRestAngle() const;
|
||||
void setRestAngle(float restAngle);
|
||||
float getStiffness() const;
|
||||
void setStiffness(float stiffness);
|
||||
float getDamping() const;
|
||||
void setDamping(float damping);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, float stiffness, float damping);
|
||||
|
||||
virtual bool createConstraints() override;
|
||||
|
||||
protected:
|
||||
PhysicsJointRotarySpring() {}
|
||||
virtual ~PhysicsJointRotarySpring() {}
|
||||
|
||||
float _stiffness;
|
||||
float _damping;
|
||||
};
|
||||
|
||||
/** Likes a limit joint, but works with rotary */
|
||||
|
@ -241,18 +255,19 @@ class CC_DLL PhysicsJointRotaryLimit : public PhysicsJoint
|
|||
public:
|
||||
static PhysicsJointRotaryLimit* construct(PhysicsBody* a, PhysicsBody* b, float min, float max);
|
||||
static PhysicsJointRotaryLimit* construct(PhysicsBody* a, PhysicsBody* b);
|
||||
|
||||
|
||||
float getMin() const;
|
||||
void setMin(float min);
|
||||
float getMax() const;
|
||||
void setMax(float max);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, float min, float max);
|
||||
|
||||
virtual bool createConstraints() override;
|
||||
|
||||
protected:
|
||||
PhysicsJointRotaryLimit() {}
|
||||
virtual ~PhysicsJointRotaryLimit() {}
|
||||
|
||||
float _min;
|
||||
float _max;
|
||||
};
|
||||
|
||||
/** Works like a socket wrench. */
|
||||
|
@ -260,20 +275,21 @@ class CC_DLL PhysicsJointRatchet : public PhysicsJoint
|
|||
{
|
||||
public:
|
||||
static PhysicsJointRatchet* construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet);
|
||||
|
||||
|
||||
float getAngle() const;
|
||||
void setAngle(float angle);
|
||||
float getPhase() const;
|
||||
void setPhase(float phase);
|
||||
float getRatchet() const;
|
||||
void setRatchet(float ratchet);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, float phase, float ratchet);
|
||||
|
||||
virtual bool createConstraints() override;
|
||||
|
||||
protected:
|
||||
PhysicsJointRatchet() {}
|
||||
virtual ~PhysicsJointRatchet() {}
|
||||
|
||||
float _phase;
|
||||
float _ratchet;
|
||||
};
|
||||
|
||||
/** Keeps the angular velocity ratio of a pair of bodies constant. */
|
||||
|
@ -281,18 +297,20 @@ class CC_DLL PhysicsJointGear : public PhysicsJoint
|
|||
{
|
||||
public:
|
||||
static PhysicsJointGear* construct(PhysicsBody* a, PhysicsBody* b, float phase, float ratio);
|
||||
|
||||
|
||||
float getPhase() const;
|
||||
void setPhase(float phase);
|
||||
float getRatio() const;
|
||||
void setRatio(float ratchet);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, float phase, float ratio);
|
||||
|
||||
|
||||
virtual bool createConstraints() override;
|
||||
|
||||
protected:
|
||||
PhysicsJointGear() {}
|
||||
virtual ~PhysicsJointGear() {}
|
||||
|
||||
float _phase;
|
||||
float _ratio;
|
||||
};
|
||||
|
||||
/** Keeps the relative angular velocity of a pair of bodies constant */
|
||||
|
@ -300,16 +318,16 @@ class CC_DLL PhysicsJointMotor : public PhysicsJoint
|
|||
{
|
||||
public:
|
||||
static PhysicsJointMotor* construct(PhysicsBody* a, PhysicsBody* b, float rate);
|
||||
|
||||
|
||||
float getRate() const;
|
||||
void setRate(float rate);
|
||||
|
||||
protected:
|
||||
bool init(PhysicsBody* a, PhysicsBody* b, float rate);
|
||||
|
||||
virtual bool createConstraints() override;
|
||||
|
||||
protected:
|
||||
PhysicsJointMotor() {}
|
||||
virtual ~PhysicsJointMotor() {}
|
||||
|
||||
float _rate;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -26,23 +26,22 @@
|
|||
#if CC_USE_PHYSICS
|
||||
|
||||
#include <climits>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "chipmunk.h"
|
||||
#include "chipmunk_unsafe.h"
|
||||
|
||||
#include "physics/CCPhysicsBody.h"
|
||||
#include "physics/CCPhysicsWorld.h"
|
||||
|
||||
#include "chipmunk/CCPhysicsBodyInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsShapeInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsHelper_chipmunk.h"
|
||||
#include "CCPhysicsBody.h"
|
||||
#include "CCPhysicsWorld.h"
|
||||
#include "CCPhysicsHelper.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
extern const float PHYSICS_INFINITY;
|
||||
std::unordered_map<cpShape*, PhysicsShape*> s_physicsShapeMap;
|
||||
static cpBody* s_sharedBody = nullptr;
|
||||
|
||||
PhysicsShape::PhysicsShape()
|
||||
: _body(nullptr)
|
||||
, _info(nullptr)
|
||||
, _type(Type::UNKNOWN)
|
||||
, _area(0.0f)
|
||||
, _mass(0.0f)
|
||||
|
@ -51,29 +50,26 @@ PhysicsShape::PhysicsShape()
|
|||
, _scaleY(1.0f)
|
||||
, _newScaleX(1.0f)
|
||||
, _newScaleY(1.0f)
|
||||
, _dirty(false)
|
||||
, _tag(0)
|
||||
, _categoryBitmask(UINT_MAX)
|
||||
, _collisionBitmask(UINT_MAX)
|
||||
, _contactTestBitmask(0)
|
||||
, _group(0)
|
||||
{
|
||||
|
||||
if (s_sharedBody == nullptr)
|
||||
{
|
||||
s_sharedBody = cpBodyNewStatic();
|
||||
}
|
||||
}
|
||||
|
||||
PhysicsShape::~PhysicsShape()
|
||||
{
|
||||
CC_SAFE_DELETE(_info);
|
||||
}
|
||||
for (auto shape : _cpShapes)
|
||||
{
|
||||
s_physicsShapeMap.erase(shape);
|
||||
|
||||
bool PhysicsShape::init(Type type)
|
||||
{
|
||||
_info = new (std::nothrow) PhysicsShapeInfo(this);
|
||||
if (_info == nullptr) return false;
|
||||
|
||||
_type = type;
|
||||
|
||||
return true;
|
||||
cpShapeFree(shape);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsShape::setMass(float mass)
|
||||
|
@ -115,60 +111,34 @@ void PhysicsShape::setMaterial(const PhysicsMaterial& material)
|
|||
setFriction(material.friction);
|
||||
}
|
||||
|
||||
PhysicsBodyInfo* PhysicsShape::bodyInfo() const
|
||||
{
|
||||
if (_body != nullptr)
|
||||
{
|
||||
return _body->_info;
|
||||
}else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsShape::setScale(float scale)
|
||||
{
|
||||
setScaleX(scale);
|
||||
setScaleY(scale);
|
||||
}
|
||||
|
||||
void PhysicsShape::setScale(float scaleX, float scaleY)
|
||||
{
|
||||
setScaleX(scaleX);
|
||||
setScaleY(scaleY);
|
||||
}
|
||||
|
||||
void PhysicsShape::setScaleX(float scaleX)
|
||||
{
|
||||
if (_scaleX == scaleX)
|
||||
if (_scaleX != scaleX || _scaleY != scaleY)
|
||||
{
|
||||
return;
|
||||
if (_type == Type::CIRCLE && scaleX != scaleY)
|
||||
{
|
||||
CCLOG("PhysicsShapeCircle WARNING: CANNOT support setScale with different x and y");
|
||||
return;
|
||||
}
|
||||
_newScaleX = scaleX;
|
||||
_newScaleY = scaleY;
|
||||
updateScale();
|
||||
}
|
||||
|
||||
_newScaleX = scaleX;
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
void PhysicsShape::setScaleY(float scaleY)
|
||||
void PhysicsShape::updateScale()
|
||||
{
|
||||
if (_scaleY == scaleY)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_newScaleY = scaleY;
|
||||
_dirty = true;
|
||||
_scaleX = _newScaleX;
|
||||
_scaleY = _newScaleY;
|
||||
}
|
||||
|
||||
void PhysicsShape::update(float delta)
|
||||
void PhysicsShape::addShape(cpShape* shape)
|
||||
{
|
||||
CC_UNUSED_PARAM(delta);
|
||||
|
||||
if (_dirty)
|
||||
if (shape)
|
||||
{
|
||||
_scaleX = _newScaleX;
|
||||
_scaleY = _newScaleY;
|
||||
_dirty = false;
|
||||
cpShapeSetGroup(shape, _group);
|
||||
_cpShapes.push_back(shape);
|
||||
s_physicsShapeMap.insert(std::pair<cpShape*, PhysicsShape*>(shape, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +234,7 @@ void PhysicsShape::setRestitution(float restitution)
|
|||
{
|
||||
_material.restitution = restitution;
|
||||
|
||||
for (cpShape* shape : _info->getShapes())
|
||||
for (cpShape* shape : _cpShapes)
|
||||
{
|
||||
cpShapeSetElasticity(shape, PhysicsHelper::float2cpfloat(restitution));
|
||||
}
|
||||
|
@ -274,7 +244,7 @@ void PhysicsShape::setFriction(float friction)
|
|||
{
|
||||
_material.friction = friction;
|
||||
|
||||
for (cpShape* shape : _info->getShapes())
|
||||
for (cpShape* shape : _cpShapes)
|
||||
{
|
||||
cpShapeSetFriction(shape, PhysicsHelper::float2cpfloat(friction));
|
||||
}
|
||||
|
@ -309,25 +279,21 @@ Vec2 PhysicsShape::getPolyonCenter(const Vec2* points, int count)
|
|||
void PhysicsShape::setBody(PhysicsBody *body)
|
||||
{
|
||||
// already added
|
||||
if (body != nullptr && _body == body)
|
||||
if (body && _body == body)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_body != nullptr)
|
||||
if (_body)
|
||||
{
|
||||
_body->removeShape(this);
|
||||
}
|
||||
|
||||
if (body == nullptr)
|
||||
for (auto shape : _cpShapes)
|
||||
{
|
||||
_info->setBody(nullptr);
|
||||
_body = nullptr;
|
||||
}else
|
||||
{
|
||||
_info->setBody(body->_info->getBody());
|
||||
_body = body;
|
||||
cpShapeSetBody(shape, body == nullptr ? s_sharedBody : body->_cpBody);
|
||||
}
|
||||
_body = body;
|
||||
}
|
||||
|
||||
// PhysicsShapeCircle
|
||||
|
@ -348,13 +314,13 @@ bool PhysicsShapeCircle::init(float radius, const PhysicsMaterial& material/* =
|
|||
{
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsShape::init(Type::CIRCLE));
|
||||
_type = Type::CIRCLE;
|
||||
|
||||
cpShape* shape = cpCircleShapeNew(_info->getSharedBody(), radius, PhysicsHelper::point2cpv(offset));
|
||||
auto shape = cpCircleShapeNew(s_sharedBody, radius, PhysicsHelper::point2cpv(offset));
|
||||
|
||||
CC_BREAK_IF(shape == nullptr);
|
||||
|
||||
_info->add(shape);
|
||||
addShape(shape);
|
||||
|
||||
_area = calculateArea();
|
||||
_mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area;
|
||||
|
@ -383,12 +349,12 @@ float PhysicsShapeCircle::calculateMoment(float mass, float radius, const Vec2&
|
|||
|
||||
float PhysicsShapeCircle::calculateArea()
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpAreaForCircle(0, cpCircleShapeGetRadius(_info->getShapes().front())));
|
||||
return PhysicsHelper::cpfloat2float(cpAreaForCircle(0, cpCircleShapeGetRadius(_cpShapes.front())));
|
||||
}
|
||||
|
||||
float PhysicsShapeCircle::calculateDefaultMoment()
|
||||
{
|
||||
cpShape* shape = _info->getShapes().front();
|
||||
auto shape = _cpShapes.front();
|
||||
|
||||
return _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY
|
||||
: PhysicsHelper::cpfloat2float(cpMomentForCircle(PhysicsHelper::float2cpfloat(_mass),
|
||||
|
@ -399,72 +365,26 @@ float PhysicsShapeCircle::calculateDefaultMoment()
|
|||
|
||||
float PhysicsShapeCircle::getRadius() const
|
||||
{
|
||||
return PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(_info->getShapes().front()));
|
||||
return PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(_cpShapes.front()));
|
||||
}
|
||||
|
||||
Vec2 PhysicsShapeCircle::getOffset()
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpCircleShapeGetOffset(_info->getShapes().front()));
|
||||
return PhysicsHelper::cpv2point(cpCircleShapeGetOffset(_cpShapes.front()));
|
||||
}
|
||||
|
||||
void PhysicsShapeCircle::setScale(float scale)
|
||||
void PhysicsShapeCircle::updateScale()
|
||||
{
|
||||
if (_scaleX == scale)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_newScaleX = _newScaleY = scale;
|
||||
_dirty = true;
|
||||
}
|
||||
cpFloat factor = std::abs(PhysicsHelper::float2cpfloat(_newScaleX / _scaleX));
|
||||
|
||||
void PhysicsShapeCircle::setScale(float scaleX, float scaleY)
|
||||
{
|
||||
if (scaleX != scaleY)
|
||||
{
|
||||
CCLOG("PhysicsShapeCircle WARNING: CANNOT support setScale with different x and y");
|
||||
}
|
||||
|
||||
if (_scaleX == scaleX)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_newScaleX = _newScaleY = scaleX;
|
||||
_dirty = true;
|
||||
}
|
||||
cpShape* shape = _cpShapes.front();
|
||||
cpVect v = cpCircleShapeGetOffset(shape);
|
||||
v = cpvmult(v, PhysicsHelper::float2cpfloat(factor));
|
||||
((cpCircleShape*)shape)->c = v;
|
||||
|
||||
void PhysicsShapeCircle::setScaleX(float scale)
|
||||
{
|
||||
CCLOG("PhysicsShapeCircle WARNING: CANNOT support setScaleX");
|
||||
|
||||
setScale(scale);
|
||||
}
|
||||
cpCircleShapeSetRadius(shape, cpCircleShapeGetRadius(shape) * factor);
|
||||
|
||||
void PhysicsShapeCircle::setScaleY(float scale)
|
||||
{
|
||||
CCLOG("PhysicsShapeCircle WARNING: CANNOT support setScaleY");
|
||||
|
||||
setScale(scale);
|
||||
}
|
||||
|
||||
void PhysicsShapeCircle::update(float delta)
|
||||
{
|
||||
|
||||
if (_dirty)
|
||||
{
|
||||
cpFloat factor = std::abs(PhysicsHelper::float2cpfloat( _newScaleX / _scaleX ));
|
||||
|
||||
cpShape* shape = _info->getShapes().front();
|
||||
cpVect v = cpCircleShapeGetOffset(shape);
|
||||
v = cpvmult(v, PhysicsHelper::float2cpfloat(factor));
|
||||
((cpCircleShape*)shape)->c = v;
|
||||
|
||||
cpCircleShapeSetRadius(shape, cpCircleShapeGetRadius(shape) * factor);
|
||||
}
|
||||
|
||||
PhysicsShape::update(delta);
|
||||
|
||||
PhysicsShape::updateScale();
|
||||
}
|
||||
|
||||
// PhysicsShapeEdgeSegment
|
||||
|
@ -485,21 +405,20 @@ bool PhysicsShapeEdgeSegment::init(const Vec2& a, const Vec2& b, const PhysicsMa
|
|||
{
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsShape::init(Type::EDGESEGMENT));
|
||||
_type = Type::EDGESEGMENT;
|
||||
|
||||
cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(),
|
||||
auto shape = cpSegmentShapeNew(s_sharedBody,
|
||||
PhysicsHelper::point2cpv(a),
|
||||
PhysicsHelper::point2cpv(b),
|
||||
PhysicsHelper::float2cpfloat(border));
|
||||
|
||||
CC_BREAK_IF(shape == nullptr);
|
||||
|
||||
_info->add(shape);
|
||||
addShape(shape);
|
||||
|
||||
_mass = PHYSICS_INFINITY;
|
||||
_moment = PHYSICS_INFINITY;
|
||||
|
||||
|
||||
setMaterial(material);
|
||||
|
||||
return true;
|
||||
|
@ -510,39 +429,36 @@ bool PhysicsShapeEdgeSegment::init(const Vec2& a, const Vec2& b, const PhysicsMa
|
|||
|
||||
Vec2 PhysicsShapeEdgeSegment::getPointA() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->getShapes().front()))->ta);
|
||||
return PhysicsHelper::cpv2point(((cpSegmentShape*)(_cpShapes.front()))->ta);
|
||||
}
|
||||
|
||||
Vec2 PhysicsShapeEdgeSegment::getPointB() const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(((cpSegmentShape*)(_info->getShapes().front()))->tb);
|
||||
return PhysicsHelper::cpv2point(((cpSegmentShape*)(_cpShapes.front()))->tb);
|
||||
}
|
||||
|
||||
Vec2 PhysicsShapeEdgeSegment::getCenter()
|
||||
{
|
||||
Vec2 a = PhysicsHelper::cpv2point(cpSegmentShapeGetA(_info->getShapes().front()));
|
||||
Vec2 b = PhysicsHelper::cpv2point(cpSegmentShapeGetB(_info->getShapes().front()));
|
||||
auto a = PhysicsHelper::cpv2point(cpSegmentShapeGetA(_cpShapes.front()));
|
||||
auto b = PhysicsHelper::cpv2point(cpSegmentShapeGetB(_cpShapes.front()));
|
||||
return ( a + b ) / 2;
|
||||
}
|
||||
|
||||
void PhysicsShapeEdgeSegment::update(float delta)
|
||||
void PhysicsShapeEdgeSegment::updateScale()
|
||||
{
|
||||
if (_dirty)
|
||||
{
|
||||
cpFloat factorX = PhysicsHelper::float2cpfloat(_newScaleX / _scaleX);
|
||||
cpFloat factorY = PhysicsHelper::float2cpfloat(_newScaleY / _scaleY);
|
||||
|
||||
cpShape* shape = _info->getShapes().front();
|
||||
cpVect a = cpSegmentShapeGetA(shape);
|
||||
a.x *= factorX;
|
||||
a.y *= factorY;
|
||||
cpVect b = cpSegmentShapeGetB(shape);
|
||||
b.x *= factorX;
|
||||
b.y *= factorY;
|
||||
cpSegmentShapeSetEndpoints(shape, a, b);
|
||||
}
|
||||
|
||||
PhysicsShape::update(delta);
|
||||
cpFloat factorX = PhysicsHelper::float2cpfloat(_newScaleX / _scaleX);
|
||||
cpFloat factorY = PhysicsHelper::float2cpfloat(_newScaleY / _scaleY);
|
||||
|
||||
cpShape* shape = _cpShapes.front();
|
||||
cpVect a = cpSegmentShapeGetA(shape);
|
||||
a.x *= factorX;
|
||||
a.y *= factorY;
|
||||
cpVect b = cpSegmentShapeGetB(shape);
|
||||
b.x *= factorX;
|
||||
b.y *= factorY;
|
||||
cpSegmentShapeSetEndpoints(shape, a, b);
|
||||
|
||||
PhysicsShape::updateScale();
|
||||
}
|
||||
|
||||
// PhysicsShapeBox
|
||||
|
@ -563,19 +479,19 @@ bool PhysicsShapeBox::init(const Size& size, const PhysicsMaterial& material/* =
|
|||
{
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsShape::init(Type::BOX));
|
||||
_type = Type::BOX;
|
||||
|
||||
cpVect wh = PhysicsHelper::size2cpv(size);
|
||||
auto wh = PhysicsHelper::size2cpv(size);
|
||||
cpVect vec[4] =
|
||||
{
|
||||
{-wh.x/2.0f, -wh.y/2.0f}, {-wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, wh.y/2.0f}, {wh.x/2.0f, -wh.y/2.0f}
|
||||
};
|
||||
|
||||
cpShape* shape = cpPolyShapeNew(_info->getSharedBody(), 4, vec, PhysicsHelper::point2cpv(offset));
|
||||
auto shape = cpPolyShapeNew(s_sharedBody, 4, vec, PhysicsHelper::point2cpv(offset));
|
||||
|
||||
CC_BREAK_IF(shape == nullptr);
|
||||
|
||||
_info->add(shape);
|
||||
addShape(shape);
|
||||
|
||||
_area = calculateArea();
|
||||
_mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area;
|
||||
|
@ -591,7 +507,7 @@ bool PhysicsShapeBox::init(const Size& size, const PhysicsMaterial& material/* =
|
|||
|
||||
Size PhysicsShapeBox::getSize() const
|
||||
{
|
||||
cpShape* shape = _info->getShapes().front();
|
||||
cpShape* shape = _cpShapes.front();
|
||||
return PhysicsHelper::cpv2size(cpv(cpvdist(cpPolyShapeGetVert(shape, 1), cpPolyShapeGetVert(shape, 2)),
|
||||
cpvdist(cpPolyShapeGetVert(shape, 0), cpPolyShapeGetVert(shape, 1))));
|
||||
}
|
||||
|
@ -614,16 +530,16 @@ bool PhysicsShapePolygon::init(const Vec2* points, int count, const PhysicsMater
|
|||
{
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsShape::init(Type::POLYGEN));
|
||||
_type = Type::POLYGEN;
|
||||
|
||||
cpVect* vecs = new cpVect[count];
|
||||
auto vecs = new cpVect[count];
|
||||
PhysicsHelper::points2cpvs(points, vecs, count);
|
||||
cpShape* shape = cpPolyShapeNew(_info->getSharedBody(), count, vecs, PhysicsHelper::point2cpv(offset));
|
||||
auto shape = cpPolyShapeNew(s_sharedBody, count, vecs, PhysicsHelper::point2cpv(offset));
|
||||
CC_SAFE_DELETE_ARRAY(vecs);
|
||||
|
||||
CC_BREAK_IF(shape == nullptr);
|
||||
|
||||
_info->add(shape);
|
||||
addShape(shape);
|
||||
|
||||
_area = calculateArea();
|
||||
_mass = material.density == PHYSICS_INFINITY ? PHYSICS_INFINITY : material.density * _area;
|
||||
|
@ -660,77 +576,74 @@ float PhysicsShapePolygon::calculateMoment(float mass, const Vec2* points, int c
|
|||
|
||||
float PhysicsShapePolygon::calculateArea()
|
||||
{
|
||||
cpShape* shape = _info->getShapes().front();
|
||||
auto shape = _cpShapes.front();
|
||||
return PhysicsHelper::cpfloat2float(cpAreaForPoly(((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts));
|
||||
}
|
||||
|
||||
float PhysicsShapePolygon::calculateDefaultMoment()
|
||||
{
|
||||
cpShape* shape = _info->getShapes().front();
|
||||
auto shape = _cpShapes.front();
|
||||
return _mass == PHYSICS_INFINITY ? PHYSICS_INFINITY
|
||||
: PhysicsHelper::cpfloat2float(cpMomentForPoly(_mass, ((cpPolyShape*)shape)->numVerts, ((cpPolyShape*)shape)->verts, cpvzero));
|
||||
}
|
||||
|
||||
Vec2 PhysicsShapePolygon::getPoint(int i) const
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpPolyShapeGetVert(_info->getShapes().front(), i));
|
||||
return PhysicsHelper::cpv2point(cpPolyShapeGetVert(_cpShapes.front(), i));
|
||||
}
|
||||
|
||||
void PhysicsShapePolygon::getPoints(Vec2* outPoints) const
|
||||
{
|
||||
cpShape* shape = _info->getShapes().front();
|
||||
auto shape = _cpShapes.front();
|
||||
PhysicsHelper::cpvs2points(((cpPolyShape*)shape)->verts, outPoints, ((cpPolyShape*)shape)->numVerts);
|
||||
}
|
||||
|
||||
int PhysicsShapePolygon::getPointsCount() const
|
||||
{
|
||||
return ((cpPolyShape*)_info->getShapes().front())->numVerts;
|
||||
return ((cpPolyShape*)_cpShapes.front())->numVerts;
|
||||
}
|
||||
|
||||
Vec2 PhysicsShapePolygon::getCenter()
|
||||
{
|
||||
return PhysicsHelper::cpv2point(cpCentroidForPoly(((cpPolyShape*)_info->getShapes().front())->numVerts, ((cpPolyShape*)_info->getShapes().front())->verts));
|
||||
return PhysicsHelper::cpv2point(cpCentroidForPoly(((cpPolyShape*)_cpShapes.front())->numVerts, ((cpPolyShape*)_cpShapes.front())->verts));
|
||||
}
|
||||
|
||||
void PhysicsShapePolygon::update(float delta)
|
||||
void PhysicsShapePolygon::updateScale()
|
||||
{
|
||||
if (_dirty)
|
||||
{
|
||||
cpFloat factorX = PhysicsHelper::float2cpfloat( _newScaleX / _scaleX );
|
||||
cpFloat factorY = PhysicsHelper::float2cpfloat( _newScaleY / _scaleY );
|
||||
|
||||
cpShape* shape = _info->getShapes().front();
|
||||
int count = cpPolyShapeGetNumVerts(shape);
|
||||
cpVect* vects = ((cpPolyShape*)shape)->verts;
|
||||
cpSplittingPlane* planes = ((cpPolyShape*)shape)->planes;
|
||||
cpFloat factorX = PhysicsHelper::float2cpfloat(_newScaleX / _scaleX);
|
||||
cpFloat factorY = PhysicsHelper::float2cpfloat(_newScaleY / _scaleY);
|
||||
|
||||
for (int i = 0; i < count ; ++i)
|
||||
auto shape = _cpShapes.front();
|
||||
int count = cpPolyShapeGetNumVerts(shape);
|
||||
cpVect* vects = ((cpPolyShape*)shape)->verts;
|
||||
cpSplittingPlane* planes = ((cpPolyShape*)shape)->planes;
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
vects[i].x *= factorX;
|
||||
vects[i].y *= factorY;
|
||||
}
|
||||
|
||||
// convert hole to clockwise
|
||||
if (factorX * factorY < 0)
|
||||
{
|
||||
for (int i = 0; i < count / 2; ++i)
|
||||
{
|
||||
vects[i].x *= factorX;
|
||||
vects[i].y *= factorY;
|
||||
}
|
||||
|
||||
// convert hole to clockwise
|
||||
if ( factorX * factorY < 0 )
|
||||
{
|
||||
for (int i = 0; i < count / 2; ++i)
|
||||
{
|
||||
cpVect v = vects[i];
|
||||
vects[i] = vects[count - i - 1];
|
||||
vects[count - i - 1] = v;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
cpVect n = cpvnormalize(cpvperp(cpvsub(vects[i], vects[(i + 1) % count])));
|
||||
|
||||
planes[i].n = n;
|
||||
planes[i].d = cpvdot(n, vects[i]);
|
||||
cpVect v = vects[i];
|
||||
vects[i] = vects[count - i - 1];
|
||||
vects[count - i - 1] = v;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
cpVect n = cpvnormalize(cpvperp(cpvsub(vects[i], vects[(i + 1) % count])));
|
||||
|
||||
planes[i].n = n;
|
||||
planes[i].d = cpvdot(n, vects[i]);
|
||||
}
|
||||
|
||||
PhysicsShape::update(delta);
|
||||
PhysicsShape::updateScale();
|
||||
}
|
||||
|
||||
// PhysicsShapeEdgeBox
|
||||
|
@ -751,7 +664,7 @@ bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material
|
|||
{
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsShape::init(Type::EDGEBOX));
|
||||
_type = Type::EDGEBOX;
|
||||
|
||||
cpVect vec[4] = {};
|
||||
vec[0] = PhysicsHelper::point2cpv(Vec2(-size.width/2+offset.x, -size.height/2+offset.y));
|
||||
|
@ -762,10 +675,10 @@ bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material
|
|||
int i = 0;
|
||||
for (; i < 4; ++i)
|
||||
{
|
||||
cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), vec[i], vec[(i+1)%4],
|
||||
auto shape = cpSegmentShapeNew(s_sharedBody, vec[i], vec[(i + 1) % 4],
|
||||
PhysicsHelper::float2cpfloat(border));
|
||||
CC_BREAK_IF(shape == nullptr);
|
||||
_info->add(shape);
|
||||
addShape(shape);
|
||||
}
|
||||
CC_BREAK_IF(i < 4);
|
||||
|
||||
|
@ -799,7 +712,7 @@ bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsM
|
|||
cpVect* vec = nullptr;
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsShape::init(Type::EDGEPOLYGEN));
|
||||
_type = Type::EDGEPOLYGEN;
|
||||
|
||||
vec = new cpVect[count];
|
||||
PhysicsHelper::points2cpvs(points, vec, count);
|
||||
|
@ -807,12 +720,12 @@ bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsM
|
|||
int i = 0;
|
||||
for (; i < count; ++i)
|
||||
{
|
||||
cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), vec[i], vec[(i+1)%count],
|
||||
auto shape = cpSegmentShapeNew(s_sharedBody, vec[i], vec[(i + 1) % count],
|
||||
PhysicsHelper::float2cpfloat(border));
|
||||
CC_BREAK_IF(shape == nullptr);
|
||||
cpShapeSetElasticity(shape, 1.0f);
|
||||
cpShapeSetFriction(shape, 1.0f);
|
||||
_info->add(shape);
|
||||
cpShapeSetElasticity(shape, 1.0f);
|
||||
cpShapeSetFriction(shape, 1.0f);
|
||||
addShape(shape);
|
||||
}
|
||||
CC_SAFE_DELETE_ARRAY(vec);
|
||||
|
||||
|
@ -833,10 +746,10 @@ bool PhysicsShapeEdgePolygon::init(const Vec2* points, int count, const PhysicsM
|
|||
|
||||
Vec2 PhysicsShapeEdgePolygon::getCenter()
|
||||
{
|
||||
int count = (int)_info->getShapes().size();
|
||||
int count = (int)_cpShapes.size();
|
||||
cpVect* points = new cpVect[count];
|
||||
int i = 0;
|
||||
for(auto shape : _info->getShapes())
|
||||
for(auto shape : _cpShapes)
|
||||
{
|
||||
points[i++] = ((cpSegmentShape*)shape)->a;
|
||||
}
|
||||
|
@ -850,7 +763,7 @@ Vec2 PhysicsShapeEdgePolygon::getCenter()
|
|||
void PhysicsShapeEdgePolygon::getPoints(cocos2d::Vec2 *outPoints) const
|
||||
{
|
||||
int i = 0;
|
||||
for(auto shape : _info->getShapes())
|
||||
for(auto shape : _cpShapes)
|
||||
{
|
||||
outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a);
|
||||
}
|
||||
|
@ -858,7 +771,7 @@ void PhysicsShapeEdgePolygon::getPoints(cocos2d::Vec2 *outPoints) const
|
|||
|
||||
int PhysicsShapeEdgePolygon::getPointsCount() const
|
||||
{
|
||||
return static_cast<int>(_info->getShapes().size());
|
||||
return static_cast<int>(_cpShapes.size());
|
||||
}
|
||||
|
||||
// PhysicsShapeEdgeChain
|
||||
|
@ -875,26 +788,23 @@ PhysicsShapeEdgeChain* PhysicsShapeEdgeChain::create(const Vec2* points, int cou
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void PhysicsShapeEdgePolygon::update(float delta)
|
||||
void PhysicsShapeEdgePolygon::updateScale()
|
||||
{
|
||||
if (_dirty)
|
||||
cpFloat factorX = PhysicsHelper::float2cpfloat(_newScaleX / _scaleX);
|
||||
cpFloat factorY = PhysicsHelper::float2cpfloat(_newScaleY / _scaleY);
|
||||
|
||||
for (auto shape : _cpShapes)
|
||||
{
|
||||
cpFloat factorX = PhysicsHelper::float2cpfloat(_newScaleX / _scaleX);
|
||||
cpFloat factorY = PhysicsHelper::float2cpfloat(_newScaleY / _scaleY);
|
||||
|
||||
for(auto shape : _info->getShapes())
|
||||
{
|
||||
cpVect a = cpSegmentShapeGetA(shape);
|
||||
a.x *= factorX;
|
||||
a.y *= factorY;
|
||||
cpVect b = cpSegmentShapeGetB(shape);
|
||||
b.x *= factorX;
|
||||
b.y *= factorY;
|
||||
cpSegmentShapeSetEndpoints(shape, a, b);
|
||||
}
|
||||
cpVect a = cpSegmentShapeGetA(shape);
|
||||
a.x *= factorX;
|
||||
a.y *= factorY;
|
||||
cpVect b = cpSegmentShapeGetB(shape);
|
||||
b.x *= factorX;
|
||||
b.y *= factorY;
|
||||
cpSegmentShapeSetEndpoints(shape, a, b);
|
||||
}
|
||||
|
||||
PhysicsShape::update(delta);
|
||||
PhysicsShape::updateScale();
|
||||
}
|
||||
|
||||
bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/)
|
||||
|
@ -902,7 +812,7 @@ bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMat
|
|||
cpVect* vec = nullptr;
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(!PhysicsShape::init(Type::EDGECHAIN));
|
||||
_type = Type::EDGECHAIN;
|
||||
|
||||
vec = new cpVect[count];
|
||||
PhysicsHelper::points2cpvs(points, vec, count);
|
||||
|
@ -910,12 +820,12 @@ bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMat
|
|||
int i = 0;
|
||||
for (; i < count - 1; ++i)
|
||||
{
|
||||
cpShape* shape = cpSegmentShapeNew(_info->getSharedBody(), vec[i], vec[i+1],
|
||||
auto shape = cpSegmentShapeNew(s_sharedBody, vec[i], vec[i + 1],
|
||||
PhysicsHelper::float2cpfloat(border));
|
||||
CC_BREAK_IF(shape == nullptr);
|
||||
cpShapeSetElasticity(shape, 1.0f);
|
||||
cpShapeSetFriction(shape, 1.0f);
|
||||
_info->add(shape);
|
||||
cpShapeSetElasticity(shape, 1.0f);
|
||||
cpShapeSetFriction(shape, 1.0f);
|
||||
addShape(shape);
|
||||
}
|
||||
CC_SAFE_DELETE_ARRAY(vec);
|
||||
CC_BREAK_IF(i < count - 1);
|
||||
|
@ -935,15 +845,15 @@ bool PhysicsShapeEdgeChain::init(const Vec2* points, int count, const PhysicsMat
|
|||
|
||||
Vec2 PhysicsShapeEdgeChain::getCenter()
|
||||
{
|
||||
int count = (int)_info->getShapes().size() + 1;
|
||||
int count = (int)_cpShapes.size() + 1;
|
||||
cpVect* points = new cpVect[count];
|
||||
int i = 0;
|
||||
for(auto shape : _info->getShapes())
|
||||
for(auto shape : _cpShapes)
|
||||
{
|
||||
points[i++] = ((cpSegmentShape*)shape)->a;
|
||||
}
|
||||
|
||||
points[i++] = ((cpSegmentShape*)_info->getShapes().back())->b;
|
||||
points[i++] = ((cpSegmentShape*)_cpShapes.back())->b;
|
||||
|
||||
Vec2 center = PhysicsHelper::cpv2point(cpCentroidForPoly(count, points));
|
||||
delete[] points;
|
||||
|
@ -954,46 +864,43 @@ Vec2 PhysicsShapeEdgeChain::getCenter()
|
|||
void PhysicsShapeEdgeChain::getPoints(Vec2* outPoints) const
|
||||
{
|
||||
int i = 0;
|
||||
for(auto shape : _info->getShapes())
|
||||
for(auto shape : _cpShapes)
|
||||
{
|
||||
outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a);
|
||||
}
|
||||
|
||||
outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)_info->getShapes().back())->b);
|
||||
outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)_cpShapes.back())->b);
|
||||
}
|
||||
|
||||
int PhysicsShapeEdgeChain::getPointsCount() const
|
||||
{
|
||||
return static_cast<int>(_info->getShapes().size() + 1);
|
||||
return static_cast<int>(_cpShapes.size() + 1);
|
||||
}
|
||||
|
||||
void PhysicsShapeEdgeChain::update(float delta)
|
||||
void PhysicsShapeEdgeChain::updateScale()
|
||||
{
|
||||
if (_dirty)
|
||||
cpFloat factorX = PhysicsHelper::float2cpfloat(_newScaleX / _scaleX);
|
||||
cpFloat factorY = PhysicsHelper::float2cpfloat(_newScaleY / _scaleY);
|
||||
|
||||
for (auto shape : _cpShapes)
|
||||
{
|
||||
cpFloat factorX = PhysicsHelper::float2cpfloat(_newScaleX / _scaleX);
|
||||
cpFloat factorY = PhysicsHelper::float2cpfloat(_newScaleY / _scaleY);
|
||||
|
||||
for(auto shape : _info->getShapes())
|
||||
{
|
||||
cpVect a = cpSegmentShapeGetA(shape);
|
||||
a.x *= factorX;
|
||||
a.y *= factorY;
|
||||
cpVect b = cpSegmentShapeGetB(shape);
|
||||
b.x *= factorX;
|
||||
b.y *= factorY;
|
||||
cpSegmentShapeSetEndpoints(shape, a, b);
|
||||
}
|
||||
cpVect a = cpSegmentShapeGetA(shape);
|
||||
a.x *= factorX;
|
||||
a.y *= factorY;
|
||||
cpVect b = cpSegmentShapeGetB(shape);
|
||||
b.x *= factorX;
|
||||
b.y *= factorY;
|
||||
cpSegmentShapeSetEndpoints(shape, a, b);
|
||||
}
|
||||
|
||||
PhysicsShape::update(delta);
|
||||
PhysicsShape::updateScale();
|
||||
}
|
||||
|
||||
void PhysicsShape::setGroup(int group)
|
||||
{
|
||||
if (group < 0)
|
||||
{
|
||||
for (auto shape : _info->getShapes())
|
||||
for (auto shape : _cpShapes)
|
||||
{
|
||||
cpShapeSetGroup(shape, (cpGroup)group);
|
||||
}
|
||||
|
@ -1004,7 +911,7 @@ void PhysicsShape::setGroup(int group)
|
|||
|
||||
bool PhysicsShape::containsPoint(const Vec2& point) const
|
||||
{
|
||||
for (auto shape : _info->getShapes())
|
||||
for (auto shape : _cpShapes)
|
||||
{
|
||||
if (cpShapePointQuery(shape, PhysicsHelper::point2cpv(point)))
|
||||
{
|
||||
|
|
|
@ -31,12 +31,11 @@
|
|||
#include "base/CCRef.h"
|
||||
#include "math/CCGeometry.h"
|
||||
|
||||
struct cpShape;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class PhysicsShapeInfo;
|
||||
class PhysicsBody;
|
||||
class PhysicsBodyInfo;
|
||||
|
||||
|
||||
typedef struct CC_DLL PhysicsMaterial
|
||||
{
|
||||
|
@ -57,7 +56,7 @@ typedef struct CC_DLL PhysicsMaterial
|
|||
{}
|
||||
}PhysicsMaterial;
|
||||
|
||||
const PhysicsMaterial PHYSICSSHAPE_MATERIAL_DEFAULT(0.0f, 0.5f, 0.5f);
|
||||
const PhysicsMaterial PHYSICSSHAPE_MATERIAL_DEFAULT;
|
||||
|
||||
/**
|
||||
* @brief A shape for body. You do not create PhysicsWorld objects directly, instead, you can view PhysicsBody to see how to create it.
|
||||
|
@ -149,23 +148,14 @@ public:
|
|||
inline int getGroup() { return _group; }
|
||||
|
||||
protected:
|
||||
bool init(Type type);
|
||||
|
||||
/**
|
||||
* @brief PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. so this method is use for subclasses to catch the bodyInfo from PhysicsBody.
|
||||
*/
|
||||
PhysicsBodyInfo* bodyInfo() const;
|
||||
|
||||
void setBody(PhysicsBody* body);
|
||||
|
||||
/** calculate the area of this shape */
|
||||
virtual float calculateArea() { return 0.0f; }
|
||||
|
||||
virtual void setScale(float scale);
|
||||
virtual void setScale(float scaleX, float scaleY);
|
||||
virtual void setScaleX(float scaleX);
|
||||
virtual void setScaleY(float scaleY);
|
||||
virtual void update(float delta);
|
||||
virtual void updateScale();
|
||||
void addShape(cpShape* shape);
|
||||
|
||||
protected:
|
||||
PhysicsShape();
|
||||
|
@ -173,7 +163,8 @@ protected:
|
|||
|
||||
protected:
|
||||
PhysicsBody* _body;
|
||||
PhysicsShapeInfo* _info;
|
||||
std::vector<cpShape*> _cpShapes;
|
||||
|
||||
Type _type;
|
||||
float _area;
|
||||
float _mass;
|
||||
|
@ -182,7 +173,6 @@ protected:
|
|||
float _scaleY;
|
||||
float _newScaleX;
|
||||
float _newScaleY;
|
||||
bool _dirty;
|
||||
PhysicsMaterial _material;
|
||||
int _tag;
|
||||
int _categoryBitmask;
|
||||
|
@ -212,11 +202,7 @@ public:
|
|||
protected:
|
||||
bool init(float radius, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO);
|
||||
virtual float calculateArea() override;
|
||||
virtual void setScale(float scale) override;
|
||||
virtual void setScale(float scaleX, float scaleY) override;
|
||||
virtual void setScaleX(float scale) override;
|
||||
virtual void setScaleY(float scale) override;
|
||||
virtual void update(float delta) override;
|
||||
virtual void updateScale() override;
|
||||
|
||||
protected:
|
||||
PhysicsShapeCircle();
|
||||
|
@ -240,7 +226,7 @@ public:
|
|||
protected:
|
||||
bool init(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, const Vec2& offset = Vec2::ZERO);
|
||||
float calculateArea() override;
|
||||
virtual void update(float delta) override;
|
||||
virtual void updateScale() override;
|
||||
|
||||
protected:
|
||||
PhysicsShapePolygon();
|
||||
|
@ -276,7 +262,7 @@ public:
|
|||
|
||||
protected:
|
||||
bool init(const Vec2& a, const Vec2& b, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
|
||||
virtual void update(float delta) override;
|
||||
virtual void updateScale() override;
|
||||
|
||||
protected:
|
||||
PhysicsShapeEdgeSegment();
|
||||
|
@ -296,7 +282,7 @@ public:
|
|||
|
||||
protected:
|
||||
bool init(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
|
||||
virtual void update(float delta) override;
|
||||
virtual void updateScale() override;
|
||||
|
||||
protected:
|
||||
PhysicsShapeEdgePolygon();
|
||||
|
@ -333,7 +319,7 @@ public:
|
|||
|
||||
protected:
|
||||
bool init(const Vec2* points, int count, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1);
|
||||
virtual void update(float delta) override;
|
||||
virtual void updateScale() override;
|
||||
|
||||
protected:
|
||||
PhysicsShapeEdgeChain();
|
||||
|
|
|
@ -24,23 +24,16 @@
|
|||
|
||||
#include "physics/CCPhysicsWorld.h"
|
||||
#if CC_USE_PHYSICS
|
||||
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
|
||||
#include "chipmunk.h"
|
||||
|
||||
#include "physics/CCPhysicsBody.h"
|
||||
#include "physics/CCPhysicsShape.h"
|
||||
#include "CCPhysicsBody.h"
|
||||
#include "CCPhysicsShape.h"
|
||||
#include "CCPhysicsContact.h"
|
||||
#include "physics/CCPhysicsJoint.h"
|
||||
#include "CCPhysicsJoint.h"
|
||||
#include "CCPhysicsContact.h"
|
||||
|
||||
#include "chipmunk/CCPhysicsWorldInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsBodyInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsShapeInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsContactInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsJointInfo_chipmunk.h"
|
||||
#include "chipmunk/CCPhysicsHelper_chipmunk.h"
|
||||
#include "CCPhysicsHelper.h"
|
||||
|
||||
#include "2d/CCDrawNode.h"
|
||||
#include "2d/CCScene.h"
|
||||
|
@ -48,11 +41,10 @@
|
|||
#include "base/CCEventDispatcher.h"
|
||||
#include "base/CCEventCustom.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
NS_CC_BEGIN
|
||||
const float PHYSICS_INFINITY = INFINITY;
|
||||
extern const char* PHYSICSCONTACT_EVENT_NAME;
|
||||
extern std::unordered_map<cpShape*, PhysicsShape*> s_physicsShapeMap;
|
||||
|
||||
const int PhysicsWorld::DEBUGDRAW_NONE = 0x00;
|
||||
const int PhysicsWorld::DEBUGDRAW_SHAPE = 0x01;
|
||||
|
@ -108,11 +100,11 @@ int PhysicsWorldCallback::collisionBeginCallbackFunc(cpArbiter *arb, struct cpSp
|
|||
{
|
||||
CP_ARBITER_GET_SHAPES(arb, a, b);
|
||||
|
||||
auto ita = PhysicsShapeInfo::getMap().find(a);
|
||||
auto itb = PhysicsShapeInfo::getMap().find(b);
|
||||
CC_ASSERT(ita != PhysicsShapeInfo::getMap().end() && itb != PhysicsShapeInfo::getMap().end());
|
||||
auto ita = s_physicsShapeMap.find(a);
|
||||
auto itb = s_physicsShapeMap.find(b);
|
||||
CC_ASSERT(ita != s_physicsShapeMap.end() && itb != s_physicsShapeMap.end());
|
||||
|
||||
PhysicsContact* contact = PhysicsContact::construct(ita->second->getShape(), itb->second->getShape());
|
||||
auto contact = PhysicsContact::construct(ita->second, itb->second);
|
||||
arb->data = contact;
|
||||
contact->_contactInfo = arb;
|
||||
|
||||
|
@ -145,12 +137,12 @@ void PhysicsWorldCallback::rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect
|
|||
return;
|
||||
}
|
||||
|
||||
auto it = PhysicsShapeInfo::getMap().find(shape);
|
||||
CC_ASSERT(it != PhysicsShapeInfo::getMap().end());
|
||||
auto it = s_physicsShapeMap.find(shape);
|
||||
CC_ASSERT(it != s_physicsShapeMap.end());
|
||||
|
||||
PhysicsRayCastInfo callbackInfo =
|
||||
{
|
||||
it->second->getShape(),
|
||||
it->second,
|
||||
info->p1,
|
||||
info->p2,
|
||||
Vec2(info->p1.x+(info->p2.x-info->p1.x)*t, info->p1.y+(info->p2.y-info->p1.y)*t),
|
||||
|
@ -163,34 +155,34 @@ void PhysicsWorldCallback::rayCastCallbackFunc(cpShape *shape, cpFloat t, cpVect
|
|||
|
||||
void PhysicsWorldCallback::queryRectCallbackFunc(cpShape *shape, RectQueryCallbackInfo *info)
|
||||
{
|
||||
auto it = PhysicsShapeInfo::getMap().find(shape);
|
||||
auto it = s_physicsShapeMap.find(shape);
|
||||
|
||||
CC_ASSERT(it != PhysicsShapeInfo::getMap().end());
|
||||
CC_ASSERT(it != s_physicsShapeMap.end());
|
||||
|
||||
if (!PhysicsWorldCallback::continues)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PhysicsWorldCallback::continues = info->func(*info->world, *it->second->getShape(), info->data);
|
||||
PhysicsWorldCallback::continues = info->func(*info->world, *it->second, info->data);
|
||||
}
|
||||
|
||||
void PhysicsWorldCallback::getShapesAtPointFunc(cpShape *shape, cpFloat distance, cpVect point, Vector<PhysicsShape*>* arr)
|
||||
{
|
||||
auto it = PhysicsShapeInfo::getMap().find(shape);
|
||||
auto it = s_physicsShapeMap.find(shape);
|
||||
|
||||
CC_ASSERT(it != PhysicsShapeInfo::getMap().end());
|
||||
CC_ASSERT(it != s_physicsShapeMap.end());
|
||||
|
||||
arr->pushBack(it->second->getShape());
|
||||
arr->pushBack(it->second);
|
||||
}
|
||||
|
||||
void PhysicsWorldCallback::queryPointFunc(cpShape *shape, cpFloat distance, cpVect point, PointQueryCallbackInfo *info)
|
||||
{
|
||||
auto it = PhysicsShapeInfo::getMap().find(shape);
|
||||
auto it = s_physicsShapeMap.find(shape);
|
||||
|
||||
CC_ASSERT(it != PhysicsShapeInfo::getMap().end());
|
||||
CC_ASSERT(it != s_physicsShapeMap.end());
|
||||
|
||||
PhysicsWorldCallback::continues = info->func(*info->world, *it->second->getShape(), info->data);
|
||||
PhysicsWorldCallback::continues = info->func(*info->world, *it->second, info->data);
|
||||
}
|
||||
|
||||
void PhysicsWorld::debugDraw()
|
||||
|
@ -343,7 +335,7 @@ void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Vec2& point1,
|
|||
RayCastCallbackInfo info = { this, func, point1, point2, data };
|
||||
|
||||
PhysicsWorldCallback::continues = true;
|
||||
cpSpaceSegmentQuery(this->_info->getSpace(),
|
||||
cpSpaceSegmentQuery(_cpSpace,
|
||||
PhysicsHelper::point2cpv(point1),
|
||||
PhysicsHelper::point2cpv(point2),
|
||||
CP_ALL_LAYERS,
|
||||
|
@ -362,7 +354,7 @@ void PhysicsWorld::queryRect(PhysicsQueryRectCallbackFunc func, const Rect& rect
|
|||
RectQueryCallbackInfo info = {this, func, data};
|
||||
|
||||
PhysicsWorldCallback::continues = true;
|
||||
cpSpaceBBQuery(this->_info->getSpace(),
|
||||
cpSpaceBBQuery(_cpSpace,
|
||||
PhysicsHelper::rect2cpbb(rect),
|
||||
CP_ALL_LAYERS,
|
||||
CP_NO_GROUP,
|
||||
|
@ -380,7 +372,7 @@ void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Vec2& po
|
|||
PointQueryCallbackInfo info = {this, func, data};
|
||||
|
||||
PhysicsWorldCallback::continues = true;
|
||||
cpSpaceNearestPointQuery(this->_info->getSpace(),
|
||||
cpSpaceNearestPointQuery(_cpSpace,
|
||||
PhysicsHelper::point2cpv(point),
|
||||
0,
|
||||
CP_ALL_LAYERS,
|
||||
|
@ -393,7 +385,7 @@ void PhysicsWorld::queryPoint(PhysicsQueryPointCallbackFunc func, const Vec2& po
|
|||
Vector<PhysicsShape*> PhysicsWorld::getShapes(const Vec2& point) const
|
||||
{
|
||||
Vector<PhysicsShape*> arr;
|
||||
cpSpaceNearestPointQuery(this->_info->getSpace(),
|
||||
cpSpaceNearestPointQuery(_cpSpace,
|
||||
PhysicsHelper::point2cpv(point),
|
||||
0,
|
||||
CP_ALL_LAYERS,
|
||||
|
@ -406,14 +398,14 @@ Vector<PhysicsShape*> PhysicsWorld::getShapes(const Vec2& point) const
|
|||
|
||||
PhysicsShape* PhysicsWorld::getShape(const Vec2& point) const
|
||||
{
|
||||
cpShape* shape = cpSpaceNearestPointQueryNearest(this->_info->getSpace(),
|
||||
cpShape* shape = cpSpaceNearestPointQueryNearest(_cpSpace,
|
||||
PhysicsHelper::point2cpv(point),
|
||||
0,
|
||||
CP_ALL_LAYERS,
|
||||
CP_NO_GROUP,
|
||||
nullptr);
|
||||
|
||||
return shape == nullptr ? nullptr : PhysicsShapeInfo::getMap().find(shape)->second->getShape();
|
||||
return shape == nullptr ? nullptr : s_physicsShapeMap.find(shape)->second;
|
||||
}
|
||||
|
||||
PhysicsWorld* PhysicsWorld::construct(Scene& scene)
|
||||
|
@ -432,14 +424,14 @@ bool PhysicsWorld::init(Scene& scene)
|
|||
{
|
||||
do
|
||||
{
|
||||
_info = new (std::nothrow) PhysicsWorldInfo();
|
||||
CC_BREAK_IF(_info == nullptr);
|
||||
_cpSpace = cpSpaceNew();
|
||||
CC_BREAK_IF(_cpSpace == nullptr);
|
||||
|
||||
_scene = &scene;
|
||||
|
||||
_info->setGravity(_gravity);
|
||||
cpSpaceSetGravity(_cpSpace, PhysicsHelper::point2cpv(_gravity));
|
||||
|
||||
cpSpaceSetDefaultCollisionHandler(_info->getSpace(),
|
||||
cpSpaceSetDefaultCollisionHandler(_cpSpace,
|
||||
(cpCollisionBeginFunc)PhysicsWorldCallback::collisionBeginCallbackFunc,
|
||||
(cpCollisionPreSolveFunc)PhysicsWorldCallback::collisionPreSolveCallbackFunc,
|
||||
(cpCollisionPostSolveFunc)PhysicsWorldCallback::collisionPostSolveCallbackFunc,
|
||||
|
@ -476,9 +468,9 @@ void PhysicsWorld::doAddBody(PhysicsBody* body)
|
|||
if (body->isEnabled())
|
||||
{
|
||||
// add body to space
|
||||
if (body->isDynamic())
|
||||
if (body->isDynamic() && !cpSpaceContainsBody(_cpSpace, body->_cpBody))
|
||||
{
|
||||
_info->addBody(*body->_info);
|
||||
cpSpaceAddBody(_cpSpace, body->_cpBody);
|
||||
}
|
||||
|
||||
// add shapes to space
|
||||
|
@ -489,7 +481,6 @@ void PhysicsWorld::doAddBody(PhysicsBody* body)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void PhysicsWorld::addBodyOrDelay(PhysicsBody* body)
|
||||
{
|
||||
auto removeBodyIter = _delayRemoveBodies.find(body);
|
||||
|
@ -499,23 +490,16 @@ void PhysicsWorld::addBodyOrDelay(PhysicsBody* body)
|
|||
return;
|
||||
}
|
||||
|
||||
if (_info->isLocked())
|
||||
if (_delayAddBodies.find(body) == _delayAddBodies.end())
|
||||
{
|
||||
if (_delayAddBodies.find(body) == _delayAddBodies.end())
|
||||
{
|
||||
_delayAddBodies.pushBack(body);
|
||||
_delayDirty = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doAddBody(body);
|
||||
_delayAddBodies.pushBack(body);
|
||||
_delayDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorld::updateBodies()
|
||||
{
|
||||
if (_info->isLocked())
|
||||
if (cpSpaceIsLocked(_cpSpace))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -550,7 +534,6 @@ void PhysicsWorld::removeBody(int tag)
|
|||
|
||||
void PhysicsWorld::removeBody(PhysicsBody* body)
|
||||
{
|
||||
|
||||
if (body->getWorld() != this)
|
||||
{
|
||||
CCLOG("Physics Warnning: this body doesn't belong to this world");
|
||||
|
@ -558,25 +541,11 @@ void PhysicsWorld::removeBody(PhysicsBody* body)
|
|||
}
|
||||
|
||||
// destory the body's joints
|
||||
for (auto joint : body->_joints)
|
||||
auto removeCopy = body->_joints;
|
||||
for (auto joint : removeCopy)
|
||||
{
|
||||
// set destroy param to false to keep the iterator available
|
||||
removeJoint(joint, false);
|
||||
|
||||
PhysicsBody* other = (joint->getBodyA() == body ? joint->getBodyB() : joint->getBodyA());
|
||||
other->removeJoint(joint);
|
||||
|
||||
// test the distraction is delaied or not
|
||||
if (std::find(_delayRemoveJoints.rbegin(), _delayRemoveJoints.rend(), joint) != _delayRemoveJoints.rend())
|
||||
{
|
||||
joint->_destoryMark = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete joint;
|
||||
}
|
||||
removeJoint(joint, true);
|
||||
}
|
||||
|
||||
body->_joints.clear();
|
||||
|
||||
removeBodyOrDelay(body);
|
||||
|
@ -593,7 +562,7 @@ void PhysicsWorld::removeBodyOrDelay(PhysicsBody* body)
|
|||
return;
|
||||
}
|
||||
|
||||
if (_info->isLocked())
|
||||
if (cpSpaceIsLocked(_cpSpace))
|
||||
{
|
||||
if (_delayRemoveBodies.getIndex(body) == CC_INVALID_INDEX)
|
||||
{
|
||||
|
@ -606,188 +575,122 @@ void PhysicsWorld::removeBodyOrDelay(PhysicsBody* body)
|
|||
}
|
||||
}
|
||||
|
||||
void PhysicsWorld::doAddJoint(PhysicsJoint *joint)
|
||||
{
|
||||
if (joint == nullptr || joint->_info == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_info->addJoint(*joint->_info);
|
||||
}
|
||||
|
||||
void PhysicsWorld::removeJoint(PhysicsJoint* joint, bool destroy)
|
||||
{
|
||||
if (joint->getWorld() != this)
|
||||
if (joint)
|
||||
{
|
||||
if (destroy)
|
||||
if (joint->getWorld() != this && destroy)
|
||||
{
|
||||
CCLOG("physics warnning: the joint is not in this world, it won't be destoried utill the body it conntect is destoried");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
removeJointOrDelay(joint);
|
||||
|
||||
_joints.remove(joint);
|
||||
joint->_world = nullptr;
|
||||
|
||||
// clean the connection to this joint
|
||||
if (destroy)
|
||||
{
|
||||
if (joint->getBodyA() != nullptr)
|
||||
|
||||
joint->_destoryMark = destroy;
|
||||
if (cpSpaceIsLocked(_cpSpace))
|
||||
{
|
||||
joint->getBodyA()->removeJoint(joint);
|
||||
}
|
||||
|
||||
if (joint->getBodyB() != nullptr)
|
||||
{
|
||||
joint->getBodyB()->removeJoint(joint);
|
||||
}
|
||||
|
||||
// test the distraction is delaied or not
|
||||
if (std::find(_delayRemoveJoints.rbegin(), _delayRemoveJoints.rend(), joint) != _delayRemoveJoints.rend())
|
||||
{
|
||||
joint->_destoryMark = true;
|
||||
auto it = std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint);
|
||||
if (it != _delayAddJoints.end())
|
||||
{
|
||||
_delayAddJoints.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
if (std::find(_delayRemoveJoints.rbegin(), _delayRemoveJoints.rend(), joint) == _delayRemoveJoints.rend())
|
||||
{
|
||||
_delayRemoveJoints.push_back(joint);
|
||||
_delayDirty = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete joint;
|
||||
doRemoveJoint(joint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorld::updateJoints()
|
||||
{
|
||||
if (_info->isLocked())
|
||||
if (cpSpaceIsLocked(_cpSpace))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto addCopy = _delayAddJoints;
|
||||
_delayAddJoints.clear();
|
||||
for (auto joint : addCopy)
|
||||
for (auto joint : _delayAddJoints)
|
||||
{
|
||||
doAddJoint(joint);
|
||||
}
|
||||
|
||||
auto removeCopy = _delayRemoveJoints;
|
||||
_delayRemoveJoints.clear();
|
||||
for (auto joint : removeCopy)
|
||||
{
|
||||
doRemoveJoint(joint);
|
||||
|
||||
if (joint->_destoryMark)
|
||||
joint->_world = this;
|
||||
if (joint->initJoint())
|
||||
{
|
||||
_joints.push_back(joint);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete joint;
|
||||
}
|
||||
}
|
||||
_delayAddJoints.clear();
|
||||
|
||||
for (auto joint : _delayRemoveJoints)
|
||||
{
|
||||
doRemoveJoint(joint);
|
||||
}
|
||||
_delayRemoveJoints.clear();
|
||||
}
|
||||
|
||||
void PhysicsWorld::removeShape(PhysicsShape* shape)
|
||||
{
|
||||
if (shape != nullptr)
|
||||
if (shape)
|
||||
{
|
||||
_info->removeShape(*shape->_info);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorld::addJointOrDelay(PhysicsJoint* joint)
|
||||
{
|
||||
auto it = std::find(_delayRemoveJoints.begin(), _delayRemoveJoints.end(), joint);
|
||||
if (it != _delayRemoveJoints.end())
|
||||
{
|
||||
_delayRemoveJoints.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_info->isLocked())
|
||||
{
|
||||
if (std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint) == _delayAddJoints.end())
|
||||
for (auto cps : shape->_cpShapes)
|
||||
{
|
||||
_delayAddJoints.push_back(joint);
|
||||
_delayDirty = true;
|
||||
if (cpSpaceContainsShape(_cpSpace, cps))
|
||||
{
|
||||
cpSpaceRemoveShape(_cpSpace, cps);
|
||||
}
|
||||
}
|
||||
}else
|
||||
{
|
||||
doAddJoint(joint);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorld::removeJointOrDelay(PhysicsJoint* joint)
|
||||
{
|
||||
auto it = std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint);
|
||||
if (it != _delayAddJoints.end())
|
||||
{
|
||||
_delayAddJoints.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_info->isLocked())
|
||||
{
|
||||
if (std::find(_delayRemoveJoints.rbegin(), _delayRemoveJoints.rend(), joint) == _delayRemoveJoints.rend())
|
||||
{
|
||||
_delayRemoveJoints.push_back(joint);
|
||||
_delayDirty = true;
|
||||
}
|
||||
}else
|
||||
{
|
||||
doRemoveJoint(joint);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorld::addJoint(PhysicsJoint* joint)
|
||||
{
|
||||
if (joint->getWorld() != nullptr && joint->getWorld() != this)
|
||||
if (joint)
|
||||
{
|
||||
joint->removeFormWorld();
|
||||
if (joint->getWorld() && joint->getWorld() != this)
|
||||
{
|
||||
joint->removeFormWorld();
|
||||
}
|
||||
|
||||
auto it = std::find(_delayRemoveJoints.begin(), _delayRemoveJoints.end(), joint);
|
||||
if (it != _delayRemoveJoints.end())
|
||||
{
|
||||
_delayRemoveJoints.erase(it);
|
||||
return;
|
||||
}
|
||||
|
||||
if (std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint) == _delayAddJoints.end())
|
||||
{
|
||||
_delayAddJoints.push_back(joint);
|
||||
_delayDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
addJointOrDelay(joint);
|
||||
_joints.push_back(joint);
|
||||
joint->_world = this;
|
||||
}
|
||||
|
||||
void PhysicsWorld::removeAllJoints(bool destroy)
|
||||
{
|
||||
for (auto joint : _joints)
|
||||
auto removeCopy = _joints;
|
||||
for (auto joint : removeCopy)
|
||||
{
|
||||
removeJointOrDelay(joint);
|
||||
joint->_world = nullptr;
|
||||
|
||||
// clean the connection to this joint
|
||||
if (destroy)
|
||||
{
|
||||
if (joint->getBodyA() != nullptr)
|
||||
{
|
||||
joint->getBodyA()->removeJoint(joint);
|
||||
}
|
||||
|
||||
if (joint->getBodyB() != nullptr)
|
||||
{
|
||||
joint->getBodyB()->removeJoint(joint);
|
||||
}
|
||||
|
||||
// test the distraction is delaied or not
|
||||
if (std::find(_delayRemoveJoints.rbegin(), _delayRemoveJoints.rend(), joint) != _delayRemoveJoints.rend())
|
||||
{
|
||||
joint->_destoryMark = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete joint;
|
||||
}
|
||||
}
|
||||
removeJoint(joint, destroy);
|
||||
}
|
||||
|
||||
_joints.clear();
|
||||
}
|
||||
|
||||
void PhysicsWorld::addShape(PhysicsShape* shape)
|
||||
void PhysicsWorld::addShape(PhysicsShape* physicsShape)
|
||||
{
|
||||
if (shape != nullptr)
|
||||
if (physicsShape)
|
||||
{
|
||||
_info->addShape(*shape->_info);
|
||||
for (auto shape : physicsShape->_cpShapes)
|
||||
{
|
||||
cpSpaceAddShape(_cpSpace, shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -802,12 +705,35 @@ void PhysicsWorld::doRemoveBody(PhysicsBody* body)
|
|||
}
|
||||
|
||||
// remove body
|
||||
_info->removeBody(*body->_info);
|
||||
if (cpSpaceContainsBody(_cpSpace, body->_cpBody))
|
||||
{
|
||||
cpSpaceRemoveBody(_cpSpace, body->_cpBody);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorld::doRemoveJoint(PhysicsJoint* joint)
|
||||
{
|
||||
_info->removeJoint(*joint->_info);
|
||||
for (auto constraint : joint->_cpConstraints)
|
||||
{
|
||||
cpSpaceRemoveConstraint(_cpSpace, constraint);
|
||||
}
|
||||
_joints.remove(joint);
|
||||
joint->_world = nullptr;
|
||||
|
||||
if (joint->getBodyA())
|
||||
{
|
||||
joint->getBodyA()->removeJoint(joint);
|
||||
}
|
||||
|
||||
if (joint->getBodyB())
|
||||
{
|
||||
joint->getBodyB()->removeJoint(joint);
|
||||
}
|
||||
|
||||
if (joint->_destoryMark)
|
||||
{
|
||||
delete joint;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorld::removeAllBodies()
|
||||
|
@ -852,7 +778,7 @@ PhysicsBody* PhysicsWorld::getBody(int tag) const
|
|||
void PhysicsWorld::setGravity(const Vect& gravity)
|
||||
{
|
||||
_gravity = gravity;
|
||||
_info->setGravity(gravity);
|
||||
cpSpaceSetGravity(_cpSpace, PhysicsHelper::point2cpv(gravity));
|
||||
}
|
||||
|
||||
void PhysicsWorld::setSubsteps(int steps)
|
||||
|
@ -881,17 +807,24 @@ void PhysicsWorld::step(float delta)
|
|||
|
||||
void PhysicsWorld::update(float delta, bool userCall/* = false*/)
|
||||
{
|
||||
if (delta < FLT_EPSILON)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_scene->updatePhysicsBodyTransform(_scene, _scene->getNodeToParentTransform(), 0, 1.0f, 1.0f);
|
||||
|
||||
while (_delayDirty)
|
||||
{
|
||||
// the updateJoints must run before the updateBodies.
|
||||
updateJoints();
|
||||
updateBodies();
|
||||
updateJoints();
|
||||
|
||||
_delayDirty = !(_delayAddBodies.size() == 0 && _delayRemoveBodies.size() == 0 && _delayAddJoints.size() == 0 && _delayRemoveJoints.size() == 0);
|
||||
}
|
||||
|
||||
if (userCall)
|
||||
{
|
||||
_info->step(delta);
|
||||
cpSpaceStep(_cpSpace, delta);
|
||||
for (auto& body : _bodies)
|
||||
{
|
||||
body->update(delta);
|
||||
|
@ -905,7 +838,7 @@ void PhysicsWorld::update(float delta, bool userCall/* = false*/)
|
|||
const float dt = _updateTime * _speed / _substeps;
|
||||
for (int i = 0; i < _substeps; ++i)
|
||||
{
|
||||
_info->step(dt);
|
||||
cpSpaceStep(_cpSpace, dt);
|
||||
for (auto& body : _bodies)
|
||||
{
|
||||
body->update(dt);
|
||||
|
@ -929,7 +862,7 @@ PhysicsWorld::PhysicsWorld()
|
|||
, _updateRateCount(0)
|
||||
, _updateTime(0.0f)
|
||||
, _substeps(1)
|
||||
, _info(nullptr)
|
||||
, _cpSpace(nullptr)
|
||||
, _scene(nullptr)
|
||||
, _delayDirty(false)
|
||||
, _autoStep(true)
|
||||
|
@ -943,7 +876,10 @@ PhysicsWorld::~PhysicsWorld()
|
|||
{
|
||||
removeAllJoints(true);
|
||||
removeAllBodies();
|
||||
CC_SAFE_DELETE(_info);
|
||||
if (_cpSpace)
|
||||
{
|
||||
cpSpaceFree(_cpSpace);
|
||||
}
|
||||
CC_SAFE_DELETE(_debugDraw);
|
||||
}
|
||||
|
||||
|
@ -976,7 +912,7 @@ void PhysicsDebugDraw::drawShape(PhysicsShape& shape)
|
|||
const Color4F fillColor(1.0f, 0.0f, 0.0f, 0.3f);
|
||||
const Color4F outlineColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
for (auto it = shape._info->getShapes().begin(); it != shape._info->getShapes().end(); ++it)
|
||||
for (auto it = shape._cpShapes.begin(); it != shape._cpShapes.end(); ++it)
|
||||
{
|
||||
cpShape *subShape = *it;
|
||||
|
||||
|
@ -1032,7 +968,7 @@ void PhysicsDebugDraw::drawJoint(PhysicsJoint& joint)
|
|||
const Color4F lineColor(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
const Color4F jointPointColor(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
|
||||
for (auto it = joint._info->getJoints().begin(); it != joint._info->getJoints().end(); ++it)
|
||||
for (auto it = joint._cpConstraints.begin(); it != joint._cpConstraints.end(); ++it)
|
||||
{
|
||||
cpConstraint *constraint = *it;
|
||||
|
||||
|
|
|
@ -34,16 +34,18 @@
|
|||
#include "physics/CCPhysicsBody.h"
|
||||
#include <list>
|
||||
|
||||
struct cpSpace;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class PhysicsBody;
|
||||
class PhysicsJoint;
|
||||
class PhysicsWorldInfo;
|
||||
class PhysicsShape;
|
||||
class PhysicsContact;
|
||||
|
||||
typedef Vec2 Vect;
|
||||
|
||||
class Director;
|
||||
class Node;
|
||||
class Sprite;
|
||||
class Scene;
|
||||
|
@ -187,12 +189,9 @@ protected:
|
|||
|
||||
virtual void doAddBody(PhysicsBody* body);
|
||||
virtual void doRemoveBody(PhysicsBody* body);
|
||||
virtual void doAddJoint(PhysicsJoint* joint);
|
||||
virtual void doRemoveJoint(PhysicsJoint* joint);
|
||||
virtual void addBodyOrDelay(PhysicsBody* body);
|
||||
virtual void removeBodyOrDelay(PhysicsBody* body);
|
||||
virtual void addJointOrDelay(PhysicsJoint* joint);
|
||||
virtual void removeJointOrDelay(PhysicsJoint* joint);
|
||||
virtual void updateBodies();
|
||||
virtual void updateJoints();
|
||||
|
||||
|
@ -203,7 +202,7 @@ protected:
|
|||
int _updateRateCount;
|
||||
float _updateTime;
|
||||
int _substeps;
|
||||
PhysicsWorldInfo* _info;
|
||||
cpSpace* _cpSpace;
|
||||
|
||||
Vector<PhysicsBody*> _bodies;
|
||||
std::list<PhysicsJoint*> _joints;
|
||||
|
@ -227,6 +226,7 @@ protected:
|
|||
friend class Node;
|
||||
friend class Sprite;
|
||||
friend class Scene;
|
||||
friend class Director;
|
||||
friend class PhysicsBody;
|
||||
friend class PhysicsShape;
|
||||
friend class PhysicsJoint;
|
||||
|
|
|
@ -6,10 +6,5 @@ set(COCOS_PHYSICS_SRC
|
|||
physics/CCPhysicsJoint.cpp
|
||||
physics/CCPhysicsShape.cpp
|
||||
physics/CCPhysicsWorld.cpp
|
||||
physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp
|
||||
physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp
|
||||
physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp
|
||||
physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp
|
||||
physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp
|
||||
|
||||
)
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
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 "CCPhysicsBodyInfo_chipmunk.h"
|
||||
#if CC_USE_PHYSICS
|
||||
#include "chipmunk.h"
|
||||
NS_CC_BEGIN
|
||||
|
||||
PhysicsBodyInfo::PhysicsBodyInfo()
|
||||
: _body(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
PhysicsBodyInfo::~PhysicsBodyInfo()
|
||||
{
|
||||
if (_body) cpBodyFree(_body);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
#endif // CC_USE_PHYSICS
|
|
@ -1,57 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
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 __CCPHYSICS_BODY_INFO_CHIPMUNK_H__
|
||||
#define __CCPHYSICS_BODY_INFO_CHIPMUNK_H__
|
||||
|
||||
#include "base/ccConfig.h"
|
||||
#if CC_USE_PHYSICS
|
||||
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
#include "base/CCRef.h"
|
||||
|
||||
struct cpBody;
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class PhysicsBodyInfo
|
||||
{
|
||||
public:
|
||||
inline cpBody* getBody() const { return _body; }
|
||||
inline void setBody(cpBody* body) { _body = body; }
|
||||
|
||||
private:
|
||||
PhysicsBodyInfo();
|
||||
~PhysicsBodyInfo();
|
||||
|
||||
private:
|
||||
cpBody* _body;
|
||||
|
||||
friend class PhysicsBody;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_USE_PHYSICS
|
||||
#endif // __CCPHYSICS_BODY_INFO_CHIPMUNK_H__
|
|
@ -1,40 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
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 "CCPhysicsContactInfo_chipmunk.h"
|
||||
#if CC_USE_PHYSICS
|
||||
#include "chipmunk.h"
|
||||
NS_CC_BEGIN
|
||||
|
||||
PhysicsContactInfo::PhysicsContactInfo(PhysicsContact* contact)
|
||||
: _contact(contact)
|
||||
{
|
||||
}
|
||||
|
||||
PhysicsContactInfo::~PhysicsContactInfo()
|
||||
{
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
#endif // CC_USE_PHYSICS
|
|
@ -1,53 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
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 __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__
|
||||
#define __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__
|
||||
|
||||
#include "base/ccConfig.h"
|
||||
#if CC_USE_PHYSICS
|
||||
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
NS_CC_BEGIN
|
||||
|
||||
class PhysicsContact;
|
||||
class PhysicsContactInfo
|
||||
{
|
||||
public:
|
||||
inline PhysicsContact* getContact() const { return _contact; }
|
||||
|
||||
private:
|
||||
PhysicsContactInfo(PhysicsContact* contact);
|
||||
~PhysicsContactInfo();
|
||||
|
||||
private:
|
||||
PhysicsContact* _contact;
|
||||
|
||||
friend class PhysicsContact;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_USE_PHYSICS
|
||||
#endif // __CCPHYSICS_CONTACT_INFO_CHIPMUNK_H__
|
|
@ -1,85 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
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 "CCPhysicsJointInfo_chipmunk.h"
|
||||
#if CC_USE_PHYSICS
|
||||
#include <algorithm>
|
||||
#include <unordered_map>
|
||||
#include "chipmunk.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
std::unordered_map<cpConstraint*, PhysicsJointInfo*> PhysicsJointInfo::_map;
|
||||
|
||||
PhysicsJointInfo::PhysicsJointInfo(PhysicsJoint* joint)
|
||||
: _joint(joint)
|
||||
{
|
||||
}
|
||||
|
||||
PhysicsJointInfo::~PhysicsJointInfo()
|
||||
{
|
||||
for (cpConstraint* joint : _joints)
|
||||
{
|
||||
cpConstraintFree(joint);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsJointInfo::add(cpConstraint* joint)
|
||||
{
|
||||
if (joint == nullptr) return;
|
||||
|
||||
_joints.push_back(joint);
|
||||
_map.insert(std::pair<cpConstraint*, PhysicsJointInfo*>(joint, this));
|
||||
}
|
||||
|
||||
void PhysicsJointInfo::remove(cpConstraint* joint)
|
||||
{
|
||||
if (joint == nullptr) return;
|
||||
|
||||
auto it = std::find(_joints.begin(), _joints.end(), joint);
|
||||
if (it != _joints.end())
|
||||
{
|
||||
_joints.erase(it);
|
||||
|
||||
auto mit = _map.find(joint);
|
||||
if (mit != _map.end()) _map.erase(mit);
|
||||
|
||||
cpConstraintFree(joint);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsJointInfo::removeAll()
|
||||
{
|
||||
for (cpConstraint* joint : _joints)
|
||||
{
|
||||
auto mit = _map.find(joint);
|
||||
if (mit != _map.end()) _map.erase(mit);
|
||||
cpConstraintFree(joint);
|
||||
}
|
||||
|
||||
_joints.clear();
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
#endif // CC_USE_PHYSICS
|
|
@ -1,65 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
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 __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__
|
||||
#define __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__
|
||||
|
||||
#include "base/ccConfig.h"
|
||||
#if CC_USE_PHYSICS
|
||||
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
struct cpConstraint;
|
||||
NS_CC_BEGIN
|
||||
|
||||
class PhysicsJoint;
|
||||
|
||||
class PhysicsJointInfo
|
||||
{
|
||||
public:
|
||||
void add(cpConstraint* shape);
|
||||
void remove(cpConstraint* shape);
|
||||
void removeAll();
|
||||
|
||||
PhysicsJoint* getJoint() const { return _joint; }
|
||||
std::vector<cpConstraint*>& getJoints() { return _joints; }
|
||||
static std::unordered_map<cpConstraint*, PhysicsJointInfo*>& getMap() { return _map; }
|
||||
|
||||
protected:
|
||||
PhysicsJointInfo(PhysicsJoint* joint);
|
||||
~PhysicsJointInfo();
|
||||
|
||||
std::vector<cpConstraint*> _joints;
|
||||
PhysicsJoint* _joint;
|
||||
static std::unordered_map<cpConstraint*, PhysicsJointInfo*> _map;
|
||||
|
||||
friend class PhysicsJoint;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_USE_PHYSICS
|
||||
#endif // __CCPHYSICS_JOINT_INFO_CHIPMUNK_H__
|
|
@ -1,118 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
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 "CCPhysicsShapeInfo_chipmunk.h"
|
||||
#if CC_USE_PHYSICS
|
||||
#include <algorithm>
|
||||
#include <unordered_map>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
std::unordered_map<cpShape*, PhysicsShapeInfo*> PhysicsShapeInfo::_map;
|
||||
cpBody* PhysicsShapeInfo::_sharedBody = nullptr;
|
||||
|
||||
PhysicsShapeInfo::PhysicsShapeInfo(PhysicsShape* shape)
|
||||
: _shape(shape)
|
||||
, _group(CP_NO_GROUP)
|
||||
{
|
||||
if (_sharedBody == nullptr)
|
||||
{
|
||||
_sharedBody = cpBodyNewStatic();
|
||||
}
|
||||
|
||||
_body = _sharedBody;
|
||||
}
|
||||
|
||||
PhysicsShapeInfo::~PhysicsShapeInfo()
|
||||
{
|
||||
for (auto shape : _shapes)
|
||||
{
|
||||
auto it = _map.find(shape);
|
||||
if (it != _map.end()) _map.erase(shape);
|
||||
|
||||
cpShapeFree(shape);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsShapeInfo::setGroup(cpGroup group)
|
||||
{
|
||||
this->_group = group;
|
||||
|
||||
for (cpShape* shape : _shapes)
|
||||
{
|
||||
cpShapeSetGroup(shape, group);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsShapeInfo::setBody(cpBody* body)
|
||||
{
|
||||
if (this->_body != body)
|
||||
{
|
||||
this->_body = body;
|
||||
for (cpShape* shape : _shapes)
|
||||
{
|
||||
cpShapeSetBody(shape, body == nullptr ? _sharedBody : body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsShapeInfo::add(cpShape* shape)
|
||||
{
|
||||
if (shape == nullptr) return;
|
||||
|
||||
cpShapeSetGroup(shape, _group);
|
||||
_shapes.push_back(shape);
|
||||
_map.insert(std::pair<cpShape*, PhysicsShapeInfo*>(shape, this));
|
||||
}
|
||||
|
||||
void PhysicsShapeInfo::remove(cpShape* shape)
|
||||
{
|
||||
if (shape == nullptr) return;
|
||||
|
||||
auto it = std::find(_shapes.begin(), _shapes.end(), shape);
|
||||
if (it != _shapes.end())
|
||||
{
|
||||
_shapes.erase(it);
|
||||
|
||||
auto mit = _map.find(shape);
|
||||
if (mit != _map.end()) _map.erase(mit);
|
||||
|
||||
cpShapeFree(shape);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsShapeInfo::removeAll()
|
||||
{
|
||||
for (cpShape* shape : _shapes)
|
||||
{
|
||||
auto mit = _map.find(shape);
|
||||
if (mit != _map.end()) _map.erase(mit);
|
||||
cpShapeFree(shape);
|
||||
}
|
||||
|
||||
_shapes.clear();
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
#endif // CC_USE_PHYSICS
|
|
@ -1,73 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
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 __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__
|
||||
#define __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__
|
||||
|
||||
#include "base/ccConfig.h"
|
||||
#if CC_USE_PHYSICS
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
#include "chipmunk.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class PhysicsShape;
|
||||
|
||||
class PhysicsShapeInfo
|
||||
{
|
||||
public:
|
||||
void add(cpShape* shape);
|
||||
void remove(cpShape* shape);
|
||||
void removeAll();
|
||||
void setGroup(cpGroup group);
|
||||
void setBody(cpBody* body);
|
||||
|
||||
PhysicsShape* getShape() const { return _shape; }
|
||||
std::vector<cpShape*>& getShapes() { return _shapes; }
|
||||
cpBody* getBody() const { return _body; }
|
||||
cpGroup getGourp() const { return _group; }
|
||||
static std::unordered_map<cpShape*, PhysicsShapeInfo*>& getMap() { return _map; }
|
||||
static cpBody* getSharedBody() { return _sharedBody; }
|
||||
|
||||
protected:
|
||||
PhysicsShapeInfo(PhysicsShape* shape);
|
||||
~PhysicsShapeInfo();
|
||||
|
||||
std::vector<cpShape*> _shapes;
|
||||
PhysicsShape* _shape;
|
||||
cpBody* _body;
|
||||
cpGroup _group;
|
||||
static std::unordered_map<cpShape*, PhysicsShapeInfo*> _map;
|
||||
static cpBody* _sharedBody;
|
||||
|
||||
friend class PhysicsShape;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_USE_PHYSICS
|
||||
#endif // __CCPHYSICS_SHAPE_INFO_CHIPMUNK_H__
|
|
@ -1,112 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
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 "CCPhysicsWorldInfo_chipmunk.h"
|
||||
#if CC_USE_PHYSICS
|
||||
#include "CCPhysicsHelper_chipmunk.h"
|
||||
#include "CCPhysicsBodyInfo_chipmunk.h"
|
||||
#include "CCPhysicsShapeInfo_chipmunk.h"
|
||||
#include "CCPhysicsJointInfo_chipmunk.h"
|
||||
#include "chipmunk.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
PhysicsWorldInfo::PhysicsWorldInfo()
|
||||
{
|
||||
_space = cpSpaceNew();
|
||||
}
|
||||
|
||||
PhysicsWorldInfo::~PhysicsWorldInfo()
|
||||
{
|
||||
cpSpaceFree(_space);
|
||||
}
|
||||
|
||||
void PhysicsWorldInfo::setGravity(const Vect& gravity)
|
||||
{
|
||||
cpSpaceSetGravity(_space, PhysicsHelper::point2cpv(gravity));
|
||||
}
|
||||
|
||||
void PhysicsWorldInfo::addBody(PhysicsBodyInfo& body)
|
||||
{
|
||||
if (!cpSpaceContainsBody(_space, body.getBody()))
|
||||
{
|
||||
cpSpaceAddBody(_space, body.getBody());
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorldInfo::removeBody(PhysicsBodyInfo& body)
|
||||
{
|
||||
if (cpSpaceContainsBody(_space, body.getBody()))
|
||||
{
|
||||
cpSpaceRemoveBody(_space, body.getBody());
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorldInfo::addShape(PhysicsShapeInfo& shape)
|
||||
{
|
||||
for (auto cps : shape.getShapes())
|
||||
{
|
||||
cpSpaceAddShape(_space, cps);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorldInfo::removeShape(PhysicsShapeInfo& shape)
|
||||
{
|
||||
for (auto cps : shape.getShapes())
|
||||
{
|
||||
if (cpSpaceContainsShape(_space, cps))
|
||||
{
|
||||
cpSpaceRemoveShape(_space, cps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorldInfo::addJoint(PhysicsJointInfo& joint)
|
||||
{
|
||||
for (auto subjoint : joint.getJoints())
|
||||
{
|
||||
cpSpaceAddConstraint(_space, subjoint);
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorldInfo::removeJoint(PhysicsJointInfo& joint)
|
||||
{
|
||||
for (auto subjoint : joint.getJoints())
|
||||
{
|
||||
cpSpaceRemoveConstraint(_space, subjoint);
|
||||
}
|
||||
}
|
||||
|
||||
bool PhysicsWorldInfo::isLocked()
|
||||
{
|
||||
return 0 == _space->locked_private ? false : true;
|
||||
}
|
||||
|
||||
void PhysicsWorldInfo::step(float delta)
|
||||
{
|
||||
cpSpaceStep(_space, delta);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
#endif // CC_USE_PHYSICS
|
|
@ -1,71 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
|
||||
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 __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__
|
||||
#define __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__
|
||||
|
||||
#include "base/ccConfig.h"
|
||||
#if CC_USE_PHYSICS
|
||||
|
||||
#include <vector>
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
#include "math/CCGeometry.h"
|
||||
|
||||
struct cpSpace;
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
typedef Vec2 Vect;
|
||||
class PhysicsBodyInfo;
|
||||
class PhysicsJointInfo;
|
||||
class PhysicsShapeInfo;
|
||||
|
||||
class PhysicsWorldInfo
|
||||
{
|
||||
public:
|
||||
cpSpace* getSpace() const { return _space; }
|
||||
void addShape(PhysicsShapeInfo& shape);
|
||||
void removeShape(PhysicsShapeInfo& shape);
|
||||
void addBody(PhysicsBodyInfo& body);
|
||||
void removeBody(PhysicsBodyInfo& body);
|
||||
void addJoint(PhysicsJointInfo& joint);
|
||||
void removeJoint(PhysicsJointInfo& joint);
|
||||
void setGravity(const Vect& gravity);
|
||||
bool isLocked();
|
||||
void step(float delta);
|
||||
|
||||
private:
|
||||
PhysicsWorldInfo();
|
||||
~PhysicsWorldInfo();
|
||||
|
||||
private:
|
||||
cpSpace* _space;
|
||||
|
||||
friend class PhysicsWorld;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // CC_USE_PHYSICS
|
||||
#endif // __CCPHYSICS_WORLD_INFO_CHIPMUNK_H__
|
|
@ -779,9 +779,8 @@ std::string FileUtils::fullPathForFilename(const std::string &filename)
|
|||
CCLOG("cocos2d: fullPathForFilename: No file found at %s. Possible missing file.", filename.c_str());
|
||||
}
|
||||
|
||||
// FIXME: Should it return nullptr ? or an empty string ?
|
||||
// The file wasn't found, return the file name passed in.
|
||||
return filename;
|
||||
// The file wasn't found, return empty string.
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string FileUtils::fullPathFromRelativeFile(const std::string &filename, const std::string &relativeFile)
|
||||
|
|
|
@ -62,6 +62,127 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
private static Cocos2dxActivity sContext = null;
|
||||
private Cocos2dxVideoHelper mVideoHelper = null;
|
||||
private Cocos2dxWebViewHelper mWebViewHelper = null;
|
||||
|
||||
public class Cocos2dxEGLConfigChooser implements GLSurfaceView.EGLConfigChooser
|
||||
{
|
||||
protected int[] configAttribs;
|
||||
public Cocos2dxEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize)
|
||||
{
|
||||
configAttribs = new int[] {redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize};
|
||||
}
|
||||
public Cocos2dxEGLConfigChooser(int[] attribs)
|
||||
{
|
||||
configAttribs = attribs;
|
||||
}
|
||||
|
||||
public EGLConfig selectConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs, int[] attribs)
|
||||
{
|
||||
for (EGLConfig config : configs) {
|
||||
int d = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_DEPTH_SIZE, 0);
|
||||
int s = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_STENCIL_SIZE, 0);
|
||||
if ((d >= attribs[4]) && (s >= attribs[5])) {
|
||||
int r = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_RED_SIZE, 0);
|
||||
int g = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_GREEN_SIZE, 0);
|
||||
int b = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_BLUE_SIZE, 0);
|
||||
int a = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_ALPHA_SIZE, 0);
|
||||
if ((r >= attribs[0]) && (g >= attribs[1])
|
||||
&& (b >= attribs[2]) && (a >= attribs[3])) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
|
||||
EGLConfig config, int attribute, int defaultValue) {
|
||||
int[] value = new int[1];
|
||||
if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
|
||||
return value[0];
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
|
||||
{
|
||||
int[] numConfigs = new int[1];
|
||||
if(egl.eglGetConfigs(display, null, 0, numConfigs))
|
||||
{
|
||||
EGLConfig[] configs = new EGLConfig[numConfigs[0]];
|
||||
int[] EGLattribs = {
|
||||
EGL10.EGL_RED_SIZE, configAttribs[0],
|
||||
EGL10.EGL_GREEN_SIZE, configAttribs[1],
|
||||
EGL10.EGL_BLUE_SIZE, configAttribs[2],
|
||||
EGL10.EGL_ALPHA_SIZE, configAttribs[3],
|
||||
EGL10.EGL_DEPTH_SIZE, configAttribs[4],
|
||||
EGL10.EGL_STENCIL_SIZE,configAttribs[5],
|
||||
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
|
||||
EGL10.EGL_NONE
|
||||
};
|
||||
int[] choosedConfigNum = new int[1];
|
||||
|
||||
egl.eglChooseConfig(display, EGLattribs, configs, numConfigs[0], choosedConfigNum);
|
||||
if(choosedConfigNum[0]>0)
|
||||
{
|
||||
return selectConfig(egl, display, configs, configAttribs);
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] defaultEGLattribs = {
|
||||
EGL10.EGL_RED_SIZE, 5,
|
||||
EGL10.EGL_GREEN_SIZE, 6,
|
||||
EGL10.EGL_BLUE_SIZE, 5,
|
||||
EGL10.EGL_ALPHA_SIZE, 0,
|
||||
EGL10.EGL_DEPTH_SIZE, 0,
|
||||
EGL10.EGL_STENCIL_SIZE,0,
|
||||
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
|
||||
EGL10.EGL_NONE
|
||||
};
|
||||
int[] defaultEGLattribsAlpha = {
|
||||
EGL10.EGL_RED_SIZE, 4,
|
||||
EGL10.EGL_GREEN_SIZE, 4,
|
||||
EGL10.EGL_BLUE_SIZE, 4,
|
||||
EGL10.EGL_ALPHA_SIZE, 4,
|
||||
EGL10.EGL_DEPTH_SIZE, 0,
|
||||
EGL10.EGL_STENCIL_SIZE,0,
|
||||
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
|
||||
EGL10.EGL_NONE
|
||||
};
|
||||
int[] attribs = null;
|
||||
//choose one can use
|
||||
if(this.configAttribs[3] == 0)
|
||||
{
|
||||
egl.eglChooseConfig(display, defaultEGLattribs, configs, numConfigs[0], choosedConfigNum);
|
||||
attribs = new int[]{5,6,5,0,0,0};
|
||||
}
|
||||
else
|
||||
{
|
||||
egl.eglChooseConfig(display, defaultEGLattribsAlpha, configs, numConfigs[0], choosedConfigNum);
|
||||
attribs = new int[]{4,4,4,4,0,0};
|
||||
}
|
||||
if(choosedConfigNum[0] > 0)
|
||||
{
|
||||
return selectConfig(egl, display, configs, attribs);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.e(DEVICE_POLICY_SERVICE, "Can not select an EGLConfig for rendering.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.e(DEVICE_POLICY_SERVICE, "Can not select an EGLConfig for rendering.");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Context getContext() {
|
||||
return sContext;
|
||||
|
@ -223,128 +344,8 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
|
||||
//this line is need on some device if we specify an alpha bits
|
||||
if(this.mGLContextAttrs[3] > 0) glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
|
||||
|
||||
class cocos2dEGLConfigChooser implements GLSurfaceView.EGLConfigChooser
|
||||
{
|
||||
protected int[] configAttribs;
|
||||
public cocos2dEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize)
|
||||
{
|
||||
configAttribs = new int[] {redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize};
|
||||
}
|
||||
public cocos2dEGLConfigChooser(int[] attribs)
|
||||
{
|
||||
configAttribs = attribs;
|
||||
}
|
||||
|
||||
public EGLConfig selectConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs, int[] attribs)
|
||||
{
|
||||
for (EGLConfig config : configs) {
|
||||
int d = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_DEPTH_SIZE, 0);
|
||||
int s = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_STENCIL_SIZE, 0);
|
||||
if ((d >= attribs[4]) && (s >= attribs[5])) {
|
||||
int r = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_RED_SIZE, 0);
|
||||
int g = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_GREEN_SIZE, 0);
|
||||
int b = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_BLUE_SIZE, 0);
|
||||
int a = findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_ALPHA_SIZE, 0);
|
||||
if ((r >= attribs[0]) && (g >= attribs[1])
|
||||
&& (b >= attribs[2]) && (a >= attribs[3])) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
|
||||
EGLConfig config, int attribute, int defaultValue) {
|
||||
int[] value = new int[1];
|
||||
if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
|
||||
return value[0];
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
|
||||
{
|
||||
int[] numConfigs = new int[1];
|
||||
if(egl.eglGetConfigs(display, null, 0, numConfigs))
|
||||
{
|
||||
EGLConfig[] configs = new EGLConfig[numConfigs[0]];
|
||||
int[] EGLattribs = {
|
||||
EGL10.EGL_RED_SIZE, configAttribs[0],
|
||||
EGL10.EGL_GREEN_SIZE, configAttribs[1],
|
||||
EGL10.EGL_BLUE_SIZE, configAttribs[2],
|
||||
EGL10.EGL_ALPHA_SIZE, configAttribs[3],
|
||||
EGL10.EGL_DEPTH_SIZE, configAttribs[4],
|
||||
EGL10.EGL_STENCIL_SIZE,configAttribs[5],
|
||||
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
|
||||
EGL10.EGL_NONE
|
||||
};
|
||||
int[] choosedConfigNum = new int[1];
|
||||
|
||||
egl.eglChooseConfig(display, EGLattribs, configs, numConfigs[0], choosedConfigNum);
|
||||
if(choosedConfigNum[0]>0)
|
||||
{
|
||||
return selectConfig(egl, display, configs, configAttribs);
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] defaultEGLattribs = {
|
||||
EGL10.EGL_RED_SIZE, 5,
|
||||
EGL10.EGL_GREEN_SIZE, 6,
|
||||
EGL10.EGL_BLUE_SIZE, 5,
|
||||
EGL10.EGL_ALPHA_SIZE, 0,
|
||||
EGL10.EGL_DEPTH_SIZE, 0,
|
||||
EGL10.EGL_STENCIL_SIZE,0,
|
||||
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
|
||||
EGL10.EGL_NONE
|
||||
};
|
||||
int[] defaultEGLattribsAlpha = {
|
||||
EGL10.EGL_RED_SIZE, 4,
|
||||
EGL10.EGL_GREEN_SIZE, 4,
|
||||
EGL10.EGL_BLUE_SIZE, 4,
|
||||
EGL10.EGL_ALPHA_SIZE, 4,
|
||||
EGL10.EGL_DEPTH_SIZE, 0,
|
||||
EGL10.EGL_STENCIL_SIZE,0,
|
||||
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
|
||||
EGL10.EGL_NONE
|
||||
};
|
||||
int[] attribs = null;
|
||||
//choose one can use
|
||||
if(this.configAttribs[3] == 0)
|
||||
{
|
||||
egl.eglChooseConfig(display, defaultEGLattribs, configs, numConfigs[0], choosedConfigNum);
|
||||
attribs = new int[]{5,6,5,0,0,0};
|
||||
}
|
||||
else
|
||||
{
|
||||
egl.eglChooseConfig(display, defaultEGLattribsAlpha, configs, numConfigs[0], choosedConfigNum);
|
||||
attribs = new int[]{4,4,4,4,0,0};
|
||||
}
|
||||
if(choosedConfigNum[0] > 0)
|
||||
{
|
||||
return selectConfig(egl, display, configs, attribs);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.e(DEVICE_POLICY_SERVICE, "Can not select an EGLConfig for rendering.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.e(DEVICE_POLICY_SERVICE, "Can not select an EGLConfig for rendering.");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
cocos2dEGLConfigChooser chooser = new cocos2dEGLConfigChooser(this.mGLContextAttrs);
|
||||
Cocos2dxEGLConfigChooser chooser = new Cocos2dxEGLConfigChooser(this.mGLContextAttrs);
|
||||
glSurfaceView.setEGLConfigChooser(chooser);
|
||||
|
||||
return glSurfaceView;
|
||||
|
|
|
@ -384,7 +384,7 @@ public class Cocos2dxBitmap {
|
|||
i = lastIndexOfSpace + 1; // skip space
|
||||
} else {
|
||||
// Should not exceed the width.
|
||||
if (tempWidth > maxWidth) {
|
||||
if (tempWidth > maxWidth && i != start + 1) {
|
||||
strList.add(string.substring(start, i - 1));
|
||||
// Compute from previous char.
|
||||
--i;
|
||||
|
|
|
@ -184,14 +184,14 @@ public class Cocos2dxHttpURLConnection
|
|||
return null;
|
||||
}
|
||||
|
||||
String header = null;
|
||||
String header = "";
|
||||
|
||||
for (Entry<String, List<String>> entry: headers.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (null == key) {
|
||||
header += listToString(entry.getValue(), ",");
|
||||
header += listToString(entry.getValue(), ",") + "\n";
|
||||
} else {
|
||||
header += key + ":" + listToString(entry.getValue(), ",");
|
||||
header += key + ":" + listToString(entry.getValue(), ",") + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -210,13 +210,16 @@ public class Cocos2dxVideoView extends SurfaceView implements MediaPlayerControl
|
|||
|
||||
private boolean isAssetRouse = false;
|
||||
private String fileName = null;
|
||||
|
||||
private String assetResourceRoot = "assets/";
|
||||
public void setVideoFileName(String path) {
|
||||
if (path.startsWith("/")) {
|
||||
isAssetRouse = false;
|
||||
setVideoURI(Uri.parse(path),null);
|
||||
}
|
||||
else {
|
||||
if (path.startsWith(assetResourceRoot)) {
|
||||
path = path.substring(assetResourceRoot.length());
|
||||
}
|
||||
fileName = path;
|
||||
isAssetRouse = true;
|
||||
setVideoURI(Uri.parse(path),null);
|
||||
|
|
|
@ -189,6 +189,9 @@ static Data getData(const std::string& filename, bool forString)
|
|||
|
||||
msg = msg + filename + ") failed, error code is " + errorCodeBuffer;
|
||||
CCLOG("%s", msg.c_str());
|
||||
|
||||
if (buffer)
|
||||
free(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue