Is there a event/notification in Sprite Kit that tells me when a node is leaving the screen? Lets say I want a coloured circle to appear on top when it left the screen at the bottom. Which means I need to know when it is leaving the screen.
You will need to check for yourself I think,
- (void)update:(NSTimeInterval)currentTime {
if (node.position.y > screenHeight+nodeSize){ // need to define first, of course
// do something like NSLog(); or [removeFromParent] or whatever =)
}
}
Sprite kit does not generate a notification when a sprite leaves screen. You will need to add your own test. Here's an example...
- (void) update:(NSTimerInterval)currentTime
{
CGPoint newPosition = CGPointMake(node.position.x, node.position.y);
if (node.position.y > maxY+node.size.y/2) {
newPosition.y = minY;
}
else if (node.position.y < minX-node.size.y/2) {
newPosition.y = maxY;
}
if (node.position.x > maxX+node.size.x/2) {
newPosition.x = minX;
}
else if (node.position.x < minX-node.size.x/2) {
newPosition.x = maxX;
}
node.position = newPosition;
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.