1

我有这个代码,我连接两个节点,一切都按预期工作。问题是我想删除节点之间的连接蓝线(附图为参考)。我该怎么做?

   //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)
    }

在此处输入图像描述

4

1 回答 1

2

在你的 GameViewController 你有view.showPysics = true这个用于调试你的物理对象但是当你不想再看到它时你需要关闭它

您也将帧速率和节点计数设置为 true

view.showsFPS = true 
view.showsNodeCount = true

只需将它们设置为 false 即可不再显示它们

于 2020-05-19T06:44:01.670 回答