I am programming a game using Xcode and test it on the iOS Simulator, using the Sprite Kit.
The SKEmitterNode
I am using seems to cause a memory leak; when the game is running, each time SKEmitterNode
is put on the screen (when drawing an 'explosion'), under the "Show the Debug Navigator" on left, the Memory increases without bound.
Does anyone have a solution to this problem?
The code below is all in MYScene.m
.
My SKEmitterNode is called _EmitterShatterApart
which is an explosion called "ShatterApart.sks". _PositionObject
is an SKSpriteNode that is the object that is exploding. _bgLayer
is the background layer.
@implementation MyScene
{
SKEmitterNode *_EmitterShatterApart;
...
}
-(void)MatchIncorrect
{
...
_EmitterShatterApart = [NSKeyedUnarchiver unarchiveObjectWithFile: [[NSBundle mainBundle] pathForResource:@"ShatterApart" ofType:@"sks"]];
_EmitterShatterApart.position = _PositionsObject.position;
if (!_EmitterShatterApart.parent) {
//[self.particleLayerNode addChild:_EmitterShatterApart];
[_bgLayer addChild:_EmitterShatterApart];
_EmitterShatterApart.userInteractionEnabled=FALSE;
[_EmitterShatterApart resetSimulation];
}
}