继承结构
常用Action一般都继承自FiniteTimeAction,就是有限时间的动作,这个动作又分两种瞬时动作和持续动作。
//animation 动画
Texture2D* tex = Director::getInstance()->getTextureCache()->addImage("role.png");
Vector
tVec;
for(int i = 0 ;i < 3; i++)
{
SpriteFrame* tframe = SpriteFrame::createWithTexture(tex,Rect(82*i,0,82,103));
tVec.pushBack(tframe);
}
Animation* tanimation = Animation::createWithSpriteFrames(tVec,0.15f);
Animate* tanimate = Animate::create(tanimation);
Sprite* tsp = Sprite::create();
tsp->setPositionX(100);
tsp->setPositionY(150);
tsp->runAction(CCRepeatForever::create(tanimate));
addChild(tsp);
//flipX 横向翻转
// flipY 纵向翻转
// DelayTime 延迟
// hide show 隐藏和显示
FlipX* tflipx = FlipX::create(true);
DelayTime* tdelay = DelayTime::create(1);
Hide* thide = Hide::create();
Show* tshow = Show::create();
Sequence* tsec = Sequence::create(tflipx,tdelay,thide,tdelay->clone(),tshow,nullptr);
tsp->runAction(tsec);
//BezierBy 贝塞尔曲线运动
Sprite* tball = Sprite::create("flyitem.png");
tball->setPosition(100,60);
addChild(tball);
ccBezierConfig tconfig;
tconfig.controlPoint_1 = Point(200,200);
tconfig.controlPoint_2 = Point(400,400);
tconfig.endPosition = Point(350,350);
BezierTo* tbezier = BezierTo::create(2,tconfig);
tball->runAction(tbezier);
//blink fadeTo spawn
Blink* tblink = Blink::create(3,10);
MoveBy* tmoveBy = MoveBy::create(1,Point(100,100));
RotateBy* trotate = RotateBy::create(1,Vertex3F(0,0,360));
Spawn* tspawn = Spawn::create(tmoveBy,trotate,nullptr);
FadeTo* tfade = FadeTo::create(1,100);
CallFunc* tfun = CallFunc::create([&](){CCLOG("11");});
tsec = Sequence::create(tblink,tspawn,tfade,tmoveBy->reverse(),trotate->reverse(),tfun,nullptr);
tball->runAction(tsec);