Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Asbestbrezel

Pages: [1]
1
Window / Re: [c++] give the Render-Window the Focus
« on: December 29, 2013, 03:47:16 pm »
But keep in mind, you're not alone! There have already been similar requests, e.g. here or here. Nobody however took their time to open a ticket on the issue tracker (as far as I know) - so feel free to do so.

Done!  ;)

2
Window / [c++] give the Render-Window the Focus
« on: December 28, 2013, 10:01:55 pm »
Hello.

I create my RenderWindow in the Constructor of my CGame-Class, which instance is created after an Input of the lives, the players shall get.

Now, the Problem is, under Windows (no Problem under Linux <3 ) the new created RenderWindow looses the focus, right after it was created. Apparently because i used cin before, if i avoid the console-input, everything works fine.

#include "CGame.hpp"
#include <iostream>

using namespace std;

int main()
{

        int lifes=0;
        do
        {
                badInput=false;
                cout << "How much Lifes do all the players get? (1 to 20):";
                cin >> lifes;
                if (cin.fail() || cin.bad())
                {
                        cin.clear();
                        while (cin.get() != '\n');
                        cout << "Bad Input, my Dear" << endl;
                        badInput=true;
                }
                if (lifes < 1 || lifes > 20)
                {
                        cout << "No Sir, wrong Number!" << endl;
                        badInput=true;
                }
        } while (badInput);
       


        CGame game(4, 2, lifes);


        game.run();

return 0;
}

CGame::CGame(int players, int humanPlayers, int lifes)
: _timePerFrame(sf::seconds(1.f/60.f))
, _window(sf::VideoMode::getDesktopMode(), "Kosmosgeballer beta - v0.1", sf::Style::Fullscreen)
, _view(sf::FloatRect(0.f,0.f,1920.f,1080.f))
{
    _gameOver=false;
    _humanPlayerCount=humanPlayers;
    _backgroundTexture.loadFromFile("Media/Textures/Background2.png");
    _backgroundImage.setTexture(_backgroundTexture);

    _window.setView(_view);

    if ((_window.getSize().x / _window.getSize().y) <= (16.f/9.f))
        _view.setViewport(sf::FloatRect(0.f, ((_window.getSize().y/2.f)-((_window.getSize().x/(16.f/9.f))/2.f))/_window.getSize().y, 1.f, (_window.getSize().x/(16.f/9.f))/_window.getSize().y));
    else _view.setViewport(sf::FloatRect(((_window.getSize().x/2.f)-((_window.getSize().y*(16.f/9.f))/2.f))/_window.getSize().x, 0.f, (_window.getSize().y*(16.f/9.f))/_window.getSize().x, 1.f));

    for (int i=0; i<players; i++)
    {
        _playerlist.emplace_back (_window, i, lifes);
        _playerlist.back().reset(_playerlist, 0);
        if (i >= humanPlayers) _mutterlist.emplace_back (i, _playerlist);
    }
}

What can i do, to prevent the Window from loosing the focus or how can i give it back to it?

Thanks for your Help.

Pages: [1]