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?
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..