| 145 | } |
| 146 | |
| 147 | void ButtonSprite::updateBGImage(std::string_view file) |
| 148 | { |
| 149 | if (_buttonTexture) |
| 150 | { |
| 151 | _buttonTexture->removeFromParent(); |
| 152 | |
| 153 | _buttonTexture = ax::ui::Scale9Sprite::create(file, ax::Rect(0, 0, 40, 40)); |
| 154 | _buttonTexture->setContentSize({ 16, 16 }); |
| 155 | |
| 156 | this->addChild(_buttonTexture, 0); |
| 157 | |
| 158 | if (_hasTextProvided) |
| 159 | this->setString(_label->getString()); |
| 160 | else |
| 161 | this->updateSpriteBGSize(); |
| 162 | } |
| 163 | else |
| 164 | { |
| 165 | if (_subBGSprite) |
| 166 | { |
| 167 | _subBGSprite->setTexture(Director::getInstance()->getTextureCache()->addImage(file)); |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | void ButtonSprite::setString(std::string_view str) |
| 173 | { |
nothing calls this directly
no test coverage detected