Swift 4 - upperBound错误&lt; lowerBound和Attemped添加已经拥有父级的SKNode:<sklabelnode>

时间:2018-05-04 04:02:13

标签: swift4

我有两个错误,有一天没有解决它们。

  1. 第一个错误:&#34;线程1:致命错误:无法使用upperBound&lt;形成范围下界&#34;当我添加函数时,在触摸与前一节点相同的节点时添加奖励点。

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    let firstTouch = touches.first!
    let positionOfTouch = firstTouch.location(in: self)
    let tappedNodes = nodes(at: positionOfTouch)
    print (tappedNodes.count)
    let firstNode = tappedNodes.first!
    handleNode(node: firstNode, bonus: 1.0)
    for index in 1...tappedNodes.count-1 {
        let current = tappedNodes[index]
        let previous = tappedNodes[index-1]
        if current.name == previous.name {
            handleNode(node: current, bonus: 2.5)
        }
        else {
            handleNode(node: current, bonus: 1)
        }
    }
    

    }

  2. 第二个错误:&#34;由于未捕获的异常终止应用程序&#39; NSInvalidArgumentException&#39;,原因:&#39;尝试添加已有父级的SKNode:&#34;当我在GameScene中点击气泡时添加消息时出现。

    var tappedScoreLabel : SKLabelNode = {
    let label = SKLabelNode(fontNamed: "Pusab")
    label.fontSize = 60
    label.fontColor = SKColor.white
    label.zPosition = 300
    return label
    

    }()

    func removeTappedNode (_ node : SKNode) {
    self.run(playCorrectSoundEffect)
    node.name = ""
    node.removeAllActions()
    node.run(SKAction.sequence([SKAction.fadeOut(withDuration: 0.3),   SKAction.removeFromParent()]))
    

    }

  3. 请帮帮我。在你的帮助下,我将不胜感激。

    由于

0 个答案:

没有答案