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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - djysyed

Pages: [1]
1
Window / Positioning Text in Window
« on: November 06, 2020, 01:47:05 am »
Hey all,

I am relatively new to SFML (3 days new to be precise) and am trying to figure out how to show the amount of time that has passed. At the moment my function for doing so is:

void Game::DisplayGameTime() {
    sf::Text game_time;
    game_time.setString(std::to_string(game_clock.getElapsedTime().asSeconds()));
    game_time.setCharacterSize(100);
    game_time.setFillColor(sf::Color::White);
    game_time.setPosition(0.f, 0.f);
    my_window.draw(game_time);
}
 

I've been messing around with CharacterSize and setPosition but none of the 10 different values have produced any visible text. The code for how I'm using this function is:

void Game::Render() {
    my_window.clear();
    for (int i = 0; i < NUMSPRITES; i++) {
        my_window.draw(sprites[i]);
    }
    DisplayGameTime();
    my_window.display();
}
 

Any tips or pointers (no pun intended) in the right direction?

Pages: [1]