SFML community forums

Help => General => Topic started by: TigerBlue on June 30, 2020, 09:14:16 pm

Title: Using text from an array
Post by: TigerBlue on June 30, 2020, 09:14:16 pm
Hi, I am trying to create a function that displays the name of the team who's turn it is.

Using the following code in the main part of the program works.

// Define Text
textTeamToChoose = TeamName[gameRoundsTeamToPlay[gameRoundsPlayed]];
textTeamToChoose.setCharacterSize(80);
textTeamToChoose.setFillColor(sf::Color::Yellow);
textTeamToChoose.setFont(fontBold);
// Center The Text
sf::FloatRect textRect = textTeamToChoose.getLocalBounds();
textTeamToChoose.setOrigin(textRect.left + textRect.width / 2.0f, textRect.top + textRect.height / 2.0f);
textTeamToChoose.setPosition(desktop.width / 2.0f, desktop.height / 2.0f - 50);

but if I put it in a function like this

void func_TeamToChoose()
{
// Define Text
textTeamToChoose = TeamName[gameRoundsTeamToPlay[gameRoundsPlayed]];
textTeamToChoose.setCharacterSize(80);
textTeamToChoose.setFillColor(sf::Color::Yellow);
textTeamToChoose.setFont(fontBold);
// Center The Text
sf::FloatRect textRect = textTeamToChoose.getLocalBounds();
textTeamToChoose.setOrigin(textRect.left + textRect.width / 2.0f, textRect.top + textRect.height / 2.0f);
textTeamToChoose.setPosition(desktop.width / 2.0f, desktop.height / 2.0f - 50);
}

then it throws up an error in Visual Studio 2019 but the program runs and works how i wanted it to.

the Error it gives me is

C26812   The enum type 'sf::PrimitiveType' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).

Any help on what I have done wrong would be great.

Thanks for taking the time to read.
Title: Re: Using text from an array
Post by: Laurent on July 01, 2020, 07:44:35 am
https://en.sfml-dev.org/forums/index.php?topic=27352.0