Sprite Kit中是否有事件/通知告诉我节点何时离开屏幕? 让我们说当我离开屏幕底部时,我想要一个彩色圆圈出现在顶部。这意味着我需要知道它何时离开屏幕。
答案 0 :(得分:2)
我认为你需要自己检查,
- (void)update:(NSTimeInterval)currentTime {
if (node.position.y > screenHeight+nodeSize){ // need to define first, of course
// do something like NSLog(); or [removeFromParent] or whatever =)
}
}
答案 1 :(得分:1)
精灵套件在精灵离开屏幕时不会生成通知。您需要添加自己的测试。这是一个例子......
- (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;