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

Author Topic: Using text from an array  (Read 1096 times)

0 Members and 2 Guests are viewing this topic.

TigerBlue

  • Newbie
  • *
  • Posts: 1
    • View Profile
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Laurent Gomila - SFML developer