Hi!
I have rectangle (1920 x ~25) on my window and well, i don't want it. Here's screenshot:
It covers everything i put there but my system's cursor.
What can cause that problem?
//Game.hpp
#ifndef GAME_H
#define GAME_H
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Mouse.hpp>
#include <SFML/Window/Event.hpp>
class Game
: public sf::RenderWindow
{
sf::Texture standardCursor;
sf::Texture sfmlLogoTex;
bool exitGame;
void loadingScreen();
void mainMenu();
public:
Game();
int start();
};
#endif // GAME_H
//Game.cpp
#include "headers/game.hpp"
/*
* Private
*/
void Game::loadingScreen()
{
sf::Clock passedTime;
sf::Sprite sfmlLogo(sfmlLogoTex);
sfmlLogo.setPosition({10.f, getSize().y - sfmlLogoTex.getSize().y - 10.f});
while(passedTime.getElapsedTime().asSeconds() < 2.f)
{
clear({0, 0, 0});
sfmlLogo.setColor({255, 255, 255, passedTime.getElapsedTime().asSeconds() / 2.f * 255});
draw(sfmlLogo);
display();
}
/* Here load assets etc. */
standardCursor.loadFromFile("assets/graphics/UI/standardCursor.png");
while(passedTime.getElapsedTime().asSeconds() < 3.f)
display();
}
void Game::mainMenu()
{
sf::Sprite mainMenuCursor(standardCursor);
while(!exitGame)
{
for(sf::Event ev; pollEvent(ev);)
{
if(ev.type == sf::Event::KeyPressed && ev.key.code == sf::Keyboard::Escape)
exitGame = true;
}
clear({255, 0, 0});
mainMenuCursor.setPosition(mapPixelToCoords(sf::Mouse::getPosition(*this)) + sf::Vector2f(0, -25));
draw(mainMenuCursor);
display();
}
}
/*
* Public
*/
Game::Game()
{
sfmlLogoTex.loadFromFile("assets/graphics/loading/sflogo.png");
setFramerateLimit(120);
exitGame = false;
}
int Game::start()
{
this->setMouseCursorVisible(true);
loadingScreen();
mainMenu();
return 0;
}
//main.cpp
#include "game.hpp"
#include <iostream>
int main(int argc, char *argv[])
{
Game game;
game.create(sf::VideoMode::getDesktopMode(), "game", sf::Style::Fullscreen);
return game.start();
}