123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- #ifndef __cocos2d_libs__CCMouseEvent__
- #define __cocos2d_libs__CCMouseEvent__
- #include "base/CCEvent.h"
- #include "math/CCGeometry.h"
- NS_CC_BEGIN
- class CC_DLL EventMouse : public Event
- {
- public:
-
- enum class MouseEventType
- {
- MOUSE_NONE,
- MOUSE_DOWN,
- MOUSE_UP,
- MOUSE_MOVE,
- MOUSE_SCROLL,
- };
- enum class MouseButton
- {
- BUTTON_UNSET = -1,
- BUTTON_LEFT = 0,
- BUTTON_RIGHT = 1,
- BUTTON_MIDDLE = 2,
- BUTTON_4 = 3,
- BUTTON_5 = 4,
- BUTTON_6 = 5,
- BUTTON_7 = 6,
- BUTTON_8 = 7
- };
-
- EventMouse(MouseEventType mouseEventCode);
-
- void setScrollData(float scrollX, float scrollY) { _scrollX = scrollX; _scrollY = scrollY; }
-
- float getScrollX() const { return _scrollX; }
-
- float getScrollY() const { return _scrollY; }
-
- void setCursorPosition(float x, float y) {
- _x = x;
- _y = y;
- _prevPoint = _point;
- _point.x = x;
- _point.y = y;
- if (!_startPointCaptured)
- {
- _startPoint = _point;
- _startPointCaptured = true;
- }
- }
-
- void setMouseButton(MouseButton button) { _mouseButton = button; }
-
- MouseButton getMouseButton() const { return _mouseButton; }
-
- float getCursorX() const { return _x; }
-
- float getCursorY() const { return _y; }
-
- Vec2 getLocation() const;
-
- Vec2 getPreviousLocation() const;
-
- Vec2 getStartLocation() const;
-
- Vec2 getDelta() const;
-
- Vec2 getLocationInView() const;
-
- Vec2 getPreviousLocationInView() const;
-
- Vec2 getStartLocationInView() const;
- private:
- MouseEventType _mouseEventType;
- MouseButton _mouseButton;
- float _x;
- float _y;
- float _scrollX;
- float _scrollY;
- bool _startPointCaptured;
- Vec2 _startPoint;
- Vec2 _point;
- Vec2 _prevPoint;
- friend class EventListenerMouse;
- };
- NS_CC_END
- #endif
|