1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- //
- // 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<redprotocol::AudioParam>& audioParams, bool forcePostEvent);
- void setTouchUpInsideAudioData(const std::string& wiseBnkFile,const std::string& wiseEvent, const std::vector<redprotocol::AudioParam>& 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<redprotocol::AudioParam> _audioParams4TouchDown;
- bool _forcePostEvent4TouchDown = false;
-
- std::string _wiseBnkFile4TouchUpInside;
- std::string _wiseEvent4TouchUpInside;
- std::vector<redprotocol::AudioParam> _audioParams4TouchUpInside;
- bool _forcePostEvent4TouchUpInside = false;
- };
- }//namespace
- #endif /* REDNodeButton_h */
|