Skip to content

Commit 2a5e72e

Browse files
committed
Merge pull request #562 from crmagicxxx/EaseSineActions
Adding Ease Sine actions Former-commit-id: 481c158
2 parents 4f5eca5 + e2fe2f6 commit 2a5e72e

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

cocos2d/CCActionEase.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,31 @@
5959
@end
6060

6161

62+
#pragma mark - Ease Sine Actions
63+
/**
64+
* This action will start the specified action with an sine effect.
65+
*
66+
* Note: This action doesn't use a bijective function, actions like CCActionSequence might have an unexpected result when used with this action.
67+
*/
68+
@interface CCActionEaseSineIn : CCActionEase <NSCopying>
69+
@end
70+
71+
/**
72+
* This action will start the specified action with an sine effect.
73+
*
74+
* Note: This action doesn't use a bijective function, actions like CCActionSequence might have an unexpected result when used with this action.
75+
*/
76+
@interface CCActionEaseSineOut : CCActionEase <NSCopying>
77+
@end
78+
79+
/**
80+
* This action will start the specified action with an sine effect.
81+
*
82+
* Note: This action doesn't use a bijective function, actions like CCActionSequence might have an unexpected result when used with this action.
83+
*/
84+
@interface CCActionEaseSineInOut : CCActionEase <NSCopying>
85+
@end
86+
6287
/**
6388
* This action will start the specified action with a reversed acceleration.
6489
*

cocos2d/CCActionEase.m

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,47 @@ -(CCActionInterval*) reverse
9393
@end
9494

9595

96+
#pragma mark - Ease Sine Actions
97+
//
98+
// EaseSineIn
99+
//
100+
@implementation CCActionEaseSineIn
101+
-(void) update: (CCTime) t
102+
{
103+
[_inner update:-1*cosf(t * (float)M_PI_2) +1];
104+
}
105+
106+
- (CCActionInterval*) reverse
107+
{
108+
return [CCActionEaseSineOut actionWithAction: [_inner reverse]];
109+
}
110+
@end
111+
112+
//
113+
// EaseSineOut
114+
//
115+
@implementation CCActionEaseSineOut
116+
-(void) update: (CCTime) t
117+
{
118+
[_inner update:sinf(t * (float)M_PI_2)];
119+
}
120+
121+
- (CCActionInterval*) reverse
122+
{
123+
return [CCActionEaseSineIn actionWithAction: [_inner reverse]];
124+
}
125+
@end
126+
127+
//
128+
// EaseSineInOut
129+
//
130+
@implementation CCActionEaseSineInOut
131+
-(void) update: (CCTime) t
132+
{
133+
[_inner update:-0.5f*(cosf( (float)M_PI*t) - 1)];
134+
}
135+
@end
136+
96137
#pragma mark -
97138
#pragma mark EaseRate
98139

0 commit comments

Comments
 (0)