1. 不断旋转
CCRotateBy* rotate = CCRotateBy::actionWithDuration(1, 360);
CCRepeatForever* repeatRotate = CCRepeatForever::actionWithAction(rotate);
2. 上升消失
CCMoveBy* move = CCMoveBy::actionWithDuration(2, ccp(0,200));
CCFadeOut* fadeOut = CCFadeOut::actionWithDuration(2);
CCFiniteTimeAction* fadeOutAct = CCSpawn::actions(move,fadeOut,NULL);
3.贝赛而曲线
ccBezierConfig bezier;
bezier.controlPoint_1 = ccp(100,200);
bezier.controlPoint_2 = ccp(200, -100);
bezier.endPosition = ccp(400, 100);
CCBezierBy* bezierBy = CCBezierBy::actionWithDuration(5.0, bezier);
4. 变色
CCTintTo* tint1 = CCTintTo::actionWithDuration(1.5, 255, 0, 0);
CCTintTo* tint2 = CCTintTo::actionWithDuration(1.5, 0, 255, 255);
CCTintTo* tint3 = CCTintTo::actionWithDuration(1.5, 0, 255, 0);
CCFiniteTimeAction* tintActions = CCSequence::actions(tint1,tint2,tint3,NULL);
CCRepeatForever* repeatTint = CCRepeatForever::actionWithAction((CCActionInterval*)tintActions);
CCBlink* blink = CCBlink::actionWithDuration(5, 25);
CCFadeOut* fadeOut = CCFadeOut::actionWithDuration(0.8);
CCCallFunc* endCall = CCCallFunc::actionWithTarget(starSprite, callfunc_selector(FlashingMeteors::removeFromParentAndCleanup));
CCFiniteTimeAction* acts = CCSequence::actions(fadeOut,endCall, NULL);
starSprite->runAction(acts);
动作基础:
cocos2d-x把动作分为basic actions \ composition actions \ ease actions \ effect actions \ special actions \ animation.
通过组合,即可实现各种动画效果。
基本动作: 移动(CCMoveBy,CCMoveTo,CCJumpBy,CCJumpTo), 旋转(CCRotateBy,CCRotateTo), 淡入淡出(CCFadeIn, CCFadeOut...)
复合动作: 顺序执行(CCSequence),同时执行(CCSpawn),重复(CCRepeat,CCRepeatForever).
动作线性: CCEaseIn, CCEaseOut, CCEaseSineIn, CCEaseSineOut等等
特殊动作: 尚不了解,之后写。