protected bool Init(CCPhysicsBody a, CCPhysicsBody b, CCPoint anchr1, CCPoint anchr2, float stiffness, float damping) { if (!base.Init(a, b)) { return(false); } var anch1 = PhysicsHelper.CCPointToCpVect(anchr1); var anch2 = PhysicsHelper.CCPointToCpVect(anchr2); cpConstraint joint = new cpDampedSpring(GetBodyInfo(a).Body, GetBodyInfo(b).Body, anch1, anch2, cpVect.cpvdist( _bodyB.Local2World(anch1), _bodyA.Local2World(anch2)), stiffness, damping); if (joint == null) { return(false); } _info.Add(joint); return(true); }
private void Draw(cpDampedSpring constraint) { var a = constraint.a.LocalToWorld(constraint.GetAnchorA()); var b = constraint.b.LocalToWorld(constraint.GetAnchorB()); DrawSpring(a, b, CONSTRAINT_COLOR); }