A
A
Andrey Onkhor2018-12-11 15:26:28
C++ / C#
Andrey Onkhor, 2018-12-11 15:26:28

Annoying problem. How to solve it?

Hi guys! Started writing in the SFML framework. There was a problem with the constantly loading cursor icon, I did something wrong. I know it's a minor issue, but I'd like to fix it.
main.cpp

#include <SFML/Graphics.hpp>
#include <iostream>
#include "Game.h"

using namespace std;
using namespace sf;

int main() 
{
  StartGame();
  return 0;
}

Game.h
using namespace sf;
using namespace std;

bool menu(RenderWindow & window){
  Texture NewGame_sp;
  Texture Options_sp;
  Texture Exit_sp;
  NewGame_sp.loadFromFile("Resources/Textures/Menu/NewGameTexture.png");
  if (!NewGame_sp.loadFromFile("Resources/Textures/Menu/NewGameTexture.png")) { cout << "Error: 001"; }
  Options_sp.loadFromFile("Resources/Textures/Menu/OptionsTexture.png");
  if (!Options_sp.loadFromFile("Resources/Textures/Menu/OptionsTexture.png")) { cout << "Error: 002"; }
  Exit_sp.loadFromFile("Resources/Textures/Menu/ExitTexture.png");
  if (!Exit_sp.loadFromFile("Resources/Textures/Menu/ExitTexture.png")) { cout << "Error: 003"; }
  Sprite NewGame(NewGame_sp); 
  Sprite Options(Options_sp);
  Sprite Exit(Exit_sp);
  bool isMenu = 1;
  int MenuNum;
  NewGame.setPosition(533, 300);
  Options.setPosition(533, 400);
  Exit.setPosition(533, 500);
  while (isMenu)
  {
    NewGame.setColor(Color::White);
    Options.setColor(Color::White);
    Exit.setColor(Color::White);
    MenuNum = 0;
    
    if (IntRect(533, 300, 251, 36).contains(Mouse::getPosition(window))) { MenuNum = 1; NewGame.setColor(Color(105, 105, 105)); }
    if (IntRect(533, 400, 251, 36).contains(Mouse::getPosition(window))) { MenuNum = 2; Options.setColor(Color(105, 105, 105)); }
    if (IntRect(533, 500, 251, 36).contains(Mouse::getPosition(window))) { MenuNum = 3; Exit.setColor(Color(105, 105, 105)); }

    window.clear();
    window.draw(NewGame);
    window.draw(Options);
    window.draw(Exit);
    window.display();
  }
  return false;
}


void StartGame() 
{
  RenderWindow window(VideoMode(1366, 768), "First Dragon");
  menu(window);
  while (window.isOpen())
  {


    Event exit;
    while (window.pollEvent(exit))
    {
      if (exit.type == Event::Closed)
        window.close();
    }
  }
}

And here is a screenshot
skrinshoter.ru/s/111218/9A7p19KQ?a

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question