| 47 | } |
| 48 | |
| 49 | bool DropDownLayer::init(Node* scrollLayer, const char* label) |
| 50 | { |
| 51 | if(!this->initWithColor({0, 0, 0, 0})) return false; |
| 52 | |
| 53 | auto winSize = Director::getInstance()->getWinSize(); |
| 54 | |
| 55 | this->_dropLayer = Layer::create(); |
| 56 | _dropLayer->setPosition({0, this->_dropLayer->getContentSize().height}); |
| 57 | |
| 58 | //menu start |
| 59 | auto menu = Menu::create(); |
| 60 | |
| 61 | auto backSpr = Sprite::createWithSpriteFrameName("GJ_arrow_03_001.png"); |
| 62 | _backBtn = MenuItemSpriteExtra::create(backSpr, [&](Node* btn){ |
| 63 | this->hideLayer(); |
| 64 | }); |
| 65 | |
| 66 | _backBtn->setPosition(menu->convertToNodeSpace({24, winSize.height - 23})); |
| 67 | menu->addChild(_backBtn); |
| 68 | _dropLayer->addChild(menu); |
| 69 | |
| 70 | auto chain1 = Sprite::createWithSpriteFrameName("chain_01_001.png"); |
| 71 | chain1->setPosition({(winSize.width / 2) - 156, winSize.height - 43}); |
| 72 | chain1->setAnchorPoint({0.5f, 0.0f}); |
| 73 | _dropLayer->addChild(chain1); |
| 74 | |
| 75 | auto chain2 = Sprite::createWithSpriteFrameName("chain_01_001.png"); |
| 76 | chain2->setPosition({(winSize.width / 2) + 156, winSize.height - 43}); |
| 77 | chain2->setAnchorPoint({0.5f, 0.0f}); |
| 78 | _dropLayer->addChild(chain2); |
| 79 | |
| 80 | |
| 81 | auto listlayer = ListLayer::create(scrollLayer, label); |
| 82 | listlayer->setPosition({ (winSize.width - 356) / 2, ((winSize.height - 220) / 2) - 5 }); |
| 83 | _dropLayer->addChild(listlayer); |
| 84 | //menu end |
| 85 | |
| 86 | this->addChild(_dropLayer); |
| 87 | |
| 88 | this->customSetup(); |
| 89 | |
| 90 | auto listener = EventListenerTouchOneByOne::create(); |
| 91 | listener->setEnabled(true); |
| 92 | listener->setSwallowTouches(true); |
| 93 | listener->onTouchBegan = [](Touch*, Event*) -> bool { |
| 94 | return true; |
| 95 | }; |
| 96 | Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this); |
| 97 | |
| 98 | return true; |
| 99 | } |
| 100 | |
| 101 | void DropDownLayer::showLayer(bool attachToScene, bool bounce) |
| 102 | { |
no test coverage detected