SFML community forums
Help => Graphics => Topic started by: Saile on October 28, 2007, 02:23:45 pm
-
Im working with tiles and have a big image with many pictures, I use the sprite.SetImage & sprite.SetSubRect to my class. That makes all instances I create have that big image stored for them selves which increases the memory radical. Would it be better if the Image worked as a pointer, if it isn't?
-
It is actually a pointer. Sprites don't duplicate their image, that would be stupid.
-
Sorry if I said something wrong, but I don't know how to solve my problem :(
-
Which problem ?
-
About that all new instances i create of a sertain class has a sprite with the SetSubRect of the huge tile image. I just need that SubRect image for that instance, not the whole image. Because when I do so the memory increases as much as the images size for all instances.
-
Can you show us some code ?
-
Hmm i maybe get what your problem is and my suggestion is to do:
you can have a class named TileMap for example with a sfImage tileImage.
then you have a class for each tile which have a sfSprite and a create function with a sfImage pointer: Create(sfImage* tileImage);
So you can set the sprite to the image pointer like this:
tileSpriteName.SetImage(*tileImage) in the Create function. Then you can set the sub rect in each tile using the same image.
Also in the tileMap class when you call the Create function it should(could) look like this: tile
Hope it helped...