ios - SKEmmitterNode not Running after First Time -


i have effect created code below. have wired button fire test. on first press effect works intended. however, on subsequent requests effect never displayed. have determined, via breakpoints, effect being called , on both first , subsequent runs making in completion handler. have checked "totaltime" variable part of runaction , have verified same (2 seconds) both first run , subsequent runs. interesting thing in first run observe several second delay between preceding if statement , break point @ completion handler. subsequent runs, however, there virtually no delay between preceding if , completion handler. again have verified duration 2 seconds on runs. lastly, if comment out [self.view setpaused:yes] in completion handler, effect run every time. again though, , code below, can see scene unpaused prior. pausing scenes way occasional effect , don't want use cpu , battery majority of time when these effects not being generated.

- (void) smokeeffectatposition:(cgpoint)position withduration:(nstimeinterval)duration andview:(skview *)view andposvector:(cgvector)vector {     skemitternode *emitter =  [nskeyedunarchiver unarchiveobjectwithfile:[[nsbundle mainbundle] pathforresource:@"smokeeffect" oftype:@"sks"]];      emitter.position = position;      // calculate number of particles need generate based on duration     emitter.particlebirthrate = 100;     emitter.numparticlestoemit = duration * emitter.particlebirthrate;     emitter.particlelifetime = duration;     emitter.particlepositionrange = vector;      // determine total time needed run effect.     nstimeinterval totaltime = duration + emitter.particlelifetime + emitter.particlelifetimerange/2;     // run action remove emitter scene      if ([self.view ispaused])         [self.view setpaused:no];      [emitter runaction:[skaction sequence:@[[skaction waitforduration:totaltime],                                             [skaction removefromparent]]]             completion:^{                 if (![self.view ispaused])                 [self.view setpaused:yes];             }];     [self addchild:emitter]; } 

after [self addchild:emitter]; add code: [emitter resetsimulation];


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -