2013-10-05 01:07:39 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
2013-10-05 01:07:39 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __cocos2d_libs__CCMouseEvent__
|
|
|
|
#define __cocos2d_libs__CCMouseEvent__
|
|
|
|
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "base/CCEvent.h"
|
2013-10-05 01:07:39 +08:00
|
|
|
|
2013-10-12 05:35:38 +08:00
|
|
|
#define MOUSE_BUTTON_LEFT 0
|
|
|
|
#define MOUSE_BUTTON_RIGHT 1
|
|
|
|
#define MOUSE_BUTTON_MIDDLE 2
|
|
|
|
#define MOUSE_BUTTON_4 3
|
|
|
|
#define MOUSE_BUTTON_5 4
|
|
|
|
#define MOUSE_BUTTON_6 5
|
|
|
|
#define MOUSE_BUTTON_7 6
|
|
|
|
#define MOUSE_BUTTON_8 7
|
|
|
|
|
2013-10-05 01:07:39 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
class EventMouse : public Event
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Different types of MouseEvent
|
|
|
|
*/
|
|
|
|
enum class MouseEventType
|
|
|
|
{
|
|
|
|
MOUSE_NONE,
|
2013-10-05 07:14:52 +08:00
|
|
|
MOUSE_DOWN,
|
|
|
|
MOUSE_UP,
|
|
|
|
MOUSE_MOVE,
|
2013-10-05 01:07:39 +08:00
|
|
|
MOUSE_SCROLL,
|
|
|
|
};
|
|
|
|
|
2013-10-31 14:19:36 +08:00
|
|
|
EventMouse(MouseEventType mouseEventCode);
|
2013-10-05 01:07:39 +08:00
|
|
|
|
|
|
|
/** Set mouse scroll data */
|
|
|
|
inline void setScrollData(float scrollX, float scrollY) { _scrollX = scrollX; _scrollY = scrollY; };
|
|
|
|
inline float getScrollX() { return _scrollX; };
|
|
|
|
inline float getScrollY() { return _scrollY; };
|
|
|
|
|
2013-10-05 07:14:52 +08:00
|
|
|
inline void setCursorPosition(float x, float y) { _x = x; _y = y; };
|
2013-10-12 05:35:38 +08:00
|
|
|
inline void setMouseButton(int button) { _mouseButton = button; };
|
|
|
|
inline int getMouseButton() { return _mouseButton; };
|
2013-10-05 07:14:52 +08:00
|
|
|
inline float getCursorX() { return _x; };
|
|
|
|
inline float getCursorY() { return _y; };
|
|
|
|
|
2013-10-05 01:07:39 +08:00
|
|
|
private:
|
|
|
|
MouseEventType _mouseEventType;
|
|
|
|
int _mouseButton;
|
2013-10-05 07:14:52 +08:00
|
|
|
float _x;
|
|
|
|
float _y;
|
2013-10-05 01:07:39 +08:00
|
|
|
float _scrollX;
|
|
|
|
float _scrollY;
|
|
|
|
|
|
|
|
friend class EventListenerMouse;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif /* defined(__cocos2d_libs__CCMouseEvent__) */
|