Mouse position with screen scrolling in SFML

孤街浪徒 提交于 2019-12-01 01:58:06

You need to call window.mapPixelToCoords() to transform your pixel position to the coordinate system of your view.

sf::Vector2i pixel_pos = sf::Mouse::getPosition(window.mywindow);
sf::Vector2f coord_pos = window.mywindow.mapPixelToCoords(pixel_pos);

And as a general advice: Don't use public class members - mywindow and playerSprite should not be accessible from the outside.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!