1
Graphics / Std::Map texture not wokring
« on: June 28, 2018, 05:37:13 am »
For the following code even though nametext = "card001" and when I hard code card001.Art it works. When I don't it gives me the normal white square. This is really confusing me.
struct tempCard {
sf::Texture Art;
std::string Texture;
//"Sprites/BasicCard.png"
void loadArt() {
if (!Art.loadFromFile(Texture) ){
// error...
}
}
};
.....
for (int i = 0; i < Player.handMax;i++) {
if (Player.Hand[i] != 0) {
sf::RectangleShape Card(sf::Vector2f(80.0f, 128.0f));
std::string nametext = function_cardTexture(Player.Hand[i]);
std::cout << nametext;
sf::Texture texture = Vars[nametext].Art;
Card.setTexture(&texture);
window.draw(Card);
}
struct tempCard {
sf::Texture Art;
std::string Texture;
//"Sprites/BasicCard.png"
void loadArt() {
if (!Art.loadFromFile(Texture) ){
// error...
}
}
};
.....
for (int i = 0; i < Player.handMax;i++) {
if (Player.Hand[i] != 0) {
sf::RectangleShape Card(sf::Vector2f(80.0f, 128.0f));
std::string nametext = function_cardTexture(Player.Hand[i]);
std::cout << nametext;
sf::Texture texture = Vars[nametext].Art;
Card.setTexture(&texture);
window.draw(Card);
}