Starting position for iOS path/curve animation -


i'm animating object using code:

cgrect imageframe = objecttoanimate.frame; cgpoint vieworigin; vieworigin.y = imageframe.origin.y + imageframe.size.height/2; vieworigin.x = imageframe.origin.x + imageframe.size.width/2;  objecttoanimate.layer.position = vieworigin;  // set path movement cakeyframeanimation *pathanimation = [cakeyframeanimation animationwithkeypath:@"position"]; pathanimation.calculationmode = kcaanimationpaced; pathanimation.fillmode = kcafillmodeforwards; pathanimation.removedoncompletion = no; cgmutablepathref curvedpath = cgpathcreatemutable(); cgpathmovetopoint(curvedpath, null, vieworigin.x, vieworigin.y); cgpathaddarc(curvedpath, null, vieworigin.x-[radius intvalue], vieworigin.y, [radius intvalue], 0, degrees_to_radians(115), no); pathanimation.path = curvedpath; pathanimation.duration = 1.0f; cgpathrelease(curvedpath);  //animate 1 curve [objecttoanimate.layer addanimation:pathanimation forkey:@"curvedfalling"]; 

everything works should.

when call similar animation on same object again, object moves original starting position , animates. how can have begin animation spot ended after first animation?

thanks in advance!

objecttoanimate.frame not being changed here. must have update frame here after animation finished because it's being used source next animations. have @ end of code use this:

. . .  //animate 1 curve [objecttoanimate.layer addanimation:pathanimation forkey:@"curvedfalling"];  objecttoanimate.frame.origin.x = vieworigin.x;  objecttoanimate.frame.origin.y = vieworigin.y; 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -