cocos2dx 動畫 二(iOS),cocos2dx動畫ios

來源:互聯網
上載者:User

cocos2dx 動畫 二(iOS),cocos2dx動畫ios

7.Bezier曲線

需要ccBezierConfig結構體,設定2個控制點和一個結束點

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.控制動畫速度變化

EaseSineIn由慢到快

EaseSineOut由快到慢 刹車效果

EaseSineInOut由慢到快再到慢

以MoveTo勻速為例 用EaseSineIn封裝

1 MoveTo *to = MoveTo::create(2, Vec2(700,500));2 EaseSineIn *in = EaseSineIn::create(to);3 spt->runAction(in);

9.閃爍動畫

第一參數:時間

第二參數:次數

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.進度條動畫

 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.並行動畫(多個動畫並發執行)

 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);

最後一個:CallFunc (回調)

 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("動畫完");13                                         });14         Sequence *sq = Sequence::create(sp,cf, NULL);15         sp1->runAction(sq);

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.