Image tre1;
tre1.loadFromFile("models/tree.png");
Texture tre2;;
tre2.loadFromImage(tre1);
Sprite tre;
tre.setTexture(tre2);
vector<Object> objects;
objects.emplace_back("models/tree.png", 600, 1000, 93, 178);
objects.emplace_back("models/tree.png", 400, 1000, 93, 178);
class Object {
public:
int w, h, x, y;
String File;
Image image;
Texture texture;
Sprite sprite;
Object(String F, float X, float Y, float W, float H) {
File = F;
w = W; h = H;
image.loadFromFile("" + File);
image.createMaskFromColor(Color::Red);
texture.loadFromImage(image);
sprite.setTexture(texture);
x = X; y = Y;
this->File = F;
this->x = X;
this->y = Y;
this->w = W;
this->h = H;
sprite.setTextureRect(IntRect(0, 0, w, h));
}
};
vector<Object> objectss(2);
objectss.at(0) = Object("models/tree.png", 600, 1000, 93, 178);
objectss.at(1) = Object("models/tree.png", 400, 1000, 93, 178);
window.draw(objectss[0].sprite);
Ошибка C2512 Object::Object: нет подходящего конструктора по умолчанию