Why the following code doesn't draw the image in the point defined by (pos1, pos2)?
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <sstream>
#include <string>
class Field
{
sf::RenderWindow App;
sf::Image image;
sf::Sprite sprite;
public:
Field(int x, int y) {App.Create(sf::VideoMode(x, y), "SFML");};
void FEvent();
void FDisplay (int, int, std::string);
};
void Field::FEvent ()
{
while(App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::MouseButtonPressed)
FDisplay(Event.MouseMove.X, Event.MouseMove.Y, "X.bmp");
}
}
}
void Field::FDisplay (int pos1, int pos2, std::string filename)
{
if(!image.LoadFromFile(filename))
{
App.Close();
}
sprite.SetImage(image);
App.Clear();
sprite.SetPosition(pos1, pos2);
App.Draw(sprite);
App.Display();
}
int main()
{
Field F(315, 315);
F.FEvent();
}