// // EXControlButton.h // cocos2d_libs // // Created by ZhengSong on 2020/4/14. // #ifndef EXControlButton_h #define EXControlButton_h #include "CCControl.h" NS_CC_EXT_BEGIN class EXControlButton : public Control{ public: static EXControlButton* create(); virtual void setHighlighted(bool enabled) override; bool isPushed() const { return _isPushed; } // Overrides virtual bool onTouchBegan(Touch *touch, Event *event) override; virtual void onTouchMoved(Touch *touch, Event *event) override; virtual void onTouchEnded(Touch *touch, Event *event) override; virtual void onTouchCancelled(Touch *touch, Event *event) override; void setContentSize(const Size& size)override; CC_CONSTRUCTOR_ACCESS: EXControlButton(); virtual bool init() override; protected: bool _isPushed; /** The preferred size of the button, if label is larger it will be expanded. */ CC_PROPERTY_PASS_BY_REF(Size, _preferredSize, PreferredSize); /** Adjust the button zooming on touchdown. Default value is YES. */ CC_PROPERTY(bool, _zoomOnTouchDown, ZoomOnTouchDown); /** Scale ratio button on touchdown. Default value 1.1f */ CC_SYNTHESIZE(float, _scaleRatio, ScaleRatio); private: CC_DISALLOW_COPY_AND_ASSIGN(EXControlButton); }; NS_CC_EXT_END #endif /* EXControlButton_h */