Witam,
mam problem dziwny trochę, SFML mimo, że robię według dokumentacji, na siłę nie chce mi załadować z pliku tekstury do sprite, nie wiem, może to przez to że używam Visual Studio 2012. Bez używania texture i sprite program działa i się kompiluje. Jakby ktoś mógł rzucić okiem na kod. Z góry dzięki za pomoc :)
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
using namespace sf;
int main() {
RenderWindow window( VideoMode( 800, 600, 32 ), "SFML");
Texture background;
if (!background.loadFromFile("tlo.png")) // tlo.png 800x600
return EXIT_FAILURE;
Sprite sprite(background);
CircleShape circle;
circle.setFillColor(Color(255, 0, 0));
circle.setRadius(50);
circle.setOutlineThickness(1);
circle.setOutlineColor(Color(255, 255, 255));
circle.setPosition(-50, -50);
RectangleShape rect;
rect.setFillColor(Color(0, 0, 255));
rect.setSize(Vector2f(64, 64));
rect.setPosition(Vector2f(-32, -32));
View view(Vector2f(0.0f, 0.0f), Vector2f(800, 600));
window.setView(view);
while(window.isOpen()) {
Event event;
while(window.pollEvent(event)) {
if(event.type == Event::Closed) {
window.close();
}
if(event.type == Event::KeyPressed && event.key.code == Keyboard::Right) {
circle.setPosition(circle.getPosition().x + 2, circle.getPosition().y);
}
if(event.type == Event::KeyPressed && event.key.code == Keyboard::Left) {
circle.setPosition(circle.getPosition().x - 2, circle.getPosition().y);
}
if(event.type == Event::KeyPressed && event.key.code == Keyboard::Up) {
circle.setPosition(circle.getPosition().x, circle.getPosition().y - 2);
}
if(event.type == Event::KeyPressed && event.key.code == Keyboard::Down) {
circle.setPosition(circle.getPosition().x, circle.getPosition().y + 2);
}
}
window.clear();
window.draw(sprite);
window.draw(circle);
window.draw(rect);
window.display();
}
return 0;
}