Hi,
I try to implement easy actions which uses bezier curve to get step time, but one not work unfortunately so. Maybe someone know how to make?
#import "cocos2d.h"
typedef struct {
float startPoint;
float controlPoint_1;
float controlPoint_2;
float endPoint;
} AECCBezierConfig;
@interface AECCEaseBezier : CCActionEase {
AECCBezierConfig _bezier;
}
+ (id) actionWithAction:(CCActionInterval *) action bezier: (AECCBezierConfig) bezier;
- (id) initWithAction:(CCActionInterval *) action bezier: (AECCBezierConfig) bezier;
@end
#import "AECCEaseBezier.h"
@implementation AECCEaseBezier
+ (id) actionWithAction: (CCActionInterval *) action bezier: (AECCBezierConfig) bezier {
return [[[self alloc] initWithAction: action bezier: bezier] autorelease];
}
- (id) initWithAction: (CCActionInterval *) action bezier: (AECCBezierConfig) bezier {
if ((self = [super initWithAction: action])) {
_bezier = bezier;
}
return self;
}
- (id) copyWithZone: (NSZone *) zone {
AECCEaseBezier *action = [super copyWithZone: zone];
action->_bezier = self->_bezier;
return action;
}
- (void) update: (ccTime) t {
[other update: ((1 - t) * (1 - t) * (1 - t) * _bezier.startPoint +
3 * (1 - t) * (1 - t) * t * _bezier.controlPoint_1 +
3 * (1 - t) * t * t * _bezier.controlPoint_2 +
t * t * t * _bezier.endPoint)];
}
@end