I have been trying to work out a way to detect if a SKSpriteNode left the screen but its x axis value is between screen width bounds. I came up with this (with a bit of help from this great community!).
override func update(currentTime: NSTimeInterval) {
super.update(currentTime)
if (node.position.y < node.size.height && node.position.x > self.frame.size.width / 8 && node.position.x < self.frame.size.width - self.frame.size.width / 8){
testFunc()
}
}
Unfortunately I still seem to call this "testFunc" although the node was not between the screen bounds.
Just to make it clear, I need to detect this because in my function the node moves from the top of the screen to the bottom and I only want the function to be called if it reached the bottom and it was actually possible to see the node while going down the screen.
I would highly appreciate every helpful comment or answer!
Aucun commentaire:
Enregistrer un commentaire