Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void) smokeEffectAtPosition:(CGPoint)position withDuration:(NSTimeInterval)duration andView:(SKView *)view andPosVector:(CGVector)vector
- {
- SKEmitterNode *emitter = [NSKeyedUnarchiver unarchiveObjectWithFile:[[NSBundle mainBundle] pathForResource:@"SmokeEffect" ofType:@"sks"]];
- emitter.position = position;
- // Calculate the number of particles we need to generate based on the duration
- emitter.particleBirthRate = 100;
- emitter.numParticlesToEmit = duration * emitter.particleBirthRate;
- emitter.particleLifetime = duration;
- emitter.particlePositionRange = vector;
- // Determine the total time needed to run this effect.
- NSTimeInterval totalTime = duration + emitter.particleLifetime + emitter.particleLifetimeRange/2;
- // Run action to remove the emitter from the scene
- if ([self.view isPaused])
- [self.view setPaused:NO];
- [emitter runAction:[SKAction sequence:@[[SKAction waitForDuration:totalTime],
- [SKAction removeFromParent]]]
- completion:^{
- if (![self.view isPaused])
- [self.view setPaused:YES];
- }];
- [self addChild:emitter];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement