ios - SKEmitterNode particles lag at start -
i'm playing around skemitternode in own little game. i'm shooting cannon ball , when ball hits 1 of boxes in scene, box gets destroyed , particle effect simple texture "boom" created make transition when box disappears. problem is, when start emitter expect start emitting particles right away, not case , particle played after short delay of 0.5-1s.
here function creating emitter:
func createparticleemitter(filename: string) -> skemitternode { let path = nsbundle.mainbundle().pathforresource(filename, oftype: "sks") assert(path != nil, "could not find file \(filename)") let obj : anyobject? = nskeyedunarchiver.unarchiveobjectwithfile(path!) assert(obj != nil, "the emiter \(filename) not created") return obj as! skemitternode }
then on collision, function called, position position of dying object, , scene parent scene of dying object:
func addondeathparticles(position: cgpoint, scene : sknode) { var emitter : skemitternode = createparticleemitter("boom") emitter.position = position let seq = [skaction.waitforduration(particle_die_duration, withrange:particle_die_duration_range), skaction.removefromparent()] emitter.runaction(skaction.sequence(seq)) scene.addchild(emitter) }
the action list added make emitter disappear after particle_die_duration random value of particle_die_duration_range.
as understand it, emitter attached scene, should start emitting particles. mentioned @ beginning, not case , particles start appearing after 0.5-1 second. particle created texture scaling , rotating there no delay set (not sure if can that).
did had same behaviour or has suggestion i'm doing wrong? glad :)
cheers, tk
the solution setting advancesimulationtime 1.0 sec. i'm not entirely sure why case, suppose creation "animation" takes time.
anyway, case closed , everyone, lchamp since suggested solution.
Comments
Post a Comment