SFML community forums
Help => Graphics => Topic started by: C0dedSurvivor on January 26, 2016, 06:54:41 pm
-
For some reason this code won't render the rectangleshape correctly. It takes control away from the player correctly and waits the right amount before giving it back, but the rectangle doesn't render on the window. If you need more of my code, please let me know.
int screenHeight = 500;
int screenWidth = 500;
if (Keyboard::isKeyPressed(Keyboard::Escape)){
playerControl = false;
RectangleShape menuBackground;
menuBackground.setFillColor(sf::Color::Red);
menuBackground.setSize(Vector2f(0, 0));
menuBackground.setPosition(sf::Vector2f(screenWidth / 2, screenHeight / 2));
window.draw(menuBackground);
for (int c = 1; c < 51; c++){
menuBackground.setSize(sf::Vector2f(round(screenWidth / 50) * c, round(screenHeight / 50) * c));
menuBackground.move(sf::Vector2f((round(screenWidth / 50) * c / 2) * -1, round((screenHeight / 50) * c / 2) * -1));
window.draw(menuBackground);
sleep(Time(milliseconds(10)));
}
menuBackground.setSize(Vector2f(screenWidth, screenHeight));
window.draw(menuBackground);
sleep(Time(seconds(3)));
for (int a = 0; a < 50; a++){
menuBackground.setSize(sf::Vector2f(screenWidth - (round(screenWidth / 50) * a), screenHeight - (round(screenHeight / 50) * a)));
menuBackground.move(sf::Vector2f(round(screenWidth / 50) * a / 2, round(screenHeight / 50) * a / 2));
window.draw(menuBackground);
sleep(Time(milliseconds(10)));
}
menuBackground.setSize(Vector2f(0, 0));
window.draw(menuBackground);
playerControl = true;
}
-
You show you're using of window.draw(), but nowhere in this code is window.clear() or window.display(). Do you have clear() happening before drawing in your game loop and display() happening immediately after?
-
Thank you, I knew there was something simple I was forgetting...