// // REDNodeButton.h // cocos2d_libs // // Created by ZhengSong on 2020/4/14. // #ifndef REDNodeButton_h #define REDNodeButton_h #include "extensions/GUI/CCControlExtension/CCControl.h" namespace redprotocol { struct AudioParam; } namespace redream { class REDNodeButton : public cocos2d::extension::Control{ public: static REDNodeButton* create(); virtual void setHighlighted(bool enabled) override; bool isPushed() const { return _isPushed; } // Overrides virtual bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event) override; virtual void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event) override; virtual void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event) override; virtual void onTouchCancelled(cocos2d::Touch *touch, cocos2d::Event *event) override; void setContentSize(const cocos2d::Size& size)override; ///add by 杜家兑(按钮点击、抬起音频支持) void setTouchDownAudioData(const std::string& wiseBnkFile, const std::string& wiseEvent, const std::vector& audioParams, bool forcePostEvent); void setTouchUpInsideAudioData(const std::string& wiseBnkFile,const std::string& wiseEvent, const std::vector& audioParams, bool forcePostEvent); CC_CONSTRUCTOR_ACCESS: REDNodeButton(); 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(cocos2d::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(REDNodeButton); ///add by 杜家兑(按钮点击、抬起音频支持) std::string _wiseBnkFile4TouchDown; std::string _wiseEvent4TouchDown; std::vector _audioParams4TouchDown; bool _forcePostEvent4TouchDown = false; std::string _wiseBnkFile4TouchUpInside; std::string _wiseEvent4TouchUpInside; std::vector _audioParams4TouchUpInside; bool _forcePostEvent4TouchUpInside = false; }; }//namespace #endif /* REDNodeButton_h */