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

Author Topic: Can you make an array of sprites  (Read 2899 times)

0 Members and 1 Guest are viewing this topic.

killer13666

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Can you make an array of sprites
« 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?
« Last Edit: October 30, 2014, 04:09:21 pm by killer13666 »

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Can you make an array of sprites
« Reply #1 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.

killer13666

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Can you make an array of sprites
« Reply #2 on: October 30, 2014, 04:12:18 pm »
Would std::vector be a more efficient choice over an array, or does it matter?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Can you make an array of sprites
« Reply #3 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++).

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Can you make an array of sprites
« Reply #4 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...

 

anything