| 47 | } |
| 48 | |
| 49 | bool AccountLoginLayer::init() |
| 50 | { |
| 51 | if(!PopupLayer::init()) { |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | auto dir = Director::getInstance(); |
| 56 | const auto& winSize = dir->getWinSize(); |
| 57 | |
| 58 | auto bg = ui::Scale9Sprite::create(GameToolbox::getTextureString("GJ_square01.png")); |
| 59 | bg->setContentSize({ 400.0f, 300.0f }); |
| 60 | ax::Vec2 winSizeHalf { winSize / 2 }; |
| 61 | bg->setPosition(winSizeHalf); |
| 62 | _mainLayer->addChild(bg); |
| 63 | |
| 64 | std::string bigFontStr = GameToolbox::getTextureString("bigFont.fnt"); |
| 65 | auto loginLabel = Label::createWithBMFont(bigFontStr, "Login"); |
| 66 | loginLabel->setScale(0.6f); |
| 67 | loginLabel->setPosition({ winSizeHalf.x, (winSizeHalf.y + 150) - 16.0f }); |
| 68 | _mainLayer->addChild(loginLabel); |
| 69 | return true; |
| 70 | |
| 71 | auto cancelBtn = MenuItemSpriteExtra::create(ButtonSprite::create("Cancel"), [](Node*) { |
| 72 | |
| 73 | }); |
| 74 | |
| 75 | auto loginBtn = MenuItemSpriteExtra::create(ButtonSprite::create("Login"), [](Node*) { |
| 76 | |
| 77 | }); |
| 78 | |
| 79 | Menu* menu = Menu::create(cancelBtn, loginBtn, nullptr); |
| 80 | float y = (winSizeHalf.y - 150.0f) + 22.0f; |
| 81 | ax::Vec2 pos {winSizeHalf.x, y + _mainLayer->getPositionY()}; |
| 82 | GameToolbox::alignItemsHorizontally(menu->getChildren(), 15.0f, menu->convertToNodeSpace(pos)); |
| 83 | |
| 84 | _mainLayer->addChild(menu); |
| 85 | |
| 86 | } |
no test coverage detected