How do you tell if a node is on the screen spritekit swift

前端 未结 6 2012
予麋鹿
予麋鹿 2020-12-09 12:48

I am trying to figure out how to determine if a node is visible on the screen or off the screen. Is this just a true/false property of the node? Thanks. (Using swift spritek

6条回答
  •  执念已碎
    2020-12-09 13:33

    the best answer here will be:

    if scene.frame.contains(myNode.position) {
    //do stuff
    }
    

    "intersect" method is very heavy and involves too much computing, can produce lag if used on many instances

提交回复
热议问题