Search code examples
sprite-kitparticles

Particle in SpriteKit does not appear on iPhone simulator


I am using this code to add the Particle :

NSString *explosionPath = [[NSBundle mainBundle] pathForResource:@"Explosion" ofType:@"sks"];
SKEmitterNode *explosion = [NSKeyedUnarchiver unarchiveObjectWithFile:explosionPath];
explosion.position = position;
[self addChild:explosion];

[explosion runAction:[SKAction waitForDuration:2.0] completion:^{
    [explosion removeFromParent];
}];

my Particle is like a fire for explosion, the particle look good in the sprite editor.

when running my game on IOS Simulator, when explosion should appear, there is nothing appear on the screen but, the Nodes number is increased by about 200-300 nodes.

no any flame appear on the screen.

There is any "view" hierarchy ?


Solution

  • If you are getting an increased node count once the emitter is added, chances are it's probably hidden behind another node. Try setting the emitter's zPosition to a higher value.

    explosion.zPosition = 900; // you can go even higher than 900 if needed