Reputation: 339
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]]];
}
}
Upvotes: 0
Views: 344
Reputation: 40030
The _EmitterShatterApart
will not be deallocated after you call removeFromParent
action because you are keeping a strong reference to it in a static variable you defined here:
SKEmitterNode *_EmitterShatterApart;
Upvotes: 1