Ok, so... I have a small trouble with drawing of UI.
I have a map, a character etc... everything is working good. But I can't to draw anyting relative to the coordinates of the window. I need it to draw an interface.
( shortly... how to draw a rectangle it always would be located in the top left corner of the window?)
my main file
#include <SFML/Graphics.hpp>
#include "GraphicsLib.cpp"
#include "character.cpp"
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(720, 480), "Tilemap");
Hero hero;
sf::View view;
view.reset(sf::FloatRect(0, 0, 720, 480));
TileMap map;
map.load("testMap.txt");
hero.setWayMap(map.wayMap, map.height, map.width);
sf::RectangleShape r(sf::Vector2f(120.f, 50.f));
r.setPosition(sf::Vector2f(10, 0));
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(hero.sprite);
window.draw(map);
window.setView(view);
window.draw(hero.sprite);
view.setCenter(hero.sprite.getPosition().x + hero.img.getSize().x / 2, hero.sprite.getPosition().y + hero.img.getSize().y / 2);
hero.move();
window.draw(r);
window.display();
}
return 0;
}