【问题标题】:Sfml text goes beyond the bounds of screenSfml 文本超出屏幕范围
【发布时间】:2021-10-21 14:40:15
【问题描述】:

我有这段代码

void Graphics::render_text(std::string bunch_of_text) {
    sf::Text text;
    text.setFont(font); // font is a sf::Font
    text.setString(bunch_of_text);
    text.setCharacterSize(text_size); // in pixels, not points!
    text.setFillColor(text_color);
    text.setStyle(text_style);
    window.draw(text);
    window.display();
}

而且有时候这段文字真的很长,因为有边界,其余的文字都看不到。 是否有机会使文本完美地适合屏幕,例如将text 拆分为多个部分或在需要的地方在text 内创建一个新行(\n)?

【问题讨论】:

    标签: c++ sfml


    【解决方案1】:

    这是一个想法(伪代码):

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-26
      • 2021-10-23
      • 2020-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多