From 8f11dd7f8ba7e45c5d6a6020f1b50b9d4a005c00 Mon Sep 17 00:00:00 2001 From: kaishiqi Date: Tue, 2 Sep 2014 11:13:30 +0800 Subject: [PATCH] Update CCGLViewImpl.cpp fix GLViewImpl::onGLFWMouseScrollCallback forger transform cursor position. --- cocos/platform/desktop/CCGLViewImpl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos/platform/desktop/CCGLViewImpl.cpp b/cocos/platform/desktop/CCGLViewImpl.cpp index 517f99ee2f..90d1767062 100644 --- a/cocos/platform/desktop/CCGLViewImpl.cpp +++ b/cocos/platform/desktop/CCGLViewImpl.cpp @@ -650,8 +650,10 @@ void GLViewImpl::onGLFWMouseScrollCallback(GLFWwindow* window, double x, double { EventMouse event(EventMouse::MouseEventType::MOUSE_SCROLL); //Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here + float cursorX = (_mouseX - _viewPortRect.origin.x) / _scaleX; + float cursorY = (_viewPortRect.origin.y + _viewPortRect.size.height - _mouseY) / _scaleY; event.setScrollData((float)x, -(float)y); - event.setCursorPosition(_mouseX, this->getViewPortRect().size.height - _mouseY); + event.setCursorPosition(cursorX, cursorY); Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); }