Advertisement
Guest User

Untitled

a guest
Mar 28th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. - (void) smokeEffectAtPosition:(CGPoint)position withDuration:(NSTimeInterval)duration andView:(SKView *)view andPosVector:(CGVector)vector
  2. {
  3. SKEmitterNode *emitter = [NSKeyedUnarchiver unarchiveObjectWithFile:[[NSBundle mainBundle] pathForResource:@"SmokeEffect" ofType:@"sks"]];
  4.  
  5. emitter.position = position;
  6.  
  7. // Calculate the number of particles we need to generate based on the duration
  8. emitter.particleBirthRate = 100;
  9. emitter.numParticlesToEmit = duration * emitter.particleBirthRate;
  10. emitter.particleLifetime = duration;
  11. emitter.particlePositionRange = vector;
  12.  
  13. // Determine the total time needed to run this effect.
  14. NSTimeInterval totalTime = duration + emitter.particleLifetime + emitter.particleLifetimeRange/2;
  15. // Run action to remove the emitter from the scene
  16.  
  17. if ([self.view isPaused])
  18. [self.view setPaused:NO];
  19.  
  20. [emitter runAction:[SKAction sequence:@[[SKAction waitForDuration:totalTime],
  21. [SKAction removeFromParent]]]
  22. completion:^{
  23. if (![self.view isPaused])
  24. [self.view setPaused:YES];
  25. }];
  26. [self addChild:emitter];
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement