CCAction运动中没有实现椭圆运动或者圆周运动,于是在网上找了很多相关帖子,有一个CCCircleBy可以实现圆周运动,但是当使用CCRepeatForever循环运动时,总是会卡一下,所以在网上有找了一个实现椭圆运动的例子,当长半轴和短半轴相等时,就是圆周运动,这个循环运动倒是不卡。
#include "../actions/CCActionInterval.h" //包含系统延时类动作头文件
#define PI 3.14159
typedef struct _lrTuoyuanConfig{
CCPoint centerPosition; //中心点坐标
float aLength; //长半轴
float cLength; //椭圆c长,也就是半焦距
}lrTuoyuanConfig;
class __declspec(dllexport) LRTuoyuanBy : public CCActionInterval
{
public:
bool initWithDuration(float f, const lrTuoyuanConfig& c);
virtual void update(float time);
public:
static LRTuoyuanBy* actionWithDuration(float t, const lrTuoyuanConfig& c);
static inline float tuoyuanXat(float a, float b