Custom SKPhysicsJoint Subclass

128 views Asked by At

I'm currently working with SKPhysicsJointSpring to connect a number of nodes together. I'd like to be able to specify the force using a logarithmic formula, rather than Hooke's law.

Is there a way for me to subclass SKPhysicsJoint to provide my own force calculations? Or must I implement this manually in update(..)?

Many thanks,

1

There are 1 answers

0
rob mayoff On BEST ANSWER

You have to implement it “manually in update”, or some other way. SKPhysicsJoint and its apparent subclasses aren't even real. Try printing one:

:; xcrun swift -framework SpriteKit
"crashlog" and "save_crashlog" command installed, use the "--help" option for detailed help
Welcome to Apple Swift version 2.0 (700.0.52.1 700.0.65). Type :help for assistance.
  1> import SpriteKit
  2> print(SKPhysicsJoint())
<PKPhysicsJoint: 0x1029006b0>
  3> print(SKPhysicsJointSpring())
<PKPhysicsJointDistance: 0x102800530>

You actually get instances of classes from the private PhysicsKit framework, and you can't subclass those classes.