0

as the title indicates, i am trying to add a explosion particle emitter to my sprite that would take place in collision method. here is my code.

if ([heroBullet intersectsNode:enemy]) {

                NSString *firePath2 = [[NSBundle mainBundle] pathForResource:@"MyParticle2" ofType:@"sks"];
                SKEmitterNode *fireEmitter2 = [NSKeyedUnarchiver unarchiveObjectWithFile:firePath2];
                fireEmitter2.position = enemy.position;
                [enemy addChild:fireEmitter2];
                NSLog(@"fire emitter works");

                heroBullet.hidden = YES;
                enemy.hidden = YES;
                continue;
            }

i have played around with the position and zPosition a bit, but can't see the explosion. NSLog says that the code gets executed but i can't see the explosion. can someone guide me to what i am doing wrong? and maybe, how to fix it?

Adrian P
  • 6,479
  • 4
  • 38
  • 55

1 Answers1

1

I think you are hiding enemy, and your emitter is a child of it.. so it may also get hidden.

try adding the emitter as a child of the scene. (you already set it's position to that of the enemy)

Or, try waiting for a little while before hiding the enemy, you could do this with an sKAction waitForDuration..

Joaquin Llaneza
  • 451
  • 2
  • 15
  • i was just about to answer my own question. you are right about that. the emitter had to be added to the scene with self and i was adding it to the enemy. well you did answer it after all even though i realized my mistake. thank you – Adrian P Apr 06 '15 at 16:00