I'm trying to put a trail of smoke behind my spaceship. I have the smoketrail worked out as an emitterNode but I can't seem to attach the emitter to the spaceship.
I can't figure out why this doesn't work. I.e. the emitter doesn't show up on screen at all:
var spaceShip: SKSpriteNode?
spaceShip = SKSpriteNode(imageNamed: "ship1.png")
spaceShip!.position = CGPoint(x: Int(arc4random_uniform(UInt32(self.size.width))), y: Int(arc4random_uniform(UInt32(self.size.height))))
let trailEmmiter = SKEmitterNode(fileNamed: "trailParticle.sks")
trailEmmiter!.name = "trailNode"
trailEmmiter!.position = CGPointMake(((plane?.size.width)!/2), ((plane?.size.height)!/2))
trailEmmiter!.zPosition = 100 //much over everything else
spaceShip!.addChild(trailEmmiter!)
self.addChild(spaceShip!)
but this works. I.e. it puts my trail of smoke at a random position on screen.
let trailEmmiter2 = SKEmitterNode(fileNamed: "trailParticle.sks")
trailEmmiter2!.name = "trailNode"
trailEmmiter2!.position = CGPoint(x: Int(arc4random_uniform(UInt32(self.size.width))), y: Int(arc4random_uniform(UInt32(self.size.height))))
trailEmmiter2!.zPosition = 100 //much over everything else
self!.addChild(trailEmmiter2!)
How can I put the trail of smoke behind the spaceship?