Skip to content

Commit 7e1b076

Browse files
committed
Change order of joint creation.
1 parent 07e8bda commit 7e1b076

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

cocos2d-ui/CCBReader/CCBReader.m

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -966,13 +966,24 @@ -(void)readJoint
966966

967967
if([className isEqualToString:@"CCPhysicsPivotJoint"])
968968
{
969+
if([properties[@"motorEnabled"] boolValue])
970+
{
971+
float motorRate = properties[@"motorRate"] ? [properties[@"motorRate"] floatValue] : 1.0f;
972+
CCPhysicsJoint * motorJoint = [CCPhysicsJoint connectedMotorJointWithBodyA:nodeBodyA.physicsBody bodyB:nodeBodyB.physicsBody rate:motorRate];
973+
974+
motorJoint.maxForce = maxForce;
975+
motorJoint.breakingForce = breakingForce;
976+
motorJoint.collideBodies = collideBodies;
977+
}
969978

970979
if([properties[@"dampedSpringEnabled"] boolValue])
971980
{
972981
float restAngle = properties[@"dampedSpringRestAngle"] ? [properties[@"dampedSpringRestAngle"] floatValue] : 0.0f;
973982
restAngle = CC_DEGREES_TO_RADIANS(restAngle);
974983
float stiffness = properties[@"dampedSpringStiffness"] ? [properties[@"dampedSpringStiffness"] floatValue] : 1.0f;
984+
stiffness *= 1000.0f;
975985
float damping = properties[@"dampedSpringDamping"] ? [properties[@"dampedSpringDamping"] floatValue] : 4.0f;
986+
damping *= 100.0f;
976987

977988
CCPhysicsJoint * rotarySpringJoint = [CCPhysicsJoint connectedRotarySpringJointWithBodyA:nodeBodyA.physicsBody bodyB:nodeBodyB.physicsBody restAngle:restAngle stifness:stiffness damping:damping];
978989

@@ -981,11 +992,12 @@ -(void)readJoint
981992
rotarySpringJoint.collideBodies = collideBodies;
982993
}
983994

995+
984996
if([properties[@"limitEnabled"] boolValue])
985997
{
986998
float limitMax = properties[@"limitMax"] ? [properties[@"limitMax"] floatValue] : 90.0f;
987999
limitMax = CC_DEGREES_TO_RADIANS(limitMax);
988-
1000+
9891001
float limitMin = properties[@"limitMin"] ? [properties[@"limitMin"] floatValue] : 0;
9901002
limitMin = CC_DEGREES_TO_RADIANS(limitMin);
9911003

@@ -995,17 +1007,7 @@ -(void)readJoint
9951007
limitJoint.breakingForce = breakingForce;
9961008
limitJoint.collideBodies = collideBodies;
9971009
}
998-
999-
if([properties[@"motorEnabled"] boolValue])
1000-
{
1001-
float motorRate = properties[@"motorRate"] ? [properties[@"motorRate"] floatValue] : 1.0f;
1002-
CCPhysicsJoint * motorJoint = [CCPhysicsJoint connectedMotorJointWithBodyA:nodeBodyA.physicsBody bodyB:nodeBodyB.physicsBody rate:motorRate];
10031010

1004-
motorJoint.maxForce = maxForce;
1005-
motorJoint.breakingForce = breakingForce;
1006-
motorJoint.collideBodies = collideBodies;
1007-
}
1008-
10091011
if([properties[@"ratchetEnabled"] boolValue])
10101012
{
10111013
float ratchetValue = properties[@"ratchetValue"] ? [properties[@"ratchetValue"] floatValue] : 30.0f;
@@ -1036,6 +1038,7 @@ -(void)readJoint
10361038

10371039
BOOL restLengthEnabled = [properties[@"restLengthEnabled"] boolValue];
10381040
float restLength = restLengthEnabled? [properties[@"restLength"] floatValue] : distance;
1041+
10391042
float stiffness = [properties[@"stiffness"] floatValue];
10401043
float damping = [properties[@"damping"] floatValue];
10411044

0 commit comments

Comments
 (0)