1
0

CCEventTouch.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /****************************************************************************
  2. Copyright (c) 2013-2017 Chukong Technologies Inc.
  3. http://www.cocos2d-x.org
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. ****************************************************************************/
  20. #ifndef __cocos2d_libs__TouchEvent__
  21. #define __cocos2d_libs__TouchEvent__
  22. #include "base/CCEvent.h"
  23. #include <vector>
  24. /**
  25. * @addtogroup base
  26. * @{
  27. */
  28. NS_CC_BEGIN
  29. class Touch;
  30. #define TOUCH_PERF_DEBUG 1
  31. /** @class EventTouch
  32. * @brief Touch event.
  33. */
  34. class CC_DLL EventTouch : public Event
  35. {
  36. public:
  37. static const int MAX_TOUCHES = 15;
  38. /** EventCode Touch event code.*/
  39. enum class EventCode
  40. {
  41. BEGAN,
  42. MOVED,
  43. ENDED,
  44. CANCELLED
  45. };
  46. /**
  47. * Constructor.
  48. * @js NA
  49. */
  50. EventTouch();
  51. /** Get event code.
  52. *
  53. * @return The code of the event.
  54. */
  55. EventCode getEventCode() const { return _eventCode; }
  56. /** Get the touches.
  57. *
  58. * @return The touches of the event.
  59. */
  60. const std::vector<Touch*>& getTouches() const { return _touches; }
  61. #if TOUCH_PERF_DEBUG
  62. /** Set the event code.
  63. *
  64. * @param eventCode A given EventCode.
  65. */
  66. void setEventCode(EventCode eventCode) { _eventCode = eventCode; };
  67. /** Set the touches
  68. *
  69. * @param touches A given touches vector.
  70. */
  71. void setTouches(const std::vector<Touch*>& touches) { _touches = touches; };
  72. #endif
  73. private:
  74. EventCode _eventCode;
  75. std::vector<Touch*> _touches;
  76. friend class GLView;
  77. };
  78. NS_CC_END
  79. // end of base group
  80. /// @}
  81. #endif /* defined(__cocos2d_libs__TouchEvent__) */