So i made a function, which makes new tysy object when it's called.
It then pushes the objects to a vector:
void piirto::CreateCan()
{
tysy *Can1 = new tysy(Win);
std::cout << "Object " << Can1 << " says..." << std::endl;
Can1->Hello();
std::cout << std::endl << std::endl;
Can1++;
Tyz.push_back(Can1);
}
Now in my mainloop i have:
//blabla
Win.Clear();
goDraw();
Win.Draw(p12.s_tysy); //This draws fine.
Win.Display();
Now the goDraw(); function has :
if (i want to do this .. .. . .)
for (int i = 0; i < Tyz.size(); ++i)
{
Tyz[i]->Hello("buu");
Win.Draw(Tyz[i]->s_tysy); // Crash
}
If i call Tyz->Hello("buu"); It prints buu nice and soundy.
But whenever i try to draw those same sprites from s_tysy members using pointers to objects it causes a crash.
Program compiles good.
So if i just make normal tysy object i can draw it's sprite ok.
So why is this pointer thing crashing it?
tysy
.h
sf::Image i_tysy;
sf::Sprite s_tysy;
.cpp
i_tysy.LoadFromFile("kanuuna.jpg");
s_tysy.SetImage(i_tysy);
s_tysy.SetScale(0.4,0.4);
s_tysy.SetColor(sf::Color(255,0,0,255));
Any help & instructions are welcome!