// // KKGLabelButton.h // SteveAndMaggieWorld // // Created by Katarzyna Kalinowska-Górska on 08/12/2021. // #ifndef KKGLabelButton_h #define KKGLabelButton_h #include "ui/CocosGUI.h" #include "cocos2d.h" class KKGLabelButton : public cocos2d::ui::Button { public: struct ButtonActionData { std::function onTouchBegan; std::function onTouchEnded; std::function onTouchCancelled; }; static KKGLabelButton* create(const std::string& backgroundPath, const std::string& text, const std::string& fontFile, float fontSize, const cocos2d::Color4B& textColor ); virtual bool init(const std::string& backgroundPath, const std::string& text, const std::string& fontFile, float fontSize, const cocos2d::Color4B& textColor); // ui and interaction virtual void setOnTouchBeganCallback(std::function callback); virtual void setOnTouchEndedCallback(std::function callback); virtual void setOnTouchCancelledCallback(std::function callback); virtual void setOriginalScale(float scale); virtual float getOriginalScale(); virtual void imitateTouchDown(); virtual void imitateTouchUp(); virtual cocos2d::Label* getLabel() { return m_textLabel; } protected: // ui and interaction float _originalScale; bool _adjustScaleOnPress; std::function _touchBeganCallback; std::function _touchEndedCallback; std::function _touchCancelledCallback; ButtonActionData _buttonOwnTouchBehaviour; cocos2d::Label* m_textLabel { nullptr }; virtual void configureTouchListeners(); }; #endif /* KKGLabelButton_h */