Update CCGLViewImpl.cpp

fix GLViewImpl::onGLFWMouseScrollCallback forger transform cursor position.
This commit is contained in:
kaishiqi 2014-09-02 11:13:30 +08:00
parent 88a80495df
commit 8f11dd7f8b
1 changed files with 3 additions and 1 deletions

View File

@ -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);
}