| 26 | USING_NS_AX; |
| 27 | |
| 28 | bool GroundLayer::init(int groundID) |
| 29 | { |
| 30 | if (!Layer::init()) return false; |
| 31 | |
| 32 | auto winSize = Director::getInstance()->getWinSize(); |
| 33 | |
| 34 | auto name = fmt::format("groundSquare_{:02}_001.png", groundID); |
| 35 | this->_sprite = Sprite::create(GameToolbox::getTextureString(name)); |
| 36 | if(!this->_sprite) |
| 37 | { |
| 38 | auto name2 = fmt::format("groundSquare_{:02}_001.png", 1); |
| 39 | this->_sprite = Sprite::create(GameToolbox::getTextureString(name)); |
| 40 | } |
| 41 | _sprite->setStretchEnabled(false); |
| 42 | this->m_fOneGroundSize = this->_sprite->getTextureRect().size.width; |
| 43 | this->_sprite->getTexture()->setTexParameters( |
| 44 | {backend::SamplerFilter::NEAREST, backend::SamplerFilter::NEAREST, backend::SamplerAddressMode::REPEAT, |
| 45 | backend::SamplerAddressMode::REPEAT}); |
| 46 | this->_sprite->setTextureRect({0, 0, winSize.width + this->m_fOneGroundSize, _sprite->getTextureRect().size.height}); |
| 47 | this->_sprite->setAnchorPoint({0, 0}); |
| 48 | this->_sprite->setPosition({0, -50}); |
| 49 | this->_sprite->setColor({0, 102, 255}); |
| 50 | this->addChild(this->_sprite); |
| 51 | |
| 52 | auto line = Sprite::createWithSpriteFrameName("floorLine_001.png"); |
| 53 | line->setStretchEnabled(false); |
| 54 | line->setBlendFunc(GameToolbox::getBlending()); |
| 55 | this->addChild(line); |
| 56 | line->setPosition({winSize.width / 2, this->_sprite->getContentSize().height + this->_sprite->getPositionY()}); |
| 57 | |
| 58 | auto gradient1 = Sprite::createWithSpriteFrameName("groundSquareShadow_001.png"); |
| 59 | gradient1->setStretchEnabled(false); |
| 60 | this->addChild(gradient1); |
| 61 | gradient1->setScale(0.7f); |
| 62 | gradient1->setPositionY(33); |
| 63 | |
| 64 | auto gradient2 = Sprite::createWithSpriteFrameName("groundSquareShadow_001.png"); |
| 65 | gradient2->setStretchEnabled(false); |
| 66 | this->addChild(gradient2); |
| 67 | gradient2->setScale(0.7f); |
| 68 | gradient2->setFlippedX(true); |
| 69 | gradient2->setPositionX(winSize.width); |
| 70 | gradient2->setPositionY(33); |
| 71 | |
| 72 | this->m_fSpeed = 5.770002f; |
| 73 | |
| 74 | //scheduleUpdate(); |
| 75 | |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | void GroundLayer::updateTweenAction(float value, std::string_view key) |
| 80 | { |
no test coverage detected