4
5
6
PointArray*array=PointArray::create(20);
array->addControlPoint(ccp(0,0));
array->addControlPoint(ccp(210,0));
CardinalSplineTo
-
作用:创建一个样条曲线轨迹的动作
-
参数1:完成轨迹所需的时间
-
参数2:控制点的坐标数组
-
拟合度:其值=0,路径最柔和
2
ActionInterval*CardinalSplineTo=CardinalSplineTo::create(3,array,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">sp->runAction(CardinalSplineTo);
|
CardinalSplineBy
-
作用:创建一个样条曲线轨迹的动作
-
参数1:完成轨迹所需的时间
-
参数2:控制点的坐标数组
-
拟合度: 其值= 0 路径最柔和
2
ActionInterval*CardinalSplineBy=CardinalSplineBy::create(3,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">sp->runAction(CardinalSplineBy);
|
CatmullRomTo、CatmullRomBY
-
作用:创建一个样条插值轨迹
-
参数1:完成轨迹的时间
-
参数2:控制点的数组坐标
ActionInterval*catmullRomTo=CatmullRomTo::create(3,array);
sp->runAction(catmullRomTo);
Follow
-
作用:创建一个跟随动作
-
参数1:跟随的目标对象
-
跟随范围,离开范围就不再跟随
创建一个参照物spT
6
7
Sprite*spt=Sprite::create(
"Icon.png"
);
spt->setPosition(ccp(420,40));
addChild(spt);
sp->runAction(MoveTo::create(3,ccp(940,sp->getPositionY())));
Follow*follow=Follow::create(sp,RectMake(0,960,320));
this
->runAction(follow);
|
EaseBounceIn
目标动作
1
ActionInterval*move=MoveTo::create(3,sp->getPositionY()));
|
让目标动作缓慢开始
参数:目标动作
ActionInterval*EaseBounceIn=EaseBounceIn::create(move);
sp->runAction(EaseBounceIn);
EaseBounceOut
ActionInterval*easeBounceOut=EaseBounceOut::create(move);
sp->runAction(easeBounceOut);
EaseBounceInOut
ActionInterval*easeBounceInOut=EaseBounceInOut::create(move);
sp->runAction(easeBounceInOut);
EaseBackIn
ActionInterval*easeBackIn=EaseBackIn::create(move);
sp->runAction(easeBackIn);
EaseBackOut
ActionInterval*easeBackOut=EaseBackOut::create(move);
sp->runAction(easeBackOut);
EaseBackInOut
ActionInterval*easeBackInOut=EaseBackInOut::create(move);
sp->runAction(easeBackInOut);
EaseElasticIn
ActionInterval*easeElasticIn=EaseElasticIn::create(move);
sp->runAction(easeElasticIn);
EaseElasticOut
ActionInterval*easeElasticOut=EaseElasticOut::create(move);
sp->runAction(easeElasticOut);
EaseElasticInOut
ActionInterval *easeElasticInOut = EaseElasticOut::create(move);
sp->runAction(easeElasticInOut);
EaseExponentialIn
ActionInterval*easeExponentialIn=EaseExponentialIn::create(move);
sp->runAction(easeExponentialIn);
EaseExponentialOut
ActionInterval*easeExponentialIn=EaseExponentialOut::create(move);
EaseExponentialInOut
ActionInterval*easeExponentialInOut=EaseExponentialInOut::create(move);
sp->runAction(easeExponentialInOut);
EaseRateAction
-
作用:让目标动作设置速率
-
参数1:目标动作
-
参数2:速率
3
ActionInterval*move=MoveTo::create(5,sp->getPositionY()));
ActionInterval*easeRateAction=EaseRateAction::create(move,3);
sp->runAction(easeRateAction);
|
EaseSineIn
ActionInterval*easeSineIn=EaseSineIn::create(move);
sp->runAction(easeSineIn);
EaseSineOut
ActionInterval*easeSineOut=EaseSineOut::create(move);
sp->runAction(easeSineOut);
EaseSineInOut
ActionInterval*easeSineInOut=EaseSineInOut::create(move);
sp->runAction(easeSineInOut);
Speed
-
作用:让目标动作运行速度加倍
-
参数1:目标动作
-
参数2:倍速
3
ActionInterval*move=MoveTo::create(10,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">Speed*speed=Speed::create(move,100);
sp->runAction(speed);
|
Spawn
-
作用:让多个动作同时执行
-
参数:目标动作的可变参数
5
ActionInterval*scale=ScaleTo::create(2,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">ActionInterval*rotate=RotateTo::create(4,190);
FiniteTimeAction*spawn=Spawn::create(move,scale,rotate,NULL);
sp->runAction(spawn);
|
Sequence
-
作用:让多个动作按照前后顺序逐一执行
-
参数:目标动作的可变参数
4
ActionInterval*move=MoveTo::create(2,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">FiniteTimeAction*seq=Sequence::create(move,NULL);
sp->runAction(seq);
|
扩展如果要对目标动作全部进行方向运动,可以使用如下形式操作
2
FiniteTimeAction*seq=Sequence::create(moveby,scaleby,...NULL);
FiniteTimeAction*reverseseq=Sequence::create(seq,seq->reverse(),NULL)
|
注意Sequence中的所有动作都必须支持reverse函数,否则会出现异常
5
ActionInterval*move=MoveBy::create(2,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">ActionInterval*scale=ScaleBy::create(2,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">FiniteTimeAction*reveseseq=Sequence::create(seq,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">sp->runAction(reveseseq);
|
Repeat
ActionInterval*move2=MoveTo::create(2,ccp(100,100));
FiniteTimeAction*repeat=Repeat::create(seq,3);
sp->runAction(repeat);
RepeatForever
5
ActionInterval*move=MoveTo::create(1,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">ActionInterval*move1=MoveTo::create(1,move1,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">ActionInterval*repeatForever=RepeatForever::create((ActionInterval*)seq);
sp->runAction(repeatForever);
|
CallFunc
4
CallFunc*funcall=CallFunc::create(
,callfunc_selector(HelloWorld::callbackC));
CallFuncN
ActionInterval * move = MoveTo::create(1,sp->getPositionY()));
CallFuncN * funcall= CallFuncN::create(this,callfuncN_selector(HelloWorld::callbackN));
FiniteTimeAction * seq = Sequence::create(move,NULL);
sp->runAction(seq);
CallFuncND
5
CallFuncND*funcall=CallFuncND::create(
void
*)0xbebabeba);
sp->runAction(seq);
return
true
;
|
| |