Witam mam jeden problem z rysowaniem blokow w SFML. Błąd to E0304 no instance of overloaded function "sf::RenderWindow::draw" matches the argument list a kod wygląda tak w main cpp
unsigned blocksX{ 8 }, blocksY{ 4 }, blockWidth{ 60 }, blockHeight{ 20 };
std::vector<block> blocks;
for (int i = 0; i < blocksY; i++)
{
for (int j = 0; j < blocksX; j++)
{
blocks.emplace_back((j + 1) * (blockWidth + 10), (i + 2) * (blockHeight + 5), blockWidth, blockHeight);
}
}
for (auto& block : blocks)
window.draw(block);
w block h
#pragma once
#include <SFML/Graphics.hpp>
using namespace sf;
class block :public sf::Drawable
{
public:
block(float t_X, float t_Y, float t_Width, float t_Height);
block() = delete;
~block()= default;
void update();
Vector2f getPostion();
float left();
float right();
float top();
float bottom();
bool isDestroyed();
void destroy();
Vector2f getSize();
private:
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
RectangleShape shape;
bool destroyed{ false };
};
block cpp
#include "block.h"
block::block(float t_X, float t_Y, float t_Width, float t_Height)
{
shape.setPosition(t_X, t_Y);
shape.setSize({ t_Width, t_Height });
shape.setFillColor(Color::Yellow);
shape.setOrigin(t_Width / 2.f, t_Height / 2.f);
}
void block::draw(RenderTarget& target, RenderStates state) const
{
target.draw(this->shape, state);
}
float block::left()
{
return this->shape.getPosition().x - shape.getSize().x / 2.f;
}
float block::right()
{
return this->shape.getPosition().x + shape.getSize().x / 2.f;
}
float block::top()
{
return this->shape.getPosition().y - shape.getSize().y / 2.f;
}
float block::bottom()
{
return this->shape.getPosition().y + shape.getSize().y / 2.f;
}
Vector2f block::getPostion()
{
return shape.getPosition();
}
bool block::isDestroyed()
{
return this->destroyed;
}
void block::destroy()
{
this->destroyed = true;
}
Vector2f block::getSize()
{
return shape.getSize();
}
void block::update()
{
}
mysle ze takie wycinki kodu wystarcza, a jedyne czego sie domyslam to że problem lezy w vectorze block