objective c - Couldn't make a particle follow a path in spriteKit -
this animation in xcode skemitter editor (i want achieve on iphone) :
this animation on iphone (i don't want animation):
using code:
let sparkemmiter = skemitternode(filenamed: "fireflies.sks") self.addchild(sparkemmiter) // self skscene var circle: cgpathref? = nil circle = cgpathcreatewithellipseinrect(cgrectmake(400, 200, 200, 200), nil) let followtrack = skaction.followpath(circle!, asoffset: false, orienttopath: true, duration: 3.0) let followtrackforever = skaction.repeatactionforever(followtrack) //sparkemmiter.runaction(followtrackforever) sparkemmiter.particleaction = followtrackforever;
this emitter settings:
i tried both runaction , particleaction referring question, doesn't work wanted to...
-----------------update----------------------------------------------
tried solution mentioned hamobi (still doesn't work) :
//if you: // 1) i'd make sprite , let texture = sktexture(imagenamed: "spark") let mysprite = skspritenode(texture: texture) self.addchild(mysprite) // 2) add emitter in first example child. let sparkemmiter = skemitternode(filenamed: "fireflies.sks") mysprite.addchild(sparkemmiter) // 3) i'd set emitters targetnode scene. sparkemmiter.targetnode = self // 4) i'd animate sprite in arc. var circle: cgpathref? = nil circle = cgpathcreatewithellipseinrect(cgrectmake(400, 200, 200, 200), nil) let followtrack = skaction.followpath(circle!, asoffset: false, orienttopath: true, duration: 3.0) let followtrackforever = skaction.repeatactionforever(followtrack) //sparkemmiter.runaction(followtrackforever) sparkemmiter.particleaction = followtrackforever;
-----------------update 2----------------------------------------------
got it! thx hamobi :d result :d:d
if i'd make sprite , add emitter in first example child. i'd set emitters targetnode scene. i'd animate sprite in arc.
edit:
okay main thing missing should forget using particleaction
. make mysprite
run followtrackforever
action.
heres code
//if you: // 1) i'd make sprite , let texture = sktexture(imagenamed: "spark") let mysprite = skspritenode(texture: texture) mysprite.position = cgpoint(x: self.size.width/2, y: self.size.height/2) self.addchild(mysprite) // 2) add emitter in first example child. let sparkemmiter = skemitternode(filenamed: "fireflies.sks") mysprite.addchild(sparkemmiter) // 3) i'd set emitters targetnode scene. sparkemmiter.targetnode = self // 4) i'd animate sprite in arc. var circle: cgpathref? = nil circle = cgpathcreatewithellipseinrect(cgrectmake(100, 200, 200, 200), nil) let followtrack = skaction.followpath(circle!, asoffset: false, orienttopath: true, duration: 3.0) let followtrackforever = skaction.repeatactionforever(followtrack) mysprite.runaction(followtrackforever)
screenshot of particle
my particle in action
Comments
Post a Comment