I saw this question and answer:
Have particle emitter trail follow finger path in spriteKit
I guess in general I just want the same but done in Swift. Any suggestions how to cover that code? or how create a new one, so I have a short particles trail following the swipe?
Here's simple code for swift, you'll need to add an sks named "MyParticle".
Right-click on the left sidebar inside xcode, pick new file, pick Resource, Sprite Kit Particle File etc.
I tested it with Fire.
import SpriteKit
class Game: SKScene{
var pathEmitter = SKEmitterNode(fileNamed: "MyParticle")
override func didMoveToView(view: SKView)
{
pathEmitter.position = CGPointMake(-100, -100)
self.addChild(pathEmitter)
pathEmitter.targetNode = self
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
let touch = touches.first as! UITouch
let touchLocation = touch.locationInNode(self)
pathEmitter.position = touchLocation
}
override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {
let touch = touches.first as! UITouch
let touchLocation = touch.locationInNode(self)
pathEmitter.position = touchLocation
}
}