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

Author Topic: Scrolling  (Read 1192 times)

0 Members and 1 Guest are viewing this topic.

mafiozy

  • Newbie
  • *
  • Posts: 3
    • View Profile
Scrolling
« on: March 15, 2023, 05:50:49 pm »
Hello everyone ;D Can i ask you. How to make scrolling in sfml? Im doing like tasklist, there are rectangleshapes and text. So, they are in tasklist window(another, but big rectangleshape). So, i need to make to dissappear small rectangleshapes as i move them outside of tasklist, as it was like outside of tasklist would be some figures that are drawed in higher order(but outside of big rectangle nothing but colored background).  In advance want to thank you. And thank for previous answered questions( couldn't thank you because dont know how to answer in topics)/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Scrolling
« Reply #1 on: March 18, 2023, 08:27:34 am »
It sounds like you want to clips objects to a rectangle shape. Is that correct?
If so, there are a few options I can think of right now:
  • Draw all the items and move/scroll them to position.
    Then, draw rectangles around the tasklist "window" rectangle to fill them with background colour. Obviously, this would need to happen before drawing over those fills.
  • Create a render texture of the same size as the tasklist window.
    Draw the items to that.
    Then, create a sprite and draw that render texture to the window.
  • Create a viewport that fills the area of the tasklist window and then you can just draw to that and it will clip it automatically.

The first one is the simplest but the third one is probably the best one if you can get to grips with views and viewports (they're difficult to understand at first but quite easy to use once you grasp the concept). The second one should be easy enough but it's up to you if creating a render texture just for this is worth it ;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything