Hello,
So I've been messing around with VertexArray because I'm trying to see the difference in time when laying down tiles.
// create a quad
sf::VertexArray quad(sf::Quads, 4);
// define it as a rectangle, located at (10, 10) and with size 100x100
quad[0].position = sf::Vector2f(10.f, 10.f);
quad[1].position = sf::Vector2f(110.f, 10.f);
quad[2].position = sf::Vector2f(110.f, 110.f);
quad[3].position = sf::Vector2f(10.f, 110.f);
// define its texture area to be a 25x50 rectangle starting at (0, 0)
quad[0].texCoords = sf::Vector2f(0.f, 0.f);
quad[1].texCoords = sf::Vector2f(25.f, 0.f);
quad[2].texCoords = sf::Vector2f(25.f, 50.f);
quad[3].texCoords = sf::Vector2f(0.f, 50.f);
How do you write a getPosition() function when doing it like this smilar to the sf::Sprite::getPosition(). I get you can make a class and derive from Drawable and Transform. How would this look if you didn't do that? Would returning quad[0].position be the same as if I loaded a Sprite and returned the position? And if I set the origin to the middle {quad[0] + quad[1] / 2, quad[2] + quad[4] / 2} it would be like this?
Thanks, I hope that makes sense.