简体   繁体   中英

Swift: Event for when node leaves SKCameraNode's view?

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....

您可以将PhysicsBodies添加到您的节点以及摄像机周围的“特殊边界”节点,然后可以使用物理委托来通知您的节点是否与边界节点相交。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM