So I know from other posts that this error occurs when you try to copy something uncountable. Problem is obviously that when I push back the window it copys it. Theoretically the solution to that is a vector of refrances. When I make it a vector of refrances and obviously push back refrances files xmemory and vector freak out, give >20 errors all saying that pointers to refrances are illegal. How show should I go about fixing this or what is a different method to use.
If this doesn't work I am trying to make a void that spawns a new window and adds it to the vector. The vector runs in a void and functions like the while loop in just one window. I run the void from the while loop of a main window.
The Struct I've made
typedef struct KeyStruct {
sf::Image Img;
sf::Texture Tex;
sf::Sprite Sprite;
//there is more but its not necessary
}NewKey;
Step Windows
static vector <sf::RenderWindow> WindowArray;
static vector <NewKey> KeyArray;
static void StepWindows()
{
sf::Clock clock;
int i;
for (i = 0; i > WindowArray.size(); i++)
MakeTopWindow(WindowArray[i].getSystemHandle());
WindowArray[i].clear(sf::Color::Transparent);
WindowArray[i].draw(KeyArray[i].Sprite);
WindowArray[i].display();
if (clock.getElapsedTime().asMicroseconds() > 1000)
{
WindowArray[i].setPosition(MakeKey::Gravity(WindowArray[i], KeyArray[i]));
}
}
Draw Key
static void DrawKey(string input)
{
//Declair Key
NewKey Key;
NewKey& KeyRef = Key;
if (input == "A")
Key.Img.loadFromFile("Assets/Images/A.png");
else if (input == "D")
Key.Img.loadFromFile("Assets/Images/D.png");
//ect
Key.Tex.loadFromImage(Key.Img);
Key.Sprite.setTexture(Key.Tex);
sf::RenderWindow window(sf::VideoMode(Key.Img.getSize().x, Key.Img.getSize().y, 32), "Key", sf::Style::None);
sf::RenderWindow& windowRef = window;
window.setPosition(MakeKey::RandSpawn(Key.Img));
MakeKey::WindowArray.push_back(windowRef);
MakeKey::KeyArray.push_back(KeyRef);
}
And My Main
int main()
{
sf::RenderWindow window(sf::VideoMode(100, 100, 32), "Main Window", sf::Style::None);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
MakeKey::MakeTopWindow(window.getSystemHandle());
//Key Presses
if (event.type == sf::Event::KeyPressed) {
if (event.key.code == sf::Keyboard::A)
MakeKey::DrawKey("A");
else if (event.key.code == sf::Keyboard::D)
MakeKey::DrawKey("D");
//ect
}
//Close
if (event.type == sf::Event::Closed)
window.close();
}
MakeKey::MakeTopWindow(window.getSystemHandle());
MakeKey::StepWindows();
}
return EXIT_SUCCESS;
}
Thanks for the help