Guest User

Untitled

a guest
Feb 22nd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. @IBAction func Destroy () {
  2. for Object in nodesInVicinity(point: bomb.position, tolerance: 80) {
  3. object.removeFromParent()
  4. }
  5. }
  6.  
  7.  
  8. extension SKNode {
  9. private func squareDistanceTo(point: CGPoint) -> CGFloat {
  10. let dx = point.x - position.x
  11. let dy = point.y - position.y
  12.  
  13. return (dx * dx + dy * dy)
  14. }
  15.  
  16. func nodesInVicinity(point: CGPoint, tolerance: CGFloat) -> [SKNode] {
  17. let squareTolerance = tolerance * tolerance
  18.  
  19.  
  20. return children.filter() {
  21. $0.squareDistanceTo(point: point) <= squareTolerance
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment