SFML community forums

Help => General => Topic started by: Carlo Meroni on October 07, 2013, 06:09:28 pm

Title: Sort Sprite List by Scale
Post by: Carlo Meroni on October 07, 2013, 06:09:28 pm
Hi! I have a list of Sprite and i want to sort it by the scale of the sprite (sprite.getScale ()). How can I do it ?
Title: Re: Sort Sprite List by Scale
Post by: zsbzsb on October 07, 2013, 06:33:50 pm
A simple google search (http://lmgtfy.com/?q=c%2B%2B+sorting+custom+objects) will always answer these kind of questions.
http://stackoverflow.com/questions/1380463/sorting-a-vector-of-custom-objects (http://stackoverflow.com/questions/1380463/sorting-a-vector-of-custom-objects)
http://stackoverflow.com/questions/8121837/sorting-a-list-of-a-custom-type (http://stackoverflow.com/questions/8121837/sorting-a-list-of-a-custom-type)
Title: Re: Sort Sprite List by Scale
Post by: Carlo Meroni on October 07, 2013, 07:37:52 pm
I can not do it with those examples ... I'm not very good with C + +.
Can someone please show me an example with a list of sprites?
Title: Re: Sort Sprite List by Scale
Post by: zsbzsb on October 07, 2013, 08:06:50 pm
I can not do it with those examples ... I'm not very good with C + +.
Can someone please show me an example with a list of sprites?

Those are very generic examples that you should easily be able to understand. Try to write something and if it doesn't work then post again while showing some code.

And if you are not familiar with C++ I highly recommend that you find a good C++ book and learn C++ before trying SFML.
Title: Re: Sort Sprite List by Scale
Post by: eXpl0it3r on October 07, 2013, 08:08:33 pm
I can not do it with those examples ... I'm not very good with C + +.
Why not? Where are you stuck? What do you not understand with the examples?

Do you know how STL containers and algorithms work? If not you should grab a good C++ book (http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) and learn some more basics of C++ first. C++ is a complex language and SFML requires you to have some basic understanding. Developing a game or application on the other hand requires you to have a lot more than just basic knowledge of if, for, while and #include. ;)