Note that there are some explanatory texts on larger screens.

plurals
  1. POCore animation: why can I not composite two animations?
    primarykey
    data
    text
    <p>I am trying to animate a wheel</p> <p>When the finger rests for > 0.1s, the wheel ' pops out ' ie I animate Scale from 1.0 to 1.2. </p> <p>when the finger moves, the wheel rotates with it ( only if it is popped out ). </p> <p>But I'm getting a problem: as soon as it starts to rotate, the scale reduces back to 1.0. </p> <pre><code>- (void) spin: (Direction) direction { float thetaOld = thetaWheel; float k = (direction == AntiClockwise) ? -1 : 1; float t = 2 * M_PI * ( k / 12.0 ); thetaWheel += t; CABasicAnimation * anim = [CABasicAnimation animationWithKeyPath:@"transform"]; anim.fromValue = [NSNumber numberWithDouble: thetaOld]; anim.toValue = [NSNumber numberWithDouble: thetaWheel]; anim.valueFunction = [CAValueFunction functionWithName: kCAValueFunctionRotateZ]; anim.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut]; anim.duration = 0.1f; anim.fillMode = kCAFillModeForwards; anim.removedOnCompletion = NO; [self.wheelLayer addAnimation: anim forKey:@"transform"]; } - (void) popOut { CABasicAnimation * anim = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; anim.fromValue = [NSNumber numberWithDouble: 1.0]; anim.toValue = [NSNumber numberWithDouble: 1.2]; anim.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut]; anim.duration = 0.25f; anim.fillMode = kCAFillModeForwards; anim.removedOnCompletion = NO; [self.wheelLayer addAnimation: anim forKey:@"transform.scale"]; } // doesnt get used yet - (void) popBack { CABasicAnimation * anim = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; anim.fromValue = [NSNumber numberWithDouble: 1.2]; anim.toValue = [NSNumber numberWithDouble: 1.0]; anim.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut]; anim.duration = 0.1f; anim.fillMode = kCAFillModeForwards; anim.removedOnCompletion = NO; [self.wheelLayer addAnimation: anim forKey:@"transform.scale"]; } </code></pre> <p>The last routine is not getting used at this time! So I can't see what is reducing the scale back to 1...</p> <p>it looks like somehow the second animation is overwriting the first one...</p> <p>how to do this properly?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload