码迷,mamicode.com
首页 > 其他好文 > 详细

cocos2d-x-3.x 动作(4)混合动作

时间:2015-12-06 00:15:49      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:

其实说白了就是同时进行多动,比如混合一下移动和旋转

 1 bool HelloWorld::init()
 2 {
 3     if (!Layer::init())
 4     {
 5         return false;
 6     }
 7 
 8     Size visibleSize = Director::getInstance()->getVisibleSize();
 9     Sprite *label = Sprite::create("what.png");
10     label->setPosition(visibleSize.width / 2, visibleSize.height / 2);
11     addChild(label);
12     auto listener = EventListenerTouchOneByOne::create();
13     listener->onTouchBegan = [label](Touch *t, Event *e){
14 
15         if (label->getBoundingBox().containsPoint(t->getLocation())){
16             //label->runAction(MoveTo::create(1, Point(100, 100)));
17             //label -> runAction(MoveBy::create(0.1, Point(-20, -20))->reverse());
18             label->runAction(Spawn::create(MoveBy::create(1, Point(100, 100)),
19                 RotateBy::create(1, 360), NULL));    //此处创建,第一个指将其移动到坐标点,第二个是1s360度,NULL必须加上,否则出错
20         }                                                              //放着这里点一次执行一次可以执行多次
21         return false;
22     };
23     Director::getInstance()->getEventDispatcher()->
24         addEventListenerWithSceneGraphPriority(listener,label);
25                                                                                    //如果放在这里只能直接执行一次
26     //label->runAction(RotateBy::create(1, 180));
27     //label->runAction(Repeat::create(RotateBy::create(1,180),3));
28     //label->runAction(RepeatForever::create(RotateBy::create(1, 360)));
29     return true;
30 }

 

cocos2d-x-3.x 动作(4)混合动作

标签:

原文地址:http://www.cnblogs.com/aprillie/p/5022624.html

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