REDNodeButton.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // REDNodeButton.h
  3. // cocos2d_libs
  4. //
  5. // Created by ZhengSong on 2020/4/14.
  6. //
  7. #ifndef REDNodeButton_h
  8. #define REDNodeButton_h
  9. #include "extensions/GUI/CCControlExtension/CCControl.h"
  10. namespace redprotocol {
  11. struct AudioParam;
  12. }
  13. namespace redream {
  14. class REDNodeButton : public cocos2d::extension::Control{
  15. public:
  16. static REDNodeButton* create();
  17. virtual void setHighlighted(bool enabled) override;
  18. bool isPushed() const { return _isPushed; }
  19. // Overrides
  20. virtual bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event) override;
  21. virtual void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event) override;
  22. virtual void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event) override;
  23. virtual void onTouchCancelled(cocos2d::Touch *touch, cocos2d::Event *event) override;
  24. void setContentSize(const cocos2d::Size& size)override;
  25. ///add by 杜家兑(按钮点击、抬起音频支持)
  26. void setTouchDownAudioData(const std::string& wiseBnkFile, const std::string& wiseEvent, const std::vector<redprotocol::AudioParam>& audioParams, bool forcePostEvent);
  27. void setTouchUpInsideAudioData(const std::string& wiseBnkFile,const std::string& wiseEvent, const std::vector<redprotocol::AudioParam>& audioParams, bool forcePostEvent);
  28. CC_CONSTRUCTOR_ACCESS:
  29. REDNodeButton();
  30. virtual bool init() override;
  31. protected:
  32. bool _isPushed;
  33. /** The preferred size of the button, if label is larger it will be expanded. */
  34. CC_PROPERTY_PASS_BY_REF(cocos2d::Size, _preferredSize, PreferredSize);
  35. /** Adjust the button zooming on touchdown. Default value is YES. */
  36. CC_PROPERTY(bool, _zoomOnTouchDown, ZoomOnTouchDown);
  37. /** Scale ratio button on touchdown. Default value 1.1f */
  38. CC_SYNTHESIZE(float, _scaleRatio, ScaleRatio);
  39. private:
  40. CC_DISALLOW_COPY_AND_ASSIGN(REDNodeButton);
  41. ///add by 杜家兑(按钮点击、抬起音频支持)
  42. std::string _wiseBnkFile4TouchDown;
  43. std::string _wiseEvent4TouchDown;
  44. std::vector<redprotocol::AudioParam> _audioParams4TouchDown;
  45. bool _forcePostEvent4TouchDown = false;
  46. std::string _wiseBnkFile4TouchUpInside;
  47. std::string _wiseEvent4TouchUpInside;
  48. std::vector<redprotocol::AudioParam> _audioParams4TouchUpInside;
  49. bool _forcePostEvent4TouchUpInside = false;
  50. };
  51. }//namespace
  52. #endif /* REDNodeButton_h */