Speed 人工设定速度,还可通过 SetSpeed 不断调整。
函数调用 :
SEL_CallFunc
SEL_CallFuncN
代码示例:
ccBezierConfig bezier;
bezier.controlPoint_1 = Vec2(100, 400);
bezier.controlPoint_2 = Vec2(500,300);
bezier.endPosition = Vec2(visibleSize.width*0.7 , visibleSize.height*0.1);
BezierBy *bezierBy = BezierBy::create(6.0f, bezier);
Action *actBy = bezierBy->reverse();
Sequence *seque = Sequence::create(bezierBy,actBy, NULL);
auto scaleByX = ScaleBy::create(0.2f, 1.5, 1);
Action *scaleX = scaleByX->reverse();
auto scaleByY = ScaleBy::create(0.3f, 1,1.5);
Action *scaleY = scaleByY->reverse();
static int count = 0;
auto callBack = CallFunc::create([=](){
count++;
CCLOG("这是第%d次动画",count);
});
auto sequen = Sequence::create(scaleByX,scaleX,scaleByY,scaleY,callBack, NULL);
Repeat *repeat = Repeat::create(sequen, 12);
Spawn *spawn = Spawn::create(seque,repeat, NULL);
RepeatForever *repeatForever = RepeatForever::create(spawn);
menuItem->runAction(repeatForever);
RotateTo
//// 作用创建一个旋转的动作
//// 参数1:旋转的时间 参数2:旋转饿角度 0 - 360
// CCActionInterval * rotateto = RotateTo::create(2, 90);
// sp->runAction(rotateto); //sp是把一个精灵添加到动作上