Animation

#ifndef SPINE_ANIMATION_H_

#define SPINE_ANIMATION_H_


namespace cocos2d { namespace extension {


typedef struct Timeline Timeline;

struct Skeleton;


typedef struct {

const char* const name;

float duration;


int timelineCount;

Timeline** timelines;

} Animation;


Animation* Animation_create (const char* name, int timelineCount);

void Animation_dispose (Animation* self);


void Animation_apply (const Animation* self, struct Skeleton* skeleton, float time, int/*bool*/loop);

void Animation_mix (const Animation* self, struct Skeleton* skeleton, float time, int/*bool*/loop, float alpha);


/**/


struct Timeline {

const void* const vtable;

};


void Timeline_dispose (Timeline* self);

void Timeline_apply (const Timeline* self, struct Skeleton* skeleton, float time, float alpha);


/**/


typedef struct {

Timeline super;

float* curves; /* dfx, dfy, ddfx, ddfy, dddfx, dddfy, ... */

} CurveTimeline;


void CurveTimeline_setLinear (CurveTimeline* self, int frameIndex);

void CurveTimeline_setStepped (CurveTimeline* self, int frameIndex);


/* Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next.

 * cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of

 * the difference between the keyframe's values. */

void CurveTimeline_setCurve (CurveTimeline* self, int frameIndex, float cx1, float cy1, float cx2, float cy2);

float CurveTimeline_getCurvePercent (const CurveTimeline* self, int frameIndex, float percent);


/**/


typedef struct BaseTimeline {

CurveTimeline super;

int const framesLength;

float* const frames; /* time, angle, ... for rotate. time, x, y, ... for translate and scale. */

int boneIndex;

} RotateTimeline;


RotateTimeline* RotateTimeline_create (int frameCount);


void RotateTimeline_setFrame (RotateTimeline* self, int frameIndex, float time, float angle);


/**/


typedef struct BaseTimeline TranslateTimeline;


TranslateTimeline* TranslateTimeline_create (int frameCount);


void TranslateTimeline_setFrame (TranslateTimeline* self, int frameIndex, float time, float x, float y);


/**/


typedef struct BaseTimeline ScaleTimeline;


ScaleTimeline* ScaleTimeline_create (int frameCount);


void ScaleTimeline_setFrame (ScaleTimeline* self, int frameIndex, float time, float x, float y);


/**/


typedef struct {

CurveTimeline super;

int const framesLength;

float* const frames; /* time, r, g, b, a, ... */

int slotIndex;

} ColorTimeline;


ColorTimeline* ColorTimeline_create (int frameCount);


void ColorTimeline_setFrame (ColorTimeline* self, int frameIndex, float time, float r, float g, float b, float a);


/**/


typedef struct {

Timeline super;

int const framesLength;

float* const frames; /* time, ... */

int slotIndex;

const char** const attachmentNames;

} AttachmentTimeline;


AttachmentTimeline* AttachmentTimeline_create (int frameCount);


/* @param attachmentName May be 0. */

void AttachmentTimeline_setFrame (AttachmentTimeline* self, int frameIndex, float time, const char* attachmentName);


}} // namespace cocos2d { namespace extension {


#endif /* SPINE_ANIMATION_H_ */


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值