I am making a game that when opened will display a menu but when my program goes through the loop it flashes that pic and black....here is my codesf::Event Event;
while(rw.IsOpened())
{
while(rw.GetEvent(Event))
{
if(Event.Type==sf::Event::Closed)
rw.Close();
//close window//
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
rw.Close();
//Esc key//
}
rw.Display();
}
and yes i have drawn all the sprites to the window this is just where the problem is
What am i doing wrong?
MainMenu::MainMenu(sf::RenderWindow & rw)
{
sf::Image Main_Menu_Pic;
Main_Menu_Pic.LoadFromFile("MasterSprites/MainMenu/MainMenu.png"); //this is the Main Menu
sf::Sprite Main_Menu_Sprite(Main_Menu_Pic);
int i=0;
int n=0;
bool running=true;
Button button[3];
//-------------------------------
button[0].x=263;
button[0].y=125;
button[0].Set_Pic_Without_Border("MasterSprites/MainMenu/PGWithoutBorder.png");
button[0].Set_Pic_With_Border("MasterSprites/MainMenu/pg Border.png");
//play button init
button[1].x=290;
button[1].y=184;
button[1].Set_Pic_Without_Border("MasterSprites/MainMenu/c WithoutBorder.png");
button[1].Set_Pic_With_Border("MasterSprites/MainMenu/c Border.png");
//Credits button init
button[2].x=267;
button[2].y=245;
button[2].Set_Pic_Without_Border("MasterSprites/MainMenu/qg WithoutBorder.png");
button[2].Set_Pic_With_Border("MasterSprites/MainMenu/qg Border.png");
//quit game button init
rw.Draw(Main_Menu_Sprite);
rw.Draw(button[0].Button_Without_Border);
rw.Draw(button[1].Button_Without_Border);
rw.Draw(button[2].Button_Without_Border);
//complete init now it is almost up without user interaction
sf::Event Event;
while(rw.IsOpened())
{
while(rw.GetEvent(Event))
{
if(Event.Type==sf::Event::Closed)
rw.Close();
//close window//
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
rw.Close();
//Esc key//
}
rw.Display();
}
}
this is all of it i have tried clear but it just makes the screen black the whole time