SFML community forums
Help => Graphics => Topic started by: BitMaNip on June 01, 2024, 06:22:19 pm
-
Hi All
I want to have a sprite with a texture. They will be the same size which is the width of the screen. I want to be able to keep the sprite stationary and horizontally move the texture (left and right) so it looks like a repeating scrolling background that wraps around. Movement amount will change on user input.
How would I do this please?
-
There are multiple ways to achieve this. The simplest I can think of the top of my head would be to utilize the view for the movement of the player and keep rendering two instances of the background texture, so if there's an overlap, the player won't notice.
See the view tutorial for more information on that: https://www.sfml-dev.org/tutorials/2.6/graphics-view.php
Maybe this graphics helps to understand what I meant:
(https://en.sfml-dev.org/forums/index.php?action=dlattach;topic=29551.0;attach=6137)