码迷,mamicode.com
首页 > 移动开发 > 详细

cocos2dx 动画 二(iOS)

时间:2015-12-20 22:14:50      阅读:295      评论:0      收藏:0      [点我收藏+]

标签:

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

 

cocos2dx 动画 二(iOS)

标签:

原文地址:http://www.cnblogs.com/wanyongjian/p/5061943.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!