ios - Strange-random crash on SKNode addChild -
i have simple class func adding skemitternode on many different occasions.
i cannot reproduce steps when exception occurs. happens , quite randomly. can call method 500 times without error or in cases error can happen after 1 or 2 call, etc.
the problem/exception line is:
root?.addchild(sparks)
below method , stack trace. have no idea how debug this. i've tried many different things without success.
any ideas ?
class func setsimplesparkseffect(root:sknode?, color:uicolor, position:cgpoint) { if cgpointequaltopoint(position, cgpointzero) { return } let sparks = skemitternode(filenamed: "simplesparks") sparks.alpha = gameobjectsdefaultalpha sparks.particlecolorsequence = nil sparks.particlecolorblendfactor = 1.0 sparks.particlecolor = color sparks.position = position sparks.zposition = sparkselementszposition root?.addchild(sparks) sparks.runaction(skaction.waitforduration(nstimeinterval(emmitersimpleshortduration)), completion: { () -> void in sparks.runaction(skaction.fadeoutwithduration(nstimeinterval(factorsparksfadeoutduration)), completion: { () -> void in sparks.removeallactions() sparks.removeallchildren() sparks.removefromparent() }) }) }
and stack trace:
thread : crashed: com.apple.main-thread 0 libc++abi.dylib 0x0000000199944ce4 __dynamic_cast + 52 1 spritekit 0x000000018ab63f58 __15-[sknode scene]_block_invoke + 60 2 spritekit 0x000000018ab63f58 __15-[sknode scene]_block_invoke + 60 3 spritekit 0x000000018ab28038 skcnode::walkup(void (skcnode*, bool*) block_pointer, bool) + 76 4 spritekit 0x000000018ab63eac -[sknode scene] + 132 5 spritekit 0x000000018ab643ac -[sknode insertchild:atindex:] + 356 6 spritekit 0x000000018ab64224 -[sknode addchild:] + 76 7 dodgemaster 0x00000001000f1d80 static dodgiecommon.setsimplesparkseffect(sknode?, color : uicolor, position : cgpoint) -> () (dodgiecommon.swift:275) 8 dodgemaster 0x00000001000d2bc4 gamelevel.(gamelogicgoalerhitmecontact(gamelevel) -> (nsnotification) -> ()).(closure #1) (gamelevel.swift:502) 9 dodgemaster 0x0000000100125018 static helper.(runasynconmain(helper.type) -> (() -> ()) -> ()).(closure #1) (helper.swift:270) 10 dodgemaster 0x00000001000b41c4 thunk (pointoser.swift) 11 libdispatch.dylib 0x000000019aa917b0 _dispatch_call_block_and_release + 24 12 libdispatch.dylib 0x000000019aa91770 _dispatch_client_callout + 16 13 libdispatch.dylib 0x000000019aa96e20 _dispatch_main_queue_callback_4cf + 1844 14 corefoundation 0x000000018574c258 __cfrunloop_is_servicing_the_main_dispatch_queue__ + 12 15 corefoundation 0x000000018574a0c0 __cfrunlooprun + 1628 16 corefoundation 0x0000000185678dc0 cfrunlooprunspecific + 384 17 graphicsservices 0x00000001907cc088 gseventrunmodal + 180 18 uikit 0x000000018ad52f60 uiapplicationmain + 204 19 dodgemaster 0x000000010011de24 main (appdelegate.swift:22) 20 libdyld.dylib 0x000000019aac28b8 start + 4
another person on here had similar problem think may encountering too... i've tailored response on post yours.
let sparksfile: string = nsbundle.mainbundle().pathforresource("simplesparks", oftype: "sks")! let sparks = nskeyedunarchiver.unarchiveobjectwithfile(explosionfile) as! skemitternode sparks.alpha = gameobjectsdefaultalpha sparks.particlecolorsequence = nil sparks.particlecolorblendfactor = 1.0 sparks.particlecolor = color sparks.position = position sparks.zposition = sparkselementszposition self.root?.addchild(sparks)
Comments
Post a Comment