Open peerobo opened 6 years ago
Steps to Reproduce:
The following code call to CCSprite::initWithSpriteFrameName two times, cause an error in rendering.
ui::Button *bt = ui::Button::create(); bt->loadTextureNormal("SpriteFrameA", ui::Widget::TextureResType::PLIST); bt->loadTextureNormal("SpriteFrameB", ui::Widget::TextureResType::PLIST);
ui::Button *bt = ui::Button::create();
bt->loadTextureNormal("SpriteFrameA", ui::Widget::TextureResType::PLIST);
bt->loadTextureNormal("SpriteFrameB", ui::Widget::TextureResType::PLIST);
Should look like this:
Achieve by modify UIButton.cpp:
void Button::loadTextureNormal(const std::string& normal,TextureResType texType) { ... case TextureResType::PLIST: // _buttonNormalRenderer->initWithSpriteFrameName(normal); frm = SpriteFrameCache::getInstance()->getSpriteFrameByName(normal); _buttonNormalRenderer->setSpriteFrame(frm); break; ... }
void Button::loadTextureNormal(const std::string& normal,TextureResType texType)
{
...
case TextureResType::PLIST:
// _buttonNormalRenderer->initWithSpriteFrameName(normal);
frm = SpriteFrameCache::getInstance()->getSpriteFrameByName(normal);
_buttonNormalRenderer->setSpriteFrame(frm);
break;
}
Could you submit a PR for it? to add a test case like your image shows into cpp-tests project -> 45:Node: Sprite would be better.
cpp-tests
45:Node: Sprite
@drelaptop please check out the PR. Thanks!
Steps to Reproduce:
The following code call to CCSprite::initWithSpriteFrameName two times, cause an error in rendering.
ui::Button *bt = ui::Button::create();
bt->loadTextureNormal("SpriteFrameA", ui::Widget::TextureResType::PLIST);
bt->loadTextureNormal("SpriteFrameB", ui::Widget::TextureResType::PLIST);
Should look like this:
Achieve by modify UIButton.cpp:
void Button::loadTextureNormal(const std::string& normal,TextureResType texType)
{
...
case TextureResType::PLIST:
// _buttonNormalRenderer->initWithSpriteFrameName(normal);
frm = SpriteFrameCache::getInstance()->getSpriteFrameByName(normal);
_buttonNormalRenderer->setSpriteFrame(frm);
break;
...
}