0

I am a beginner with Xcode's sprite-kit programming a game for the iPhone. I am having an issue with the SKEmitterNode. Specifically it looks like I have an unbounded memory leak every time the following SKEmitterNode is added even though I use the removeFromParent SKAction. Anyone have a solution to this? Thanks

SKEmitterNode *_EmitterShatterApart; 
...
-(void)ShatterApart
    {
    SKAction *fadeaway = [SKAction fadeOutWithDuration:0.5];
    SKAction *removeFromParent = [SKAction removeFromParent];
    _EmitterShatterApart = [NSKeyedUnarchiver unarchiveObjectWithFile: [[NSBundle mainBundle] pathForResource:@"ShatterApart" ofType:@"sks"]];
    _EmitterShatterApart.position = _NodePlayer.position;    
    if (!_EmitterShatterApart.parent) {
        [_bgLayer addChild:_EmitterShatterApart];
        _EmitterShatterApart.userInteractionEnabled=FALSE;
        [_EmitterShatterApart runAction: [SKAction sequence:@[fadeaway,removeFromParent]]];
    }
}
4

1 回答 1

1

_EmitterShatterApart调用 action 后不会解除分配,因为removeFromParent您在此处定义的静态变量中保留了对它的强引用:

SKEmitterNode *_EmitterShatterApart; 
于 2014-07-19T20:24:46.877 回答