ios - Group animation on multiple objects -


i'm trying animate many bubbles coming out of machine. i'm using basic animation scale bubbles small bubble large 1 , keyframe animation send bubble in curve across screen. these combined group animation.

i have read through can try work, have following 2 problems.

  1. i can't scale animation work keyframe animation when try animate each bubble.
  2. the animation happens them @ same time. i'd see them animated 1 after other, animate together.

here animation code have.

-(void)emitbubbles:(uibutton*)bubblename :(cgrect)rectpassed { bubblename.hidden = no;  // set position , size of each bubble @ head of bubble machine , size (0,0) cgpoint point = (rectpassed.origin); cgrect buttonframe; buttonframe = bubblename.bounds; buttonframe.size = cgsizemake(0, 0); bubblename.bounds = buttonframe; cgrect oldbuttonbounds = bubblename.bounds; cgrect newbuttonbounds = oldbuttonbounds; newbuttonbounds.size = rectpassed.size;  cgfloat animationduration = 0.8f;  // set scaling cabasicanimation *resizeanimation = [cabasicanimation animationwithkeypath:@"bounds.size"]; resizeanimation.fillmode = kcafillmodeforwards; resizeanimation.duration = animationduration; resizeanimation.fromvalue = [nsvalue valuewithcgsize:oldbuttonbounds.size];  resizeanimation.tovalue = [nsvalue valuewithcgsize:newbuttonbounds.size];   // set actual bubble size after animation  bubblename.bounds = newbuttonbounds;  // setup path cgpoint midpoint = cgpointmake(500,50); cgpoint endpoint = cgpointmake(rectpassed.origin.x, rectpassed.origin.y);  cakeyframeanimation *pathanimation = [cakeyframeanimation animationwithkeypath:@"position"]; pathanimation.calculationmode = kcaanimationpaced; cgmutablepathref curvedpath = cgpathcreatemutable(); cgpathmovetopoint(curvedpath, nil, bubblename.bounds.origin.x, bubblename.bounds.origin.y); cgpoint newloc = cgpointmake(745, 200); cgpathmovetopoint(curvedpath, null, newloc.x,newloc.y);  cgpathaddcurvetopoint(curvedpath, null, 745,200,midpoint.x,midpoint.y, endpoint.x, endpoint.y); pathanimation.path = curvedpath;  // set bubble action position after animation bubblename.layer.position = point;  // add scale , path animation group caanimationgroup *group = [caanimationgroup animation]; group.removedoncompletion = yes; [group setanimations:[nsarray arraywithobjects:pathanimation, resizeanimation, nil]]; group.duration = animationduration;  [bubblename.layer addanimation:group forkey:@"nil"]; //savinganimation   cgpathrelease(curvedpath); 

}

i call animation each bubble using

[self emitbubbles:btnbubble1 :cgrectmake(200, 500, 84, 88)]; [self emitbubbles:btnbubble2 :cgrectmake(200, 500, 84, 88)]; 

i have 20 bubbles on screen. size of rect passed final size want bubbles be.

can can each bubble animate separately using scale , keyframe path, without having write above code each bubble?

thanks

ok. think did it.after hours of looking around stackoverflow , other places found bhave objects animate 1 after other. had calculate time according app time. used.

group.begintime = cacurrentmediatime() + animationdelay

to stop animation momentarily appearing @ final position before continuing animation. had use

group.fillmode = kcafillmodebackwards;


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -