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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Szustarol

Pages: 1 [2]
16
General / Re: Problem with a class with texture element
« on: June 03, 2016, 08:44:41 pm »
Oh I'm really sorry!
Its sf::Rectangleshape not Sprite!
I have noticed it right after your post, im so stupid i have mistake those two. Im really sorry!
Is there a difference if Im using sf::Rectangleshape?

17
General / Re: Problem with a class with texture element
« on: June 03, 2016, 05:20:11 pm »
I want to print all images from a folder.
I read it all with a function that is not really important in this problem imo
I have something like
image.gif
image2.gif
etc etc
so then i create as many objects of a class that looks similar to the one i posted before, as many images there are

then in a loop i set the parameters of the somesprite like size etc.
and then i use the loadtxt function, to load the sprite with texture


then there is a piece of unrelated code

at the end of program i display all of loaded images in positions set before in a loop

all loops mentioned above display the images depending on the count of the images gathered at the loading process, so the display looks something like
window display someclass[i].somesprite
where i is the counter that counts towards the number of all images

i hope the explanation is clear, if it is not ill just post code here

18
General / Re: Problem with a class with texture element
« on: June 03, 2016, 02:18:21 pm »
okay, so now i added & before name of texture and i have the white square problem :/
i know it happens if texture is destroyed after calling a function, but it shouldnt be destroyed here, because its a class and it still exists. Why is it?

19
General / Problem with a class with texture element
« on: June 02, 2016, 10:57:51 pm »
Hi!
I have a class like:
someclass name{
public:
 sf::Texture sometexture;
 sf::Sprite somesprite;
void settexture(){
somesprite.settexture(sometexture);
}
void loadtxt(std::string path){
sometexture.loadfromfile(path);
}
};

and then somewhere in code  i have;
std::vector <name> arrayofclasses;
...
arrayofclasses[i].loadtxt("Files/file.bmp");
arrayofclasses[i].settexture();
 
and i get compiler error:
'void sf::Shape::setTexture(const sf::Texture *,bool)': cannot convert argument 1 from 'sf::Texture' to 'const sf::Texture *'


ofc the code up there is just sample i wanted to explain what i have in a simple way, but it looks like this: array of classes, in one of them i want to set texture and then load them to sprite.

im using visual studio

why does it happen?
what is wrong?
would appreciate any help :)

Pages: 1 [2]
anything