auto img = Sprite::createWithSpriteFrameName("playBtn.png"); // Tries to load from the spritesheet
auto menuplay = cocos2d::ui::Button::create(img, "button_green.png", "button_small.png");
menuplay->addTouchEventListener([&](Ref* sender, cocos2d::ui::Widget::TouchEventType type){
switch (type)
{
case ui::Widget::TouchEventType::BEGAN: // I havent coded anything to do when the button is pressed yet
break;
case ui::Widget::TouchEventType::ENDED:
break;
default:
break;
}
});
There is no such create function in the cocos2d::ui::Button class. If you looked at the UIButton.h header file to find out what is available, you would see these:
All the images need to be in that sprite sheet. If you want to mix and match sprite sheet and individual graphics, you’ll have to inherit from the ui::Button class and add your own create methods.
I realise I may be pointing out the obvious here, but reading the documentation and taking a quick look at the interfaces to the code you’re using does help, a lot.