SFML community forums

Help => Graphics => Topic started by: killer13666 on October 30, 2014, 03:49:41 pm

Title: Can you make an array of sprites
Post by: killer13666 on October 30, 2014, 03:49:41 pm
I am new to sfml, and I want to know if it is possible to make an array of sprites?
Title: Re: Can you make an array of sprites
Post by: Ixrec on October 30, 2014, 03:57:51 pm
You can make an array of anything.  SFML doesn't change how the C++ language works.

Whether you should make an array of sprites is an entirely different question (std::vector is usually better), but that depends on the program you're writing.

If you have to ask a question like this, it's probably worth reading a good book on C++ itself before trying to use C++ libraries.
Title: Re: Can you make an array of sprites
Post by: killer13666 on October 30, 2014, 04:12:18 pm
Would std::vector be a more efficient choice over an array, or does it matter?
Title: Re: Can you make an array of sprites
Post by: Ixrec on October 30, 2014, 04:30:55 pm
It depends on what you want to do with it.  If you read a proper C++ book and understand what arrays and vectors actually are, then the decision is very easy to make.  They're both as efficient as they can possibly be if you use them for what they're meant to be used for (like almost everything else in C++).
Title: Re: Can you make an array of sprites
Post by: Jesper Juhl on October 31, 2014, 12:22:49 am
If you worry about the performance of plain C/C++ arrays[] vs std::array vs std::vector then you are doing it wrong.
By default, just use std::vector. In the rare case you need something else; you'll know (I hope).
Just use vector...