Hi there,
I would like to ask how to create SFML sprites directly from a textfile.
The textfile holds some sprite names.
I know that it's not possible to force text/stringdata into a sprite vector, but how to convert that stringdata
in the textfile to a "real" spritename that is accepted by the spritecontainer for the sprite creation?
You're trying to push a std::string into a vector of sf::Sprite type.
The first example works because you are pushing strings into a vector of strings, but in the second example you are trying to push strings into a vector of sprites.
If you want to push into VehicleSpritesVector you'll have to create a sprite with the string you read from the file and then push that sprite you created into the vector.
But I did create the sprites with identical names like in the text file. How to convert those spritenames in the textfile so that it will not try to read it as string, but as a sprite? I know how to convert string in int etc. (stringstreams...), but it doesn't work with sf::Sprite.
Are the names in the text file the names of the texture files for the sprites?
You can read the file name for a texture from a file and make a sprite using that, but you can't read a sprite from a file.
If you want a vector of sprites, you'll have to create a sprite and push that into the vector. You can use info from the text file to make the sprite, like what texture it'll use, but you have to push an actual sprite into that vector instead of a string.
Ok, thanks for the help. I think, that I've found now a revolutionary approach:
It seems, that in this case here, the spritenames aren't even relevant.
I only need the png file names in the text file for it to recognize everything correctly......