SFML community forums

Help => General => Topic started by: antinoid on May 15, 2023, 07:56:30 pm

Title: sf::Mouse mouse; gives an error
Post by: antinoid on May 15, 2023, 07:56:30 pm
Currently, I'm using SFML 3.0.0 and it seems that I can't do
sf::Mouse mouse;

anymore, does this mean any time I want to call a method such as mouse.getPosition() I will need to call sf::Mouse::getPosition() instead?

Is there any alternative?

Thanks!
Title: Re: sf::Mouse mouse; gives an error
Post by: Hapax on May 15, 2023, 08:56:05 pm
From 2.5.1's documentation:
Quote from: https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Mouse.php
It only contains static functions (a single mouse is assumed), so it's not meant to be instantiated.

Which means we should never have been doing:
sf::Mouse mouse;

You are right, though. The correct way to do it is simply:
sf::Mouse::getPosition();