Skip to content

Commit

Permalink
Merge pull request #13 from gdier/master
Browse files Browse the repository at this point in the history
external stiffness property
  • Loading branch information
khanlou committed Mar 11, 2014
2 parents e6dda04 + 5623f6a commit bb0226a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
10 changes: 5 additions & 5 deletions SKBounceAnimation/SKBounceAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

typedef enum {
SKBounceAnimationStiffnessLight,
SKBounceAnimationStiffnessMedium,
SKBounceAnimationStiffnessHeavy
} SKBounceAnimationStiffness;
typedef CGFloat SKBounceAnimationStiffness;

extern SKBounceAnimationStiffness SKBounceAnimationStiffnessLight;
extern SKBounceAnimationStiffness SKBounceAnimationStiffnessMedium;
extern SKBounceAnimationStiffness SKBounceAnimationStiffnessHeavy;

@interface SKBounceAnimation : CAKeyframeAnimation

Expand Down
13 changes: 6 additions & 7 deletions SKBounceAnimation/SKBounceAnimation.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
*/

SKBounceAnimationStiffness SKBounceAnimationStiffnessLight = 5.f;
SKBounceAnimationStiffness SKBounceAnimationStiffnessMedium = .1f;
SKBounceAnimationStiffness SKBounceAnimationStiffnessHeavy = .001f;

@interface SKBounceAnimation (Private)

- (void) createValueArray;
Expand Down Expand Up @@ -123,7 +127,7 @@ - (void) setStiffness:(SKBounceAnimationStiffness)stiffness {
}

- (SKBounceAnimationStiffness) stiffness {
return [[super valueForKey:@"stifnessKey"] integerValue];
return [[super valueForKey:@"stifnessKey"] floatValue];
}

- (void) setShouldOvershoot:(BOOL)newShouldOvershoot {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit bb0226a

Please sign in to comment.