remove mouse event wrong data

This commit is contained in:
u0u0
2023-01-17 17:42:17 +08:00
parent 8181bcfa3e
commit 4410ec0d60
5 changed files with 39 additions and 720 deletions

View File

@@ -33,53 +33,26 @@ EventMouse::EventMouse(MouseEventType mouseEventCode)
: Event(Type::MOUSE)
, _mouseEventType(mouseEventCode)
, _mouseButton(MouseButton::BUTTON_UNSET)
, _x(0.0f)
, _y(0.0f)
, _scrollX(0.0f)
, _scrollY(0.0f)
, _startPointCaptured(false)
{
};
}
void EventMouse::setCursorPosition(float x, float y)
{
_point.set(x, y);
}
// returns the current touch location in screen coordinates
Vec2 EventMouse::getLocationInView() const
{
return _point;
}
// returns the previous touch location in screen coordinates
Vec2 EventMouse::getPreviousLocationInView() const
{
return _prevPoint;
}
// returns the start touch location in screen coordinates
Vec2 EventMouse::getStartLocationInView() const
{
return _startPoint;
Vec2 EventMouse::getLocationInView() const
{
return _point;
}
// returns the current touch location in OpenGL coordinates
Vec2 EventMouse::getLocation() const
{
return Director::getInstance()->convertToGL(_point);
{
return Director::getInstance()->convertToGL(_point);
}
// returns the previous touch location in OpenGL coordinates
Vec2 EventMouse::getPreviousLocation() const
{
return Director::getInstance()->convertToGL(_prevPoint);
}
// returns the start touch location in OpenGL coordinates
Vec2 EventMouse::getStartLocation() const
{
return Director::getInstance()->convertToGL(_startPoint);
}
// returns the delta position between the current location and the previous location in OpenGL coordinates
Vec2 EventMouse::getDelta() const
{
return getLocation() - getPreviousLocation();
}
NS_CC_END

View File

@@ -69,7 +69,6 @@ public:
BUTTON_8 = 7
};
/** Constructor.
*
* @param mouseEventCode A given mouse event type.
@@ -77,120 +76,65 @@ public:
*/
EventMouse(MouseEventType mouseEventCode);
/** Set mouse scroll data.
/** Set mouse scroll data. ONLY be call by GLFW
*
* @param scrollX The scroll data of x axis.
* @param scrollY The scroll data of y axis.
*/
void setScrollData(float scrollX, float scrollY) { _scrollX = scrollX; _scrollY = scrollY; }
/** Get mouse scroll data of x axis.
*
* @return The scroll data of x axis.
*/
float getScrollX() const { return _scrollX; }
/** Get mouse scroll data of y axis.
*
* @return The scroll data of y axis.
*/
float getScrollY() const { return _scrollY; }
/** Set the cursor position.
/** Set the cursor position. ONLY be call by GLFW
*
* @param x The x coordinate of cursor position.
* @param y The y coordinate of cursor position.
* @js setLocation
*/
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 setCursorPosition(float x, float y);
/** Set mouse button.
/** Set mouse button. ONLY be call by GLFW
*
* @param button a given mouse button.
* @js setButton
*/
void setMouseButton(MouseButton button) { _mouseButton = button; }
/** Get mouse button.
*
* @return The mouse button.
* @js getButton
*/
MouseButton getMouseButton() const { return _mouseButton; }
/** Get the cursor position of x axis.
*
* @return The x coordinate of cursor position.
* @js getLocationX
*/
float getCursorX() const { return _x; }
/** Get the cursor position of y axis.
*
* @return The y coordinate of cursor position.
* @js getLocationY
*/
float getCursorY() const { return _y; }
/** Returns the current touch location in OpenGL coordinates.
*
* @return The current touch location in OpenGL coordinates.
*/
Vec2 getLocation() const;
/** Returns the previous touch location in OpenGL coordinates.
*
* @return The previous touch location in OpenGL coordinates.
* @js NA
*/
Vec2 getPreviousLocation() const;
/** Returns the start touch location in OpenGL coordinates.
*
* @return The start touch location in OpenGL coordinates.
* @js NA
*/
Vec2 getStartLocation() const;
/** Returns the delta of 2 current touches locations in screen coordinates.
*
* @return The delta of 2 current touches locations in screen coordinates.
*/
Vec2 getDelta() const;
/** Returns the current touch location in screen coordinates.
*
* @return The current touch location in screen coordinates.
*/
Vec2 getLocationInView() const;
/** Returns the previous touch location in screen coordinates.
*
* @return The previous touch location in screen coordinates.
* @js NA
*/
Vec2 getPreviousLocationInView() const;
/** Returns the start touch location in screen coordinates.
*
* @return The start touch location in screen coordinates.
* @js NA
*/
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;
};

View File

@@ -537,7 +537,7 @@ void InputProcessor::onMouseDown(cocos2d::EventMouse * event)
return;
auto camera = Camera::getVisitingCamera();
Vec2 pt(event->getCursorX(), event->getCursorY());
Vec2 pt = event->getLocationInView();
GObject* target = _owner->hitTest(pt, camera);
if (!target)
target = _owner;
@@ -567,7 +567,7 @@ void InputProcessor::onMouseUp(cocos2d::EventMouse * event)
return;
auto camera = Camera::getVisitingCamera();
Vec2 pt(event->getCursorX(), event->getCursorY());
Vec2 pt = event->getLocationInView();
GObject* target = _owner->hitTest(pt, camera);
if (!target)
target = _owner;
@@ -628,13 +628,13 @@ void InputProcessor::onMouseUp(cocos2d::EventMouse * event)
void InputProcessor::onMouseMove(cocos2d::EventMouse * event)
{
TouchInfo* ti = getTouch(0);
Vec2 npos = UIRoot->worldToRoot(Vec2(event->getCursorX(), event->getCursorY()));
Vec2 pt = event->getLocationInView();
Vec2 npos = UIRoot->worldToRoot(pt);
if (std::abs(ti->pos.x - npos.x) < 1
&& std::abs(ti->pos.y - npos.y) < 1)
return;
auto camera = Camera::getVisitingCamera();
Vec2 pt(event->getCursorX(), event->getCursorY());
GObject* target = _owner->hitTest(pt, camera);
if (!target)
target = _owner;
@@ -677,7 +677,7 @@ void InputProcessor::onMouseMove(cocos2d::EventMouse * event)
void InputProcessor::onMouseScroll(cocos2d::EventMouse * event)
{
auto camera = Camera::getVisitingCamera();
Vec2 pt(event->getCursorX(), event->getCursorY());
Vec2 pt = event->getLocationInView();
GObject* target = _owner->hitTest(pt, camera);
if (!target)
target = _owner;

View File

@@ -35174,65 +35174,13 @@ int lua_register_cocos2dx_EventListenerKeyboard(lua_State* tolua_S)
return 1;
}
int lua_cocos2dx_EventMouse_getPreviousLocationInView(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getPreviousLocationInView'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getPreviousLocationInView'", nullptr);
return 0;
}
cocos2d::Vec2 ret = cobj->getPreviousLocationInView();
vec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventMouse:getPreviousLocationInView",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getPreviousLocationInView'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_EventMouse_getLocation(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
@@ -35249,11 +35197,6 @@ int lua_cocos2dx_EventMouse_getLocation(lua_State* tolua_S)
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getLocation'", nullptr);
return 0;
}
cocos2d::Vec2 ret = cobj->getLocation();
vec2_to_luaval(tolua_S, ret);
return 1;
@@ -35262,24 +35205,19 @@ int lua_cocos2dx_EventMouse_getLocation(lua_State* tolua_S)
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getLocation'.",&tolua_err);
#endif
return 0;
#endif
}
int lua_cocos2dx_EventMouse_getMouseButton(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
@@ -35296,11 +35234,6 @@ int lua_cocos2dx_EventMouse_getMouseButton(lua_State* tolua_S)
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getMouseButton'", nullptr);
return 0;
}
int ret = (int)cobj->getMouseButton();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
@@ -35309,315 +35242,19 @@ int lua_cocos2dx_EventMouse_getMouseButton(lua_State* tolua_S)
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getMouseButton'.",&tolua_err);
#endif
return 0;
#endif
}
int lua_cocos2dx_EventMouse_getPreviousLocation(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getPreviousLocation'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getPreviousLocation'", nullptr);
return 0;
}
cocos2d::Vec2 ret = cobj->getPreviousLocation();
vec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventMouse:getPreviousLocation",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getPreviousLocation'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_EventMouse_getDelta(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getDelta'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getDelta'", nullptr);
return 0;
}
cocos2d::Vec2 ret = cobj->getDelta();
vec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventMouse:getDelta",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getDelta'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_EventMouse_setScrollData(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_setScrollData'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
double arg0;
double arg1;
ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.EventMouse:setScrollData");
ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.EventMouse:setScrollData");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_setScrollData'", nullptr);
return 0;
}
cobj->setScrollData(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventMouse:setScrollData",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_setScrollData'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_EventMouse_getStartLocationInView(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getStartLocationInView'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getStartLocationInView'", nullptr);
return 0;
}
cocos2d::Vec2 ret = cobj->getStartLocationInView();
vec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventMouse:getStartLocationInView",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getStartLocationInView'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_EventMouse_getStartLocation(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getStartLocation'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getStartLocation'", nullptr);
return 0;
}
cocos2d::Vec2 ret = cobj->getStartLocation();
vec2_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventMouse:getStartLocation",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getStartLocation'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_EventMouse_setMouseButton(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_setMouseButton'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::EventMouse::MouseButton arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EventMouse:setMouseButton");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_setMouseButton'", nullptr);
return 0;
}
cobj->setMouseButton(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventMouse:setMouseButton",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_setMouseButton'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_EventMouse_getLocationInView(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
@@ -35634,11 +35271,6 @@ int lua_cocos2dx_EventMouse_getLocationInView(lua_State* tolua_S)
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getLocationInView'", nullptr);
return 0;
}
cocos2d::Vec2 ret = cobj->getLocationInView();
vec2_to_luaval(tolua_S, ret);
return 1;
@@ -35647,24 +35279,19 @@ int lua_cocos2dx_EventMouse_getLocationInView(lua_State* tolua_S)
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getLocationInView'.",&tolua_err);
#endif
return 0;
#endif
}
int lua_cocos2dx_EventMouse_getScrollY(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
@@ -35681,11 +35308,6 @@ int lua_cocos2dx_EventMouse_getScrollY(lua_State* tolua_S)
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getScrollY'", nullptr);
return 0;
}
double ret = cobj->getScrollY();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
@@ -35694,24 +35316,19 @@ int lua_cocos2dx_EventMouse_getScrollY(lua_State* tolua_S)
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getScrollY'.",&tolua_err);
#endif
return 0;
#endif
}
int lua_cocos2dx_EventMouse_getScrollX(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
@@ -35728,11 +35345,6 @@ int lua_cocos2dx_EventMouse_getScrollX(lua_State* tolua_S)
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getScrollX'", nullptr);
return 0;
}
double ret = cobj->getScrollX();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
@@ -35741,203 +35353,10 @@ int lua_cocos2dx_EventMouse_getScrollX(lua_State* tolua_S)
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getScrollX'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_EventMouse_getCursorX(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getCursorX'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getCursorX'", nullptr);
return 0;
}
double ret = cobj->getCursorX();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventMouse:getCursorX",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getCursorX'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_EventMouse_getCursorY(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_getCursorY'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_getCursorY'", nullptr);
return 0;
}
double ret = cobj->getCursorY();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventMouse:getCursorY",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_getCursorY'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_EventMouse_setCursorPosition(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventMouse",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventMouse*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_EventMouse_setCursorPosition'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
double arg0;
double arg1;
ok &= luaval_to_number(tolua_S, 2,&arg0, "cc.EventMouse:setCursorPosition");
ok &= luaval_to_number(tolua_S, 3,&arg1, "cc.EventMouse:setCursorPosition");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_setCursorPosition'", nullptr);
return 0;
}
cobj->setCursorPosition(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventMouse:setCursorPosition",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_setCursorPosition'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_EventMouse_constructor(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventMouse* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::EventMouse::MouseEventType arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.EventMouse:EventMouse");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_EventMouse_constructor'", nullptr);
return 0;
}
cobj = new cocos2d::EventMouse(arg0);
cobj->autorelease();
int ID = (int)cobj->_ID ;
int* luaID = &cobj->_luaID ;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventMouse");
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.EventMouse:EventMouse",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_EventMouse_constructor'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_EventMouse_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (EventMouse)");
return 0;
}
int lua_register_cocos2dx_EventMouse(lua_State* tolua_S)
@@ -35946,22 +35365,11 @@ int lua_register_cocos2dx_EventMouse(lua_State* tolua_S)
tolua_cclass(tolua_S,"EventMouse","cc.EventMouse","cc.Event",nullptr);
tolua_beginmodule(tolua_S,"EventMouse");
tolua_function(tolua_S,"new",lua_cocos2dx_EventMouse_constructor);
tolua_function(tolua_S,"getPreviousLocationInView",lua_cocos2dx_EventMouse_getPreviousLocationInView);
tolua_function(tolua_S,"getLocation",lua_cocos2dx_EventMouse_getLocation);
tolua_function(tolua_S,"getMouseButton",lua_cocos2dx_EventMouse_getMouseButton);
tolua_function(tolua_S,"getPreviousLocation",lua_cocos2dx_EventMouse_getPreviousLocation);
tolua_function(tolua_S,"getDelta",lua_cocos2dx_EventMouse_getDelta);
tolua_function(tolua_S,"setScrollData",lua_cocos2dx_EventMouse_setScrollData);
tolua_function(tolua_S,"getStartLocationInView",lua_cocos2dx_EventMouse_getStartLocationInView);
tolua_function(tolua_S,"getStartLocation",lua_cocos2dx_EventMouse_getStartLocation);
tolua_function(tolua_S,"setMouseButton",lua_cocos2dx_EventMouse_setMouseButton);
tolua_function(tolua_S,"getLocationInView",lua_cocos2dx_EventMouse_getLocationInView);
tolua_function(tolua_S,"getScrollY",lua_cocos2dx_EventMouse_getScrollY);
tolua_function(tolua_S,"getScrollX",lua_cocos2dx_EventMouse_getScrollX);
tolua_function(tolua_S,"getCursorX",lua_cocos2dx_EventMouse_getCursorX);
tolua_function(tolua_S,"getCursorY",lua_cocos2dx_EventMouse_getCursorY);
tolua_function(tolua_S,"setCursorPosition",lua_cocos2dx_EventMouse_setCursorPosition);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocos2d::EventMouse).name();
g_luaType[typeName] = "cc.EventMouse";

View File

@@ -256,20 +256,14 @@ function Node:setMouseEnabled(enable)
if enable then
local dealFunc = function(mouse, name)
local tp = mouse:getLocationInView()
local sp = mouse:getStartLocationInView()
local pp = mouse:getPreviousLocationInView()
-- call listener
self._LuaListeners[c.MOUSE_EVENT]{
name = name,
x = tp.x,
y = tp.y,
startX = sp.x,
startY = sp.y,
prevX = pp.x,
prevY = pp.y,
scroll = mouse:getScrollY(),
key = mouse:getMouseButton()
scrollX = mouse:getScrollX(),
scrollY = mouse:getScrollY(),
button = mouse:getMouseButton()
}
end