graphics - Why is my animation flickering on iPhone? -


i'm getting random flickers following animation -- looks picture centering 1 frame or before continuing it's supposed doing, , don't know why.

-(void)generatewander{ //nslog(@"generatewander");  if(targetchange==0) {     targetchange=target_length+1;     float destinationangle=((float)random()/rand_max)*2*m_pi;     nslog(@"new destination:  %f",destinationangle);     targety=sin(destinationangle)*target_radius;     targetx=cos(destinationangle)*target_radius;     nslog(@"new target is: %f %f",targetx,targety); } targetchange--; float newvectorx=(targetx-currentx)*vector_scalar; float newvectory=(targety-currenty)*vector_scalar; vectorx+=newvectorx; vectory+=newvectory; if (pow((vectorx*vectorx+vectory*vectory),.5f)>max_speed) {     vectorx*=.5;     vectory*=.5; } float newx=currentx+vectorx; float newy=currenty+vectory; //nslog(@"new position is: %f %f",newx,newy); self.wander=[cakeyframeanimation               animationwithkeypath:@"transform"]; nsvalue *initial = [nsvalue valuewithcatransform3d:                     catransform3dmaketranslation(currentx, currenty, 0.0)]; nsvalue *final = [nsvalue valuewithcatransform3d:                   catransform3dmaketranslation(newx, newy, 0.0)]; self.wander.values = [nsarray arraywithobjects:initial, final, nil]; wander.removedoncompletion=no; wander.duration = animation_time; [self.wander setdelegate:self]; [wander setdelegate:self]; [self.icon removeanimationforkey:@"wander"]; [self.icon addanimation:self.wander forkey:@"wander"]; currentx=newx; currenty=newy; /*currentx=0.0f; currenty=0.0f; vectorx=0.0f; vectory=0.0f; targetx=0.0f; targety=0.0f; targetchange=0;*/    }  - (void)animationdidstop:(caanimation *)theanimation finished:(bool)flag { //nslog(@"animation did stop called"); if (theanimation==[backgroundrays animationforkey:@"rotate"]) {     //nslog(@"rotate detected");     [backgroundrays removeanimationforkey:@"rotate"];//may not necessary, think helps prevent memory leak     [self.backgroundrays addanimation:self.rotate forkey:@"rotate"]; } else if(theanimation==[icon animationforkey:@"wander"]){     [self generatewander]; } } 


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -