Search code examples
iosswiftsprite-kitskphysicsjoint

SKPhysicsJoint remove connecting line between node


I have this code where I am connecting two nodes, everything working as expected. Question is that I want to remove the connecting blue line between nodes (attached image for ref). How should I do that?

   //This function creates a player sprite node and place it on screen 

   func addPlayer () {
        player = SKShapeNode(circleOfRadius: 30)
        player.position = CGPoint(x: playableArea.midX, y: playableArea.midY - 600)
        player.fillColor = UIColor.black
        player.strokeColor = UIColor.white
        player.lineWidth = 4
        player.physicsBody = SKPhysicsBody(circleOfRadius: 30)
        player.physicsBody?.affectedByGravity = false
        player.physicsBody?.isDynamic = false
        player.name = "characterColor"
        addChild(player)
    }

//This function creates second node and attach it as tail of player node and also joint player and tail node
    func addTail () {
        tail = SKShapeNode(circleOfRadius: 25)
        tail.position = CGPoint(x: player.position.x, y: player.position.y - 60)
        tail.physicsBody = SKPhysicsBody(circleOfRadius: 25)
        tail.fillColor = UIColor.black
        addChild(tail)
        let joint = SKPhysicsJointPin.joint(withBodyA: player!.physicsBody!, bodyB: tail.physicsBody!, anchor: player.position)

        joint.shouldEnableLimits = true
        joint.lowerAngleLimit = 0
        joint.upperAngleLimit = 0
        joint.frictionTorque = 0.1
        physicsWorld.add(joint)
    }

enter image description here


Solution

  • in your GameViewController you have view.showPysics = true this is used for debugging your physics object but you need to turn it off when you don't wan to see it anymore

    you also have framerat eand node count set to true as well

    view.showsFPS = true 
    view.showsNodeCount = true
    

    just turn them to false to not display them anymore