Pregunta

I've follow this tutorial to create RenderWindow in QFrame.

Everything fine, except this

sf::Vector2i pixelPos = sf::Mouse::getPosition(); sf::Vector2f worldPos = RenderWindow::mapPixelToCoords(pixelPos);

In sf::Mouse::getPosition();
It refer the mouse position of my screen, not refer to my QFrame.

What variable should I fill in () of sf::Mouse::getPosition

Thanks

¿Fue útil?

Solución

class QSFMLCanvas : public QWidget, public sf::RenderWindow hence you can call sf::Mouse::getPosition(*this) from within your class' methods.

Otros consejos

You need to use

sf::Mouse::GetPosition(sf::RenderWindow &Game);

So it is relative to your window, not your full screen.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top