So I got tileset like this: Tileset
How do I load only one tile from it in SFML?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Load the image into a texture (either
sf::Imageif using SFML 1.6, orsf::Textureif using SFML 2.0), and then set the sub-rect for the sprite. Something like this (using SFML 2.0):For SFML 1.6, it’s more like this:
Note that you may want to disable smoothing for the image/texture, depending on how you’re using your sprites. If you don’t disable smoothing, the edges may bleed (like
texture.setSmooth(false)orimage.SetSmooth(false)).