Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: scrolling texture thru sprite  (Read 1536 times)

0 Members and 1 Guest are viewing this topic.

BitMaNip

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
scrolling texture thru sprite
« 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?


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: scrolling texture thru sprite
« Reply #1 on: June 01, 2024, 07:44:43 pm »
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:

Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/