#pragma once
#include <SFML\Graphics.hpp>
#include <iostream>
using namespace sf;
using namespace std;
class Ship : public sf::Drawable
{
public:
Ship();
~Ship() = default;
private:
Texture texture;
Sprite sprite;
void draw(RenderTarget& traget, RenderStates state) const override;
};
_________________________________________________________________
#include "Ship.h"
Ship::Ship()
{
texture.loadFromFile("space-ship.png");
sprite.setTexture(texture);
sprite.setPosition(0, 0);
sprite.setScale(0.1, 0.1);
}
void Ship::draw(RenderTarget& target, RenderStates state) const
{
target.draw(this->sprite, state);
}
__________________________________________________________________
#include <iostream>
#include<SFML\Graphics.hpp>
#include <SFML\Window.hpp>
#include "Ship.h"
using namespace std;
using namespace sf;
int main()
{
Ship ship;
ship.Ship();
RenderWindow window(VideoMode(800, 600), "SFML works!");
while (window.isOpen())
{
window.clear(Color::White);
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
}
window.draw(ship);
window.display();
}
return 0;
}
Wyskakuje mi error "type name is not allowed". Co zrobiłem źle?