This is not going to be the best approach by a performance point of view but if you override the update
method in your scene you will be able to write code that gets executed each frame so.
class GameScene : SKScene {
var arrow : SKSpriteNode?
override func update(currentTime: NSTimeInterval) {
super.update(currentTime)
if let
arrow = arrow,
view = self.view
where
CGRectContainsRect(view.frame, arrow.frame) == false &&
CGRectIntersectsRect(arrow.frame, view.frame) == false {
arrow.removeFromParent()
}
}
}
Considerations
Please keep in mind that every code you write inside the update method is executed each frame (60 times per second on a 60fps game) so you should be very careful about that.
Typical things you don't want to write inside the update
unless it is strictly necessary:
- creation of objects
- big loops
- recursive calls
- any crazy code that requires too much time to be executed
Hope this helps.