Skip to content

Commit db5d747

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into develop
2 parents d231319 + 283ca3c commit db5d747

File tree

75 files changed

+2713
-2230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2713
-2230
lines changed

UnitTests/CCPhysicsTests.m

Lines changed: 150 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,6 @@ -(void)testBodyEachCollisionPair
776776
[physicsNode onExit];
777777
}
778778

779-
780779
//Focusing on Position.
781780
-(void)testKineticBodyBasic1
782781
{
@@ -954,6 +953,156 @@ -(void)testKineticNodeActionsBasic1
954953

955954

956955

956+
-(void)testApplyImpulse
957+
{
958+
CCPhysicsNode *physics = [CCPhysicsNode node];
959+
[physics onEnter];
960+
961+
{
962+
CCNode *node = [CCNode node];
963+
[physics addChild:node];
964+
965+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
966+
node.physicsBody.mass = 5;
967+
968+
node.physicsBody.velocity = ccp(10, 10);
969+
[node.physicsBody applyImpulse:ccp(5, 5)];
970+
XCTAssert(ccpDistance(ccp(11, 11), node.physicsBody.velocity) < 1e-5, @"");
971+
}{
972+
CCNode *node = [CCNode node];
973+
node.rotation = 90;
974+
[physics addChild:node];
975+
976+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
977+
node.physicsBody.mass = 5;
978+
979+
node.physicsBody.velocity = ccp(10, 10);
980+
[node.physicsBody applyImpulse:ccp(5, 5)];
981+
XCTAssert(ccpDistance(ccp(11, 11), node.physicsBody.velocity) < 1e-5, @"");
982+
}{
983+
CCNode *node = [CCNode node];
984+
node.position = ccp(20, 20);
985+
[physics addChild:node];
986+
987+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
988+
node.physicsBody.mass = 5;
989+
990+
node.physicsBody.velocity = ccp(10, 10);
991+
[node.physicsBody applyImpulse:ccp(5, 5) atWorldPoint:node.position];
992+
XCTAssert(ccpDistance(ccp(11, 11), node.physicsBody.velocity) < 1e-5, @"");
993+
}{
994+
CCNode *node = [CCNode node];
995+
node.position = ccp(20, 20);
996+
[physics addChild:node];
997+
998+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
999+
node.physicsBody.mass = 5;
1000+
1001+
node.physicsBody.velocity = ccp(10, 10);
1002+
[node.physicsBody applyImpulse:ccp(5, 5) atLocalPoint:ccp(0, 0)];
1003+
XCTAssert(ccpDistance(ccp(11, 11), node.physicsBody.velocity) < 1e-5, @"");
1004+
}{
1005+
CCNode *node = [CCNode node];
1006+
node.position = ccp(20, 20);
1007+
node.rotation = 90;
1008+
[physics addChild:node];
1009+
1010+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
1011+
node.physicsBody.mass = 5;
1012+
1013+
node.physicsBody.velocity = ccp(10, 10);
1014+
[node.physicsBody applyImpulse:ccp(5, 0) atLocalPoint:ccp(0, 0)];
1015+
XCTAssert(ccpDistance(ccp(10, 9), node.physicsBody.velocity) < 1e-5, @"");
1016+
}{
1017+
CCNode *node = [CCNode node];
1018+
node.position = ccp(20, 20);
1019+
node.rotation = 180;
1020+
[physics addChild:node];
1021+
1022+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
1023+
node.physicsBody.mass = 5;
1024+
1025+
node.physicsBody.velocity = ccp(10, 10);
1026+
[node.physicsBody applyImpulse:ccp(5, 0) atLocalPoint:ccp(0, 1)];
1027+
XCTAssert(ccpDistance(ccp(9, 10), node.physicsBody.velocity) < 1e-5, @"");
1028+
XCTAssertEqualWithAccuracy(node.physicsBody.angularVelocity, -2, 1e-5, @"");
1029+
}
1030+
1031+
[physics onExit];
1032+
}
1033+
1034+
-(void)testApplyForce
1035+
{
1036+
CCPhysicsNode *physics = [CCPhysicsNode node];
1037+
[physics onEnter];
1038+
1039+
{
1040+
CCNode *node = [CCNode node];
1041+
[physics addChild:node];
1042+
1043+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
1044+
node.physicsBody.mass = 5;
1045+
1046+
[node.physicsBody applyForce:ccp(5, 5)];
1047+
XCTAssert(ccpDistance(ccp(5, 5), node.physicsBody.force) < 1e-5, @"");
1048+
}{
1049+
CCNode *node = [CCNode node];
1050+
node.rotation = 90;
1051+
[physics addChild:node];
1052+
1053+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
1054+
node.physicsBody.mass = 5;
1055+
1056+
[node.physicsBody applyForce:ccp(5, 5)];
1057+
XCTAssert(ccpDistance(ccp(5, 5), node.physicsBody.force) < 1e-5, @"");
1058+
}{
1059+
CCNode *node = [CCNode node];
1060+
node.position = ccp(20, 20);
1061+
[physics addChild:node];
1062+
1063+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
1064+
node.physicsBody.mass = 5;
1065+
1066+
[node.physicsBody applyForce:ccp(5, 5) atWorldPoint:node.position];
1067+
XCTAssert(ccpDistance(ccp(5, 5), node.physicsBody.force) < 1e-5, @"");
1068+
}{
1069+
CCNode *node = [CCNode node];
1070+
node.position = ccp(20, 20);
1071+
[physics addChild:node];
1072+
1073+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
1074+
node.physicsBody.mass = 5;
1075+
1076+
[node.physicsBody applyForce:ccp(5, 5) atLocalPoint:ccp(0, 0)];
1077+
XCTAssert(ccpDistance(ccp(5, 5), node.physicsBody.force) < 1e-5, @"");
1078+
}{
1079+
CCNode *node = [CCNode node];
1080+
node.position = ccp(20, 20);
1081+
node.rotation = 90;
1082+
[physics addChild:node];
1083+
1084+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
1085+
node.physicsBody.mass = 5;
1086+
1087+
[node.physicsBody applyForce:ccp(5, 0) atLocalPoint:ccp(0, 0)];
1088+
XCTAssert(ccpDistance(ccp(0, -5), node.physicsBody.force) < 1e-5, @"");
1089+
}{
1090+
CCNode *node = [CCNode node];
1091+
node.position = ccp(20, 20);
1092+
node.rotation = 180;
1093+
[physics addChild:node];
1094+
1095+
node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius:1 andCenter:CGPointZero];
1096+
node.physicsBody.mass = 5;
1097+
1098+
[node.physicsBody applyForce:ccp(5, 0) atLocalPoint:ccp(0, 1)];
1099+
XCTAssert(ccpDistance(ccp(-5, 0), node.physicsBody.force) < 1e-5, @"");
1100+
XCTAssertEqualWithAccuracy(node.physicsBody.torque, -5, 1e-5, @"");
1101+
}
1102+
1103+
[physics onExit];
1104+
}
1105+
9571106
// TODO
9581107
// * Check that body and shape settings are preserved through multiple add/remove cycles and are actually applied to the cpBody.
9591108
// * Check that changing properties before and after adding to an active physics node updates the properties correctly.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0
1+
3.1.0

cocos2d-ios.xcodeproj/project.pbxproj

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@
101101
50F9E8170E1AA34E000E7616 /* ccTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 50F9E8160E1AA34E000E7616 /* ccTypes.h */; };
102102
50FBB2DA117613F500150761 /* CCActionTween.h in Headers */ = {isa = PBXBuildFile; fileRef = 50FBB2D8117613F500150761 /* CCActionTween.h */; };
103103
50FBB2DB117613F500150761 /* CCActionTween.m in Sources */ = {isa = PBXBuildFile; fileRef = 50FBB2D9117613F500150761 /* CCActionTween.m */; };
104-
5B051B1D18FC032F0091CB8C /* CCBAnimationManager+FrameAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B051B1B18FC032F0091CB8C /* CCBAnimationManager+FrameAnimation.h */; };
105-
5B051B1E18FC032F0091CB8C /* CCBAnimationManager+FrameAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B051B1C18FC032F0091CB8C /* CCBAnimationManager+FrameAnimation.m */; };
104+
926B97F31938606D00E345FB /* CCAnimationManager+FrameAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 926B97EE1938606D00E345FB /* CCAnimationManager+FrameAnimation.m */; };
105+
926B97F41938606D00E345FB /* CCAnimationManager+FrameAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 926B97EF1938606D00E345FB /* CCAnimationManager+FrameAnimation.h */; };
106+
926B97F51938606D00E345FB /* CCAnimationManager_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 926B97F01938606D00E345FB /* CCAnimationManager_Private.h */; };
107+
926B97F61938606D00E345FB /* CCAnimationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 926B97F11938606D00E345FB /* CCAnimationManager.m */; };
108+
926B97F71938606D00E345FB /* CCAnimationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 926B97F21938606D00E345FB /* CCAnimationManager.h */; };
106109
9D85671D191B018200573093 /* CCEffectBrightness.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D85671B191B018200573093 /* CCEffectBrightness.h */; };
107110
9D85671E191B018200573093 /* CCEffectBrightness.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D85671C191B018200573093 /* CCEffectBrightness.m */; };
108111
9D856721191B019900573093 /* CCEffectContrast.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D85671F191B019900573093 /* CCEffectContrast.h */; };
@@ -419,8 +422,11 @@
419422
50F9E8160E1AA34E000E7616 /* ccTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = ccTypes.h; sourceTree = "<group>"; };
420423
50FBB2D8117613F500150761 /* CCActionTween.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActionTween.h; sourceTree = "<group>"; };
421424
50FBB2D9117613F500150761 /* CCActionTween.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCActionTween.m; sourceTree = "<group>"; };
422-
5B051B1B18FC032F0091CB8C /* CCBAnimationManager+FrameAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "CCBAnimationManager+FrameAnimation.h"; path = "cocos2d-ui/CCBReader/CCBAnimationManager+FrameAnimation.h"; sourceTree = "<group>"; };
423-
5B051B1C18FC032F0091CB8C /* CCBAnimationManager+FrameAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "CCBAnimationManager+FrameAnimation.m"; path = "cocos2d-ui/CCBReader/CCBAnimationManager+FrameAnimation.m"; sourceTree = "<group>"; };
425+
926B97EE1938606D00E345FB /* CCAnimationManager+FrameAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "CCAnimationManager+FrameAnimation.m"; path = "cocos2d-ui/CCBReader/CCAnimationManager+FrameAnimation.m"; sourceTree = "<group>"; };
426+
926B97EF1938606D00E345FB /* CCAnimationManager+FrameAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "CCAnimationManager+FrameAnimation.h"; path = "cocos2d-ui/CCBReader/CCAnimationManager+FrameAnimation.h"; sourceTree = "<group>"; };
427+
926B97F01938606D00E345FB /* CCAnimationManager_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCAnimationManager_Private.h; path = "cocos2d-ui/CCBReader/CCAnimationManager_Private.h"; sourceTree = "<group>"; };
428+
926B97F11938606D00E345FB /* CCAnimationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CCAnimationManager.m; path = "cocos2d-ui/CCBReader/CCAnimationManager.m"; sourceTree = "<group>"; };
429+
926B97F21938606D00E345FB /* CCAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCAnimationManager.h; path = "cocos2d-ui/CCBReader/CCAnimationManager.h"; sourceTree = "<group>"; };
424430
92FF6C7318F33A2A005B7139 /* CCActionManager_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCActionManager_Private.h; sourceTree = "<group>"; };
425431
9D85671A191AE2CC00573093 /* CCEffectStack_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCEffectStack_Private.h; sourceTree = "<group>"; };
426432
9D85671B191B018200573093 /* CCEffectBrightness.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCEffectBrightness.h; sourceTree = "<group>"; };
@@ -1157,8 +1163,11 @@
11571163
B7D272FA1822F4920054849B /* CCBReader */ = {
11581164
isa = PBXGroup;
11591165
children = (
1160-
5B051B1B18FC032F0091CB8C /* CCBAnimationManager+FrameAnimation.h */,
1161-
5B051B1C18FC032F0091CB8C /* CCBAnimationManager+FrameAnimation.m */,
1166+
926B97EE1938606D00E345FB /* CCAnimationManager+FrameAnimation.m */,
1167+
926B97EF1938606D00E345FB /* CCAnimationManager+FrameAnimation.h */,
1168+
926B97F01938606D00E345FB /* CCAnimationManager_Private.h */,
1169+
926B97F11938606D00E345FB /* CCAnimationManager.m */,
1170+
926B97F21938606D00E345FB /* CCAnimationManager.h */,
11621171
B7D273001822F4AA0054849B /* CCBAnimationManager.h */,
11631172
B7D273011822F4AA0054849B /* CCBAnimationManager.m */,
11641173
B7D273021822F4AA0054849B /* CCBKeyframe.h */,
@@ -1338,10 +1347,10 @@
13381347
B7D273131822F4AA0054849B /* CCBReader.h in Headers */,
13391348
9DF37621191C594A00C6D27A /* CCEffectPixellate.h in Headers */,
13401349
50CB3B0E100AC43A00B7A750 /* CCActionManager.h in Headers */,
1350+
926B97F71938606D00E345FB /* CCAnimationManager.h in Headers */,
13411351
509D0818101E4FCE007E1749 /* CCTiledMap.h in Headers */,
13421352
50F29F6F102053370046CA73 /* base64.h in Headers */,
13431353
50F2A105102094550046CA73 /* ZipUtils.h in Headers */,
1344-
5B051B1D18FC032F0091CB8C /* CCBAnimationManager+FrameAnimation.h in Headers */,
13451354
50CFAC391023660000175934 /* CCTMXXMLParser.h in Headers */,
13461355
50316AA610291280003ACFE7 /* CCRenderTexture.h in Headers */,
13471356
B7D273171822F4AA0054849B /* CCBSequenceProperty.h in Headers */,
@@ -1395,13 +1404,15 @@
13951404
E0BC7DA81342CF27001B4DCC /* CCES2Renderer.h in Headers */,
13961405
B7705FD81831A07B0043CC67 /* OALAudioTrackNotifications.h in Headers */,
13971406
B77060031831A07B0043CC67 /* OALAudioFile.h in Headers */,
1407+
926B97F41938606D00E345FB /* CCAnimationManager+FrameAnimation.h in Headers */,
13981408
D39FA9C818C1BC6B00441627 /* CCShader_Private.h in Headers */,
13991409
A0C20AC8144FDAF700D84B47 /* CCParticleBatchNode.h in Headers */,
14001410
B7705FDF1831A07B0043CC67 /* ObjectALConfig.h in Headers */,
14011411
A046E29314C1DB7D0005BBF2 /* CCDirectorMac.h in Headers */,
14021412
A046E29714C1DB7D0005BBF2 /* CCGLView.h in Headers */,
14031413
A046E29914C1DB7E0005BBF2 /* CCWindow.h in Headers */,
14041414
B791E85E182074C500DAE1D7 /* CCProgressNode.h in Headers */,
1415+
926B97F51938606D00E345FB /* CCAnimationManager_Private.h in Headers */,
14051416
B7EE69E01819E75700B983FE /* CCLayout.h in Headers */,
14061417
A0C87D1A14F9A3A100C0E8B2 /* NSThread+performBlock.h in Headers */,
14071418
B791E84A182064BF00DAE1D7 /* CCTiledMapLayer_Private.h in Headers */,
@@ -1525,6 +1536,7 @@
15251536
buildActionMask = 2147483647;
15261537
files = (
15271538
5018F26A0DFDEAFF00C013A5 /* CCAction.m in Sources */,
1539+
926B97F31938606D00E345FB /* CCAnimationManager+FrameAnimation.m in Sources */,
15281540
5018F26C0DFDEAFF00C013A5 /* CCNode.m in Sources */,
15291541
5018F26E0DFDEAFF00C013A5 /* CCDirector.m in Sources */,
15301542
5018F2700DFDEAFF00C013A5 /* CCActionInstant.m in Sources */,
@@ -1534,6 +1546,7 @@
15341546
B7705FE91831A07B0043CC67 /* ALDevice.m in Sources */,
15351547
5018F2740DFDEAFF00C013A5 /* CCLabelTTF.m in Sources */,
15361548
9D856722191B019900573093 /* CCEffectContrast.m in Sources */,
1549+
926B97F61938606D00E345FB /* CCAnimationManager.m in Sources */,
15371550
5018F2760DFDEAFF00C013A5 /* CCNodeColor.m in Sources */,
15381551
B77060001831A07B0043CC67 /* NSMutableArray+WeakReferences.m in Sources */,
15391552
5018F2780DFDEAFF00C013A5 /* CCScene.m in Sources */,
@@ -1606,7 +1619,6 @@
16061619
A046E29414C1DB7D0005BBF2 /* CCDirectorMac.m in Sources */,
16071620
A046E29814C1DB7D0005BBF2 /* CCGLView.m in Sources */,
16081621
A046E29A14C1DB7E0005BBF2 /* CCWindow.m in Sources */,
1609-
5B051B1E18FC032F0091CB8C /* CCBAnimationManager+FrameAnimation.m in Sources */,
16101622
B7D273121822F4AA0054849B /* CCBLocalizationManager.m in Sources */,
16111623
B7705FFC1831A07B0043CC67 /* IOSVersion.m in Sources */,
16121624
A0C87D1B14F9A3A100C0E8B2 /* NSThread+performBlock.m in Sources */,

0 commit comments

Comments
 (0)