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 - krolik

Pages: [1]
1
Help requests / Re: EditBox acts strange.
« on: 07 January 2019, 21:03:20 »
Thanks! I managed to pull this off. Didn't need to change much tho, I had gameState variable, which changed depending on where I am in the game, my game loop has only switch instruction on current gameState:
while (window.isOpen())
        {
                sf::Event event;
                switch (menu.getGameState())
                {
                case 0:
                        menu.showMenu(event);
                        break;
                case 1:
                        std::cout << "LvlChoose" << std::endl;
                        break;
                case 2:
                        menu.showEdit(event);
                        break;
                case 3:
                        std::cout << "Play" << std::endl;
                        break;
                case 4:
                        std::cout << "Auto" << std::endl;
                        break;
                case 5:
                        menu.showAbout(event);
                        break;
                }
        }
And I changed fuctions to look like this:
void Menu::showEdit(sf::Event & event)
{
        while (window.pollEvent(event))
        {
                if (event.type == sf::Event::Closed)
                        window.close();
                editGui.handleEvent(event);
        }
        window.clear(sf::Color::White); // clear window with white color
        editGui.draw();
        window.display();
}
I think I actually tried that before, but I must've made some mistake along the way. Thanks again :)

2
Help requests / EditBox acts strange.
« on: 06 January 2019, 23:28:02 »
Hello!
I'm making a game using sfml + tgui, and for my level creator I need EditBoxes, so I made new tgui::Gui object for creator menu and loaded Widgets using loadWidgetsFromFile() function.
These Widget declarations in .txt file look like this:
EditBox.width {
    Position = (10, 40);
    DefaultText = "Number of cols...";
}
then, when in main menu I click button directing me to creator I'm calling this function in a loop:
void Menu::showEdit(sf::Event & event)
{
        if (event.type == sf::Event::Closed)
                window.close();
                window.clear(sf::Color::White); // clear window with white color
                editGui.handleEvent(event);
                editGui.draw(); // drawing loaded widgets
                window.display();
}
But with this code it doesn't work like it should, when I press any key loop manages to execute few times and I get a few characters instead of one, in addition, backspace doesn't work. I think I should change something in EditBok drawing, but I have run out of ideas, nothing seems to work so far. Could you give me some advice? I'm using TGUI 0.8. Thanks in advance :)

Pages: [1]