Cześć, mam mały problem. Mianowicie byłem w trakcie tworzenia arcanoida z youtube'a tyle, że w pewnym momencie efekt przestał być identyczny z tym co było na filmie. Chciałem by na środku okienka wyświetlił się biały okrąg, ale nic się nie pokazuje i okno jest całe czarne. Osobiście mi to wygląda jakby program nie czytał pliku Ball.cpp, jednak nie wiedziałem co miałbym zrobić z tym i tak. Pracuje w Visual Studio
#pragma once
#include <SFML/Graphics.hpp>
using namespace sf;
class Ball : public sf::Drawable //inherits the shape
{
public:
Ball(float t_x,float t_y);
Ball()=delete; //more about in internet
~Ball()=default;
private:
CircleShape shape;
const float ballRadius{ 10.0f };
void draw(RenderTarget& target, RenderStates state) const override; //isplays(przekazuje) the object as drawable'
};
#include "Ball.h"
Ball::Ball(float t_x, float t_y)
{
shape.setPosition(t_x, t_y);
shape.setRadius(this->ballRadius);
shape.setFillColor(Color::White);
shape.setOrigin(this->ballRadius, this->ballRadius);
}
void Ball::draw(RenderTarget& target, RenderStates state) const
{
target.draw(this->shape, state);
}
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include "Ball.h"
using namespace sf;
using namespace std;
int main()
{
Ball ball(400, 300);
RenderWindow window{ VideoMode{800,600},"Arcanoid tutorial" };
window.setFramerateLimit(60);
Event event;
{
window.clear(Color::Black);
window.pollEvent(event);
window.display();
if (event.type == Event::Closed) {
window.close();
break;
}
window.draw(ball);
}
return 0;
}
Nie wiem też czy to ma jakiekolwiek znaczenie, ale przy kompilacji wyświetla mi się takie ostrzeżenie:
1>C:\ProgramFiles\MicrosoftVisualStudio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(531,5): warning MSB8028: Katalog pośredni (x64\Debug\) zawiera pliki udostępnione z innego projektu (proba.vcxproj).