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.


Messages - TigerBlue

Pages: [1]
1
General / Using text from an array
« 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.

Pages: [1]
anything