Analog clock with pin joint

Hi all,

I’ve just completed Section II:(Physics and Nodes/Cat Nap) and now trying to deepen my understanding by playing with “Pin Joint”.
I thought that an analog clock would be the easiest study for that purpose. :slight_smile:
However, it’s not working so far. So, I’m not sure if my direction and approach is right…

Do you use SpriteKit when you create a simple analog clock?

My goal is just to spin the clock hand(360 degrees) in accordance with the duration I configure such as 5 sec, 10 sec, 30 sec, and 60 sec.

Code snnipet

import SpriteKit

class ClockNode: SKSpriteNode, CustomNodeEvents {
private var clockBase = SKSpriteNode(imageNamed: “base”)
private var clockHand = SKSpriteNode(imageNamed: “hand”)
private var clockJoint: SKPhysicsJointPin!

func didMoveToScene() {
guard let scene = scene else {
return
}
userInteractionEnabled = true

clockBase.anchorPoint = CGPoint(x: 0.5, y: 0.5)     //center
clockBase.position = position
addChild(clockBase)
clockHand.anchorPoint = CGPoint(x: clockBase.position.x, y: clockBase.position.y)
clockHand.position = position
let pinPoint = CGPoint(x: clockBase.position.x,y: clockBase.position.y)
clockJoint = SKPhysicsJointPin.jointWithBodyA(clockBase.physicsBody!, bodyB: clockHand.parent!.physicsBody!, anchor:  pinPoint)
scene.physicsWorld.addJoint(clockJoint)

//clockHand.physicsBody!.allowsRotation = true
//clockHand.physicsBody!.


addChild(clockHand)

clockHand.physicsBody!.applyImpulse(CGVector(dx: 50, dy: 25))

// let fortyFive = SKAction.rotateToAngle(CGFloat(3.14), duration: NSTimeInterval(1))
// clockHand.runAction(fortyFive)

}
}

Many thanks in advance for your help.

Looks like one of the solutions is to add the followings. :confused:

clockHand.physicsBody!.mass = 0.0
let action = SKAction.rotateByAngle(-CGFloat(M_PI) * 2, duration: 3)  //
clockHand.runAction(action, completion: { 
    print("done")
})