Hi guys, i will show you my problem on code
This code will show white square.
#include <SFML\Graphics.hpp>
class Button: public sf::Drawable {
sf::Texture txt;
sf::Sprite spr;
sf::Text t;
sf::Font f;
virtual void draw(sf::RenderTarget & t, sf::RenderStates s) const {
t.draw(spr, s);
}
public:
Button() {
txt.loadFromFile("txt.png");
spr.setTexture(txt);
}
};
class Invet: public sf::Drawable {
Button b;
virtual void draw(sf::RenderTarget & t, sf::RenderStates s) const {
t.draw(b, s);
}
public:
Invet() {
b = Button();
}
};
int main() {
Invet i;
sf::RenderWindow w(sf::VideoMode(1280, 780), "e");
while (w.isOpen()) {
sf::Event e;
if (w.pollEvent(e)) {}
w.clear();
w.draw(i);
w.display();
}
return 0;
}
or this
//Invent
public:
Button b;
//main
Invet i;
i.b=Button()
but if...
Invet() {}
Why i can't use constructor to second class from first, or like object be second object?
SFML 2.5.1