This topic is 1987 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello.
I am currently learning SFML, i am following tutorial.
I came across a point that i am suposed to do this
 sf::Sprite MySpriteName; MySpriteName.SetImage(image,true); //Except sf::Sprite.SetImage does not exist. I included everything <SFML/Window.hpp> <SFML/Graphics.hpp> <SFML/System.hpp> 
Only thing it has is Texture, and i am reading its not same thing...
My IDE does not provide it as possibility, and compiler is giving me error:
 C:\c++ Project\The Knight of Avalion2\Tile.cpp|5|error: 'class sf::Sprite' has no member named 'SetImage'| 

EDIT:
Here is what sf::Sprite class holds from official site
http://www.sfml-dev....f_1_1Sprite.php

Question is, are sf::Texture replacing sf::Image cause there is still sf::Image in the class, but i cant use it... Edited by BaneTrapper

##### Share on other sites
I can tell you right now that the code :

sf::Sprite MySpriteName;
MySpriteName.SetImage(image,true);

Is not SFML 2.0 as Laurent changed the naming convention of methods to always start with a lowercase letter, and sprites take a Texture instead of an Image.

In terms of things that are drawn, the Texture class replaced the Image class. The Image class is used for loading, manipulating, and saving image files which is why it still exists in the system.

Basically, when you define a Texture object, that data is stored on the GPU to help speed up the drawing. An instance of an Image, however, is stored in local memory where it can be accessed and changed easier than if it were on the GPU.

##### Share on other sites
Jebbles is spot on. This is most likely version 1.6 code. Which means even if you switch code to

 sf::Texture image; image.loadFromFile("image.png"); sf::Sprite mySpriteName; mySpriteName.setTexture(image); 
there will still be some other things which might need to be changed. There were many changes up until the release candidate of sfml 2.0 which makes following many tutorials online a little difficult. However, it can be done if you put in some effort and make the changes as needed yourself.

Good Luck!

##### Share on other sites

Jebbles is spot on. This is most likely version 1.6 code. Which means even if you switch code to

 sf::Texture image; image.loadFromFile("image.png"); sf::Sprite mySpriteName; mySpriteName.setTexture(image); 
there will still be some other things which might need to be changed. There were many changes up until the release candidate of sfml 2.0 which makes following many tutorials online a little difficult. However, it can be done if you put in some effort and make the changes as needed yourself.

Good Luck!

Its kinda difficult to find a proper tutorial,
That will show how to manipulate pixels in texture/image,
make audio,

Allot of tutorials got sfml 2.0 in context and are 1.6 100% since they use sf::Sprite.SetImage();
its annoying that people do that.

Thanks on encouragement!