0 Members and 1 Guest are viewing this topic.
the "getSprite" function seems completely useless and a waste of code
Shared pointers maybe. But there are simpler ways to deal with that. Manager classes put in well thought locations. See : http://en.sfml-dev.org/forums/index.php?topic=9437.msg64068#msg64068Quotethe "getSprite" function seems completely useless and a waste of codeYes!
Does it really? Should cause access violation or stack corruption. It's also (possibly) leaking memory. Why can't you just return sf::Vector? There is no reason not to return sf::Vector or if you really need array : std::vector(which is unleaky, self resizing array).
TAKE vector in SFML take const references or references
Functions are declared like this:void doShitWithVector(const sf::Vector2f& vector);sf::Vector2f calculateShitVector();not like this:void doShitWithVector(sf::Vector2f vector);//waste of memory passingvector by valuesf::Vector2f& calculateShitVector();//cant return reference to temporary vector from inside fucntion scope
Yes. So you return a copy. References are for things that are heavy to copy or for input values to functions.