Cocos2dx Animation 2 (iOS) and cocos2dx animation ios
7. bezr Curve
The ccBezierConfig struct is required. set two control points and one end point.
1 ccBezierConfig bc;2 bc.controlPoint_1 = Vec2(400,400);3 bc.controlPoint_2 = Vec2(800,200);4 bc.endPosition = Vec2(900,300);5 6 BezierTo *bz = BezierTo::create(2.0, bc);7 8 spt->runAction(bz);
8. Control animation speed changes
EaseSineIn from slow to fast
EaseSineOut from approaching slow braking effect
EaseSineInOut from slow to fast to slow
Taking MoveTo uniform speed as an example to use EaseSineIn Packaging
1 MoveTo *to = MoveTo::create(2, Vec2(700,500));2 EaseSineIn *in = EaseSineIn::create(to);3 spt->runAction(in);
9. Flashing Animation
Parameter 1: Time
Second parameter: Number of times
1 Blink *bl = Blink::create(2, 5);2 spt->runAction(bl);
10. Sequence)
1 MoveTo *mt = MoveTo::create(2, Vec2(600,300));2 DelayTime *dt = DelayTime::create(2);3 Blink *bl = Blink::create(2, 5);4 Sequence *sq = Sequence::create(mt,dt,bl, NULL);5 spt->runAction(sq);
11. progress bar Animation
1 Sprite *sp1 = Sprite::create("dark.jpg"); 2 sp1->setPosition(Vec2(300,300)); 3 this->addChild(sp1); 4 5 Sprite *sp2 = Sprite::create("light.jpg"); 6 7 ProgressTimer *timer = ProgressTimer::create(sp2); 8 timer->setPosition(Vec2(300,300)); 9 this->addChild(timer);10 11 timer->setType(ProgressTimer::Type::BAR);12 timer->setMidpoint(Vec2(0, 0));13 timer->setBarChangeRate(Vec2(1,0));14 15 ProgressTo *pt = ProgressTo::create(2, 100);16 timer->runAction(pt);
12. Parallel animation (concurrent execution of multiple animations)
1 Sprite *sp1 = Sprite::create("pean.jpg"); 2 sp1->setPosition(Vec2(300,300)); 3 this->addChild(sp1); 4 5 MoveTo *mv = MoveTo::create(2, Vec2(700,300)); 6 RotateBy *rb = RotateBy::create(2, 3600); 7 8 Spawn *sp = Spawn::create(mv,rb, NULL); 9 10 sp1->runAction(sp);
Last one: CallFunc (callback)
1 Sprite * sp1 = Sprite: create ("pean.jpg"); 2 sp1-> setPosition (Vec2 (300,300); 3 this-> addChild (sp1 ); 4 5 MoveTo * mv = MoveTo: create (2, Vec2 (700,300); 6 RotateBy * rb = RotateBy: create (2, 3600 ); 7 8 Spawn * sp = Spawn: create (mv, rb, NULL); 9 10 CallFunc * cf = CallFunc: create ([&] (void) 11 {12 CCLOG ("animation finished"); 13}); 14 Sequence * sq = Sequence: create (sp, cf, NULL ); 15 sp1-> runAction (sq );