Note that there are some explanatory texts on larger screens.

plurals
  1. POJumpy CADisplayLink Animation
    primarykey
    data
    text
    <p>As detailed in a previous post (<a href="https://stackoverflow.com/questions/17257252/cabasicanimation-animating-between-two-angles">Here</a>), I'm creating an animation that starts at an initial angle and moves to an ending angle. I've decided to use <code>CADisplayLink</code> for this animation because the animation needs to run as fast as possible during user input, so a <code>CALayer</code> with a <code>CAKeyframeAnimation</code> seemed like it would be too slow to achieve this.</p> <p>After implementing the <code>CADisplayLink</code>, which calls <code>setNeedsDisplay</code>, I do have the animation working, but it looks really bad because it chunks up the difference between endAngle and initialAngle into heavily visible blocks of angles instead of creating a continuous flow from one angle to the next. Here's the current code I have:</p> <pre><code>CGFloat newAngleToAnimate = animationProgress + ((endAngle-initialAngle)/kDrawDuration)*elapsedTime; // Use newAngleToAnimate to draw in drawInContext animationProgress = newAngleToAnimate; // Update the progress for the next frame. </code></pre> <p>Also, <code>kDrawDuration</code> is defined as <code>3.0f</code>, so I want the animation from <code>initialAngle</code> to <code>endAngle</code> to take 3.0 seconds. I break up the full circle (<code>2*M_PI</code> radians) into equal segments by calculating <code>2*M_PI / kNumAnglesInAnimation</code>, and preferably I want to animate one of those angles every frame, but somehow I still have to take <code>kDrawDuration</code> and <code>elapsedTime</code> into account, which I'm just not seeing how to achieve.</p> <p>Thanks for any help with fixing this!</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