SFML community forums
Help => General => Topic started by: LTahboub on June 28, 2020, 10:47:14 am
-
Hello Everybody,
I've recently gotten into SFML and as an exercise to get more comfortable (and have fun), I started translating some Coding Challenges done by Daniel Shiffman on his Youtube channel, The Coding Train. Upon attempting to translate a star field effect in SFML, I started searching for the right function in SFML that would change the world origin from the top-left of the screen to the center. The closest thing I found to this was the setOrigin function, but that only works for sprites and not the whole window/screen. If you didn't understand my description of this function, it would be the equivalent of the translate(x, y) function in Processing. Any help would be appreciated.
-
Check the sf::View class (tutorial (https://www.sfml-dev.org/tutorials/2.5/graphics-view.php), doc (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1View.php))
Moving the view half the window size in the top left direction would put 0, 0 in the middle of the screen.
-
G, I would say that it would simpler to just set the view's center to (0, 0) ;D
-
True, true... ;D