まず最初に、私はプログラミングに関してはまだ完全な初心者であり、この問題に対する答えをすでに探していると言いたいのですが、何が問題なのかわかりません。
sf::Text オブジェクトのパラメータを設定する関数を書きました:
void FontParam(sf::Text obj, sf::Font font, std::string text, sf::Color color, int size, int positionX, int positionY)
{
obj.setCharacterSize(size);
obj.setFont(font);
obj.setColor(color);
obj.setString(text);
obj.setPosition(positionX,positionY);
}
使用:
FontParam(t[0],font_Clubland,"R",sf::Color::White,100,100,100);
そしてそれを描くことはうまくいきません。次のように記述します。
t[0].setFont(font_Clubland);
t[0].setColor(sf::Color::White);
t[0].setPosition(100,100);
t[0].setString("R");
t[0].setCharacterSize(100);
そしてそれを描きます。
ヘルプやヒントは大歓迎です。事前に感謝します!
編集: - - - - - - - - - - - - - -
誰かが不思議に思っていたのは、私が sf::Font を参照していなかったため、アクセス違反が発生していたからです。正しい関数は次のようになります。
void FontParam(sf::Text &obj, sf::Font &font, std::string text, sf::Color color, int size, int positionX, int positionY)
{
obj.setCharacterSize(size);
obj.setFont(font);
obj.setColor(color);
obj.setString(text);
obj.setPosition(positionX,positionY);
}
助けてくれてありがとう!