| 101 | } |
| 102 | |
| 103 | bool LevelDebugLayer::init(GJGameLevel* level) |
| 104 | { |
| 105 | if (!BaseGameLayer::init(level)) |
| 106 | return false; |
| 107 | |
| 108 | auto dir = Director::getInstance(); |
| 109 | auto winSize = dir->getWinSize(); |
| 110 | |
| 111 | auto backBtn = MenuItemSpriteExtra::create("GJ_arrow_01_001.png", [this](Node const* btn) { exit(); }); |
| 112 | auto backMenu = Menu::create(backBtn, nullptr); |
| 113 | backMenu->setPosition({25.0f, winSize.height - 22.0f}); |
| 114 | addChild(backMenu); |
| 115 | |
| 116 | _BG = Sprite::create(GameToolbox::getTextureString(fmt::format("game_bg_{:02}_001.png", _levelSettings._bgID))); |
| 117 | if (!_BG) |
| 118 | { |
| 119 | _BG = Sprite::create(GameToolbox::getTextureString(fmt::format("game_bg_{:02}_001.png", 1))); |
| 120 | } |
| 121 | _BG->setStretchEnabled(false); |
| 122 | const Texture2D::TexParams texParams = {backend::SamplerFilter::LINEAR, backend::SamplerFilter::LINEAR, |
| 123 | backend::SamplerAddressMode::REPEAT, backend::SamplerAddressMode::REPEAT}; |
| 124 | _BG->getTexture()->setTexParameters(texParams); |
| 125 | _BG->setTextureRect(Rect(0, 0, 1024 * 5, 1024)); |
| 126 | _BG->setPosition(winSize.x / 2, winSize.y / 4); |
| 127 | addChild(_BG, -100); |
| 128 | |
| 129 | if (_colorChannels.contains(1000)) |
| 130 | _BG->setColor(_colorChannels.at(1000)._color); |
| 131 | |
| 132 | offset = this->_levelSettings.songOffset; |
| 133 | songid = level->_songID; |
| 134 | |
| 135 | scheduleOnce(AX_SCHEDULE_SELECTOR(LevelDebugLayer::playMusic), 0); |
| 136 | scheduleUpdate(); |
| 137 | |
| 138 | return true; |
| 139 | } |
| 140 | |
| 141 | void LevelDebugLayer::onEnter() |
| 142 | { |
no test coverage detected