@whfissler,您的解释对查明此解决方案有很大帮助。
仅当我有许多 SKSpriteNodes 处于活动状态(气球游戏)时才会发生此错误。在每个气球上单击它都会弹出并添加一个 SKEmitterNode(爆炸)。似乎当爆炸产生的粒子相互接触时,我收到了和你一样的错误。我改变了我的代码:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
SKEmitterNode *explosion = [SKEmitterNode orb_emitterNamed:@"ballonEksplosion"];
CGPoint positionInScene = [touch locationInNode:self];
explosion.position = positionInScene;
SKSpriteNode *touchedSprite;
for ( int i = 0; i < [[self nodesAtPoint:positionInScene] count]; i++)
{
touchedSprite = (SKSpriteNode *)[[self nodesAtPoint:positionInScene] objectAtIndex:i];
if ([touchedSprite.name isEqualToString:@"BALLON"])
{
[(MBDBallon *)touchedSprite popAndRemoveWithSoundEffect];
[self addChild:explosion];
}
}
}
至:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
SKSpriteNode *touchedSprite;
for ( int i = 0; i < [[self nodesAtPoint:positionInScene] count]; i++)
{
touchedSprite = (SKSpriteNode *)[[self nodesAtPoint:positionInScene] objectAtIndex:i];
if ([touchedSprite.name isEqualToString:@"BALLON"])
{
SKEmitterNode *explosion = [SKEmitterNode orb_emitterNamed:@"ballonEksplosion"];
explosion.position = positionInScene;
[(MBDBallon *)touchedSprite popAndRemoveWithSoundEffect];
[self addChild:explosion];
}
}
}
它奏效了。对我来说,似乎我的爆炸 SKEmitterNode 在 SKScene 上一直保持很长时间,因此为 currentPosition 添加另一个 SKEmitterNode 会导致以下问题:
self nodesAtPoint:positionInScene
nodesAtPoint 堆栈。
我不完全理解它,也许这有助于你进一步理解。