title: Have particle emitter trail follow finger path in spriteKit
body: <p>I have created a particle emitter in Xcode that has quite a lengthy trail. When i move it inside of the particle generator it leaves a trail following my mouse path. </p>
  
  <p><strong>some background info on my goal:</strong>
  In my spriteKit game the user drags their finger around the screen to shoot moving objects. I am attempting to create a "Bullet Time" effect where the objects slow down and highlights when the current finger location touches them. When the finger stops moving or they run out of ammo the touchesEnded method is fired shooting all of the highlighted objects. Currently I have the path that they travel showing up as a line drawn to the screen using SKShapeNode &amp; CGPath, but I would like the trail to be highlighted with the emitter trail instead.</p>
  
  <p>In the touches began method I create a circle SpriteNode that moves around wherever the finger moves to (the physics collision is attached to the circle not the path). I've attached the particle trail emitter to this circle and <strong>it moves with the circle when I move it around the screen, but does not leave a trail.</strong></p>
  
  <pre><code>- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  
      UITouch *touch = [touches anyObject];
      CGPoint touchLocation = [touch locationInNode:self];
  
      pathToDraw = CGPathCreateMutable();
      startPoint = touchLocation;
      CGPathMoveToPoint(pathToDraw, NULL, touchLocation.x, touchLocation.y);
  
      lineNode = [SKShapeNode node];
      lineNode.path = pathToDraw;
      lineNode.lineWidth = 2;
      lineNode.zPosition = 110;
      lineNode.strokeColor = [SKColor whiteColor];
      [self addChild:lineNode];
  
      circle = [SKSpriteNode spriteNodeWithTexture:[animationsAtlas textureNamed:@"anim_countdown_9"]];
      circle.name = @"circle";
      circle.scale = 0.3;
      circle.alpha = 0.5;
      circle.zPosition = 110;
      circle.position = touchLocation;
  
      circle.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:20];
      circle.physicsBody.categoryBitMask = weaponCategory;
      circle.physicsBody.dynamic = NO;
      circle.physicsBody.contactTestBitMask = billyCategory;
      circle.physicsBody.collisionBitMask = 0;
  
      [self addChild:circle];
  
      pathEmitter = [SKEmitterNode skt_emitterNamed:@"FollowPath"];
      //pathEmitter.position = circle.position;
      //pathEmitter.targetNode = self;
      //pathEmitter.scale = 0.2;
      //pathEmitter.zPosition = 60;
      [circle addChild:pathEmitter];
  }
  </code></pre>
  
  <p>In touchesMoved method I move the circle accordingly to the new position</p>
  
  <pre><code>- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
  
  UITouch *touch = [touches anyObject];
  CGPoint currentPoint = [touch locationInNode:self];
  
  circle.position = currentPoint;
  
  SKAction *wtf = [SKAction followPath:pathToDraw asOffset:NO orientToPath:YES duration:0.1];
  //pathEmitter.position = currentPoint;
  //[pathEmitter runAction:wtf];
  //pathEmitter.particleAction = wtf;
  pathEmitter.particleAction = [SKAction moveTo:currentPoint duration:1.0];
  
  CGPathAddLineToPoint(pathToDraw, NULL, currentPoint.x, currentPoint.y);
  
  lineNode.path = pathToDraw;
  </code></pre>
  
  <p>I've tried setting <strong>pathEmitter.targetNode = self;</strong> like this post <a href="https://stackoverflow.com/questions/18986098/making-a-particle-follow-a-path-in-spritekit?rq=1">Making a particle follow a path in spriteKit</a> suggests but then the emitter doesn't appear at all.</p>
  
  <p>and if i set the particleAction to followPath it does not leave a trail either.</p>
  
  <p>In my code you can see I've commented out some lines, basically I've tried every combination of targetNode &amp; particleAction I can think of.</p>
  
  <p>Any suggestions on how I can get the emitter to leave a trail on my finger path?</p>
  
  <p>thanks</p>