ios - I joined multiple images into a rope. How can I decrease the rope stretchiness? -
i created rope based off this tutorial, except rope has 1 ball attached on each end of rope.
high level: how create rope.
- create array of
sknodes
- append each rope segment (node) array
- add each node screen
- join each node form rope
- (then add ball on each end of rope)
in program move ball around , swing rope around kind of stretchy pendulum.
here's issue: if swing rope around hard, rope stretches much! how can decrease amount rope stretches? don't see method decrease elasticity of body.
if there other information useful please let me know! in advance
you can try these 2 methods. first method increase property frictiontorque
of skphysicsjointpin
class.
the range of values 0.0 1.0. default value 0.0. if value greater default specified, friction applied reduce object’s angular velocity around pin.
an example tutorial followed, before adding joint
scene, modify frictiontorque
:
for in 1...length { let nodea = ropesegments[i - 1] let nodeb = ropesegments[i] let joint = skphysicsjointpin.jointwithbodya(nodea.physicsbody!, bodyb: nodeb.physicsbody!, anchor: cgpointmake(cgrectgetmidx(nodea.frame), cgrectgetminy(nodea.frame))) joint.frictiontorque = 0.5 // add line scene.physicsworld.addjoint(joint) }
the second method limit swing angle of pin joint. after enabling shouldenablelimits
, adjust loweranglelimit
, upperanglelimit
in radians.
read more skphysicsjointpin class reference determining characteristics of pin joint.
Comments
Post a Comment