Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
425 views
in Technique[技术] by (71.8m points)

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

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 spritekit)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use the following to test if a node is in the scene:

if (!intersectsNode(sprite)) {
  println("node is not in the scene")
}

This assumes that self is an SKScene subclass, such as GameScene.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...