static void cxTimeLineInit(cxAny pav) { cxTimeLine this = pav; cxNumber last = cxArrayLast(this->times); if(last == NULL){ cxActionStop(this); return; } this->cxAction.duration = cxNumberToFloat(last) + 1.0f; this->index = -1; }
static void cxTimeLineStep(cxAny pav,cxFloat dt,cxFloat time) { cxTimeLine this = pav; cxInt count = cxArrayLength(this->times); for(cxInt i = this->index + 1; i < count; i++){ cxNumber num = cxArrayAtIndex(this->times, i); cxFloat time = cxNumberToFloat(num); if(this->cxAction.durationElapsed >= time){ this->index = i; CX_EVENT_FIRE(this, onTime); continue; } break; } if(this->index == (count - 1)){ cxActionStop(this); } }
CX_METHOD_DEF(cxSpline,Init,void) { CX_ASSERT_VALUE(cxActionGetView(this), cxView, view); cxInt num = cxAnyArrayLength(this->points); if(num < 2){ cxActionStop(this); return; } this->delta = 1.0f/((cxFloat)num - 1.0f); this->diff = cxVec2fv(0, 0); this->prev =cxViewGetPosition(view); cxVec2f p0 = cxSplinePointAt(this, 0); cxVec2f p1 = cxSplinePointAt(this, num - 1); cxFloat angle = cxVec2fRadiansBetween(p1, p0); if(!cxFloatEqu(angle, this->angle)){ this->angle = angle; CX_EVENT_FIRE(this, onAngle); } CX_SUPER(cxAction, this, Init, CX_M(void)); }