1

I have a SKShapenode creating a line that detects collisions but only for the first line. I can continue drawing lines after but only the first line has physics properties. How do I make an array of shape nodes that all will detect collisions? Drawing is working and didBeginContact method is working fine for first collision so I think the problem is in applying the physics category to an array and not just the first one drawn.

    let line = SKShapeNode()
    line.path = path
    line.strokeColor = UIColor.blackColor()
    line.lineWidth = 5

    [self.addChild(line)]
    lineArray.append(line)

    line.physicsBody = SKPhysicsBody(edgeChainFromPath: path)
    line.physicsBody?.dynamic = false
    line.physicsBody?.categoryBitMask = PhysicsCategory.Lines
    line.physicsBody?.contactTestBitMask = PhysicsCategory.Ball
    line.physicsBody?.collisionBitMask = PhysicsCategory.Ball
    line.physicsBody?.usesPreciseCollisionDetection = true
spapp
  • 41
  • 3

0 Answers0