diff --git a/SKBounceAnimation/SKBounceAnimation.h b/SKBounceAnimation/SKBounceAnimation.h index a1b87e0..9da1ed3 100755 --- a/SKBounceAnimation/SKBounceAnimation.h +++ b/SKBounceAnimation/SKBounceAnimation.h @@ -9,11 +9,11 @@ #import #import -typedef enum { - SKBounceAnimationStiffnessLight, - SKBounceAnimationStiffnessMedium, - SKBounceAnimationStiffnessHeavy -} SKBounceAnimationStiffness; +typedef CGFloat SKBounceAnimationStiffness; + +extern SKBounceAnimationStiffness SKBounceAnimationStiffnessLight; +extern SKBounceAnimationStiffness SKBounceAnimationStiffnessMedium; +extern SKBounceAnimationStiffness SKBounceAnimationStiffnessHeavy; @interface SKBounceAnimation : CAKeyframeAnimation diff --git a/SKBounceAnimation/SKBounceAnimation.m b/SKBounceAnimation/SKBounceAnimation.m index 3f6cbc0..7be13c3 100755 --- a/SKBounceAnimation/SKBounceAnimation.m +++ b/SKBounceAnimation/SKBounceAnimation.m @@ -52,6 +52,10 @@ */ +SKBounceAnimationStiffness SKBounceAnimationStiffnessLight = 5.f; +SKBounceAnimationStiffness SKBounceAnimationStiffnessMedium = .1f; +SKBounceAnimationStiffness SKBounceAnimationStiffnessHeavy = .001f; + @interface SKBounceAnimation (Private) - (void) createValueArray; @@ -123,7 +127,7 @@ - (void) setStiffness:(SKBounceAnimationStiffness)stiffness { } - (SKBounceAnimationStiffness) stiffness { - return [[super valueForKey:@"stifnessKey"] integerValue]; + return [[super valueForKey:@"stifnessKey"] floatValue]; } - (void) setShouldOvershoot:(BOOL)newShouldOvershoot { @@ -327,12 +331,7 @@ - (NSArray*) createColorArrayFromRed:(NSArray*)redValues green:(NSArray*)greenVa - (NSArray*) valueArrayForStartValue:(CGFloat)startValue endValue:(CGFloat)endValue { NSInteger steps = 60*self.duration; //60 fps desired - CGFloat stiffnessCoefficient = 0.1f; - if (self.stiffness == SKBounceAnimationStiffnessHeavy) { - stiffnessCoefficient = 0.001f; - } else if (self.stiffness == SKBounceAnimationStiffnessLight) { - stiffnessCoefficient = 5.0f; - } + CGFloat stiffnessCoefficient = self.stiffness; CGFloat alpha = 0; if (startValue == endValue) {