cocos2d-x-3.x 动作(2)动作反转
其实就是接着动作操作,反正移动而已。
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("0840.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))->reverse()); //注意此处,加入了一个reverse,便可以反转动作。 17 label -> runAction(MoveBy::create(0.1, Point(-10, -10))->reverse()); 18 } 19 return false; 20 }; 21 Director::getInstance()->getEventDispatcher()-> 22 addEventListenerWithSceneGraphPriority(listener, 23 label); 24 return true; 25 }