Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @IBAction func Destroy () {
- for Object in nodesInVicinity(point: bomb.position, tolerance: 80) {
- object.removeFromParent()
- }
- }
- extension SKNode {
- private func squareDistanceTo(point: CGPoint) -> CGFloat {
- let dx = point.x - position.x
- let dy = point.y - position.y
- return (dx * dx + dy * dy)
- }
- func nodesInVicinity(point: CGPoint, tolerance: CGFloat) -> [SKNode] {
- let squareTolerance = tolerance * tolerance
- return children.filter() {
- $0.squareDistanceTo(point: point) <= squareTolerance
- }
- }
- }
Add Comment
Please, Sign In to add comment