| 78 | } |
| 79 | |
| 80 | bool MenuLayer::init() |
| 81 | { |
| 82 | auto gm = GameManager::getInstance(); |
| 83 | |
| 84 | // gm->set<std::string>("key1", "value"); |
| 85 | // gm->set<bool>("key2", true); |
| 86 | // gm->set<int>("key3", 523423); |
| 87 | |
| 88 | // std::string key = gm->get<std::string>("key1"); |
| 89 | // bool otherKey = gm->get<bool>("key2"); |
| 90 | // int myKey = gm->get<int>("key3"); |
| 91 | |
| 92 | // GameToolbox::log("key1: {}, key2: {}, key3: {}", key, otherKey, myKey); |
| 93 | |
| 94 | |
| 95 | if (!Layer::init()) return false; |
| 96 | |
| 97 | if (music) |
| 98 | { |
| 99 | //AudioEngine::play2d("menuLoop.mp3", true, 0.2f); |
| 100 | music = false; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | //_mgl = MenuGameLayer::create(); |
| 105 | //addChild(_mgl, -1); |
| 106 | |
| 107 | float offsetScale = 1.13F; |
| 108 | const auto& winSize = Director::getInstance()->getWinSize(); |
| 109 | |
| 110 | auto log_oSpr = Sprite::createWithSpriteFrameName("GJ_logo_001.png"); |
| 111 | log_oSpr->setStretchEnabled(false); |
| 112 | //log_oSpr->setPosition({ winSize.width / 2, winSize.height - 100 }); |
| 113 | log_oSpr->setPosition({ winSize.width / 2.f, winSize.height - 50 }); |
| 114 | this->addChild(log_oSpr); |
| 115 | auto playBtn = MenuItemSpriteExtra::create("GJ_playBtn_001.png", [&](Node* btn) { |
| 116 | auto scene = LevelSelectLayer::scene(0); |
| 117 | Director::getInstance()->pushScene(TransitionFade::create(0.5f, scene)); |
| 118 | }); |
| 119 | playBtn->getChildren().at(0)->setAnchorPoint({0.5, 0.5}); |
| 120 | playBtn->setPosition({ 0, 0 }); |
| 121 | |
| 122 | auto garageBtn = MenuItemSpriteExtra::create("GJ_garageBtn_001.png", [=](Node* btn) { |
| 123 | gm->_openedGarage = true; |
| 124 | Director::getInstance()->pushScene(TransitionFade::create(0.5f, GarageLayer::scene())); |
| 125 | }); |
| 126 | |
| 127 | garageBtn->setPosition({-110, 0}); |
| 128 | garageBtn->getChildren().at(0)->setAnchorPoint({0.5, 0.5}); |
| 129 | |
| 130 | auto creatorBtn = MenuItemSpriteExtra::create("GJ_creatorBtn_001.png", [=](Node* btn) { |
| 131 | gm->_openedCreator = true; |
| 132 | Director::getInstance()->pushScene(TransitionFade::create(0.5f, CreatorLayer::scene())); |
| 133 | }); |
| 134 | |
| 135 | creatorBtn->setPosition({110, 0}); |
| 136 | |
| 137 | creatorBtn->getChildren().at(0)->setAnchorPoint({0.5, 0.5}); |
no test coverage detected