Suppose:
- you have an
SKSpriteNode
, node, off doing its own thing - you have implemented an
SKCameraNode
, cam, to dictate what the player can see - node has the function:
func onScreen(camera:SKCameraNode) -> Bool {
if camera.contains(self) { return true }
else { return false }
}
Question How can one add an event listener to node so that when node transitions from within the camera's view to out of the camera's view, it triggers or calls a function?
This looks a bit complicated....
You can add PhysicsBodies to your nodes, and "special boundary" nodes around your camera, then you can use your physics delegate to get notified if your nodes intersect the boundary nodes.