1
Graphics / Re: Subtle positioning behavior
« on: May 02, 2015, 08:51:57 pm »
Agknoleged.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Should be in general discussion because it is not a help request.It's a conversation about bugs that may arise when using sfml-graphics, and not a general design discussion about SFML.
First, this is not a SFML bug, yet behavior that one would probably not expect as a user. I stumbled upon it yesterday, after debugging almost an hour and searching in the wrong placesShould be in general discussion because it is not a help request. And no I don't see a problem.
There is a bug in the following code, leading to a rendering that doesn't appear smooth when the sprites move.// Two sprites. Assume they're initialized with texture and everything.
// Origin is (0, 0) and rotation is 0 at all times.
sf::Sprite sprite;
sf::Sprite sprite2;
// Align sprite to integral coordinates (pixel-perfect rendering)
sprite.setPosition(std::round(...), std::round(...));
// Second sprite starts at the center of first.
// Also round sprite2 for pixel-perfect rendering
sf::FloatRect bounds = sprite.getGlobalBounds();
sf::Vector2f center(
bounds.left + std::round(bounds.width / 2.f),
bounds.top + std::round(bounds.height / 2.f));
sprite2.setPosition(center);
Does anybody spot it?
...............Now put a breakpoint on the call to sound.play() and tell me when it is called. Also you must learn about program flow control and basic C++ before you can even attempt to use SFML. So get yourself a good C++ book and learn that for 2 months and then come back to SFML.The tutorial was more helpful than you. For your information, I know several languages of code and have been doing C++ for much longer than 2 months. Case closed.
(please no one else state the obvious)
I moved the sound.play(); outside of the loop, but still not hearing anything I also tried with sf::music, and with different files.
Show your updated code. Alternatively try the included examples that come with SFML.