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

Pages: [1]
1
General / Re: How to make dialog boxes with sfml in a simple way?
« on: January 05, 2019, 03:23:56 am »
I mean that in some situation I want to press a key to do something, but how does the program know that I'm just pressing a key not entering texts if both events happen? And in other situations, I need to input texts.

2
General / Re: How to make dialog boxes with sfml in a simple way?
« on: January 04, 2019, 03:50:59 pm »
Now, I have another question.
How to deal with  "both" KeyPressed and TextEntered in the while loop? It seems that when there is  case sf::Event::TextEntered: , case sf::Event::KeyPressed: will not be detected. Could anyone help me with this, please? Thank you.


 while (window.pollEvent(event))
        {
            switch(event.type)
            {
            case(sf::Event::Closed):
                window.close();
                break;
            case sf::Event::KeyPressed:
                if(event.key.code == sf::Keyboard::Q)
                {
                    sd.play();
                }
                else if(event.key.code == sf::Keyboard::P)
                {
                    if(music.getStatus() == sf::Sound::Playing)
                        music.pause();
                    else
                        music.play();
                }
           break;
           
            case sf::Event::TextEntered:
                    if(event.text.unicode >= 32 && event.text.unicode <= 126)
                        sentence += static_cast<char>(event.text.unicode);
                    else if(event.text.unicode == 8 && sentence.getSize() > 0)
                        sentence.erase(sentence.getSize() - 1, sentence.getSize());

                    text.setString(sentence);
             break;
            }
        }

3
General / Re: How to make dialog boxes with sfml in a simple way?
« on: January 04, 2019, 04:07:38 am »
The simplest way to recreate something like your attached screenshot would be to just use a sf::RectangleShape to draw the dialog box background, and then use sf::Text to draw the words on top of it.

If you need something more advanced than that you may need to be more specific with your question.

Thanks, I'll try it.

4
General / How to make dialog boxes with sfml in a simple way?
« on: January 03, 2019, 05:31:01 pm »
Hello
I'm using sfml 2.5.1 with c++, and I'm really new to it. My problem is that I don't know how to create dialog boxes. I have been searching about this online, but I can't quite get how to do it. Could anyone tell me a simple way to create dialog boxes or tell me where to find related tutorials? Thank you!

p.s. something similar to the attached picture would be pretty fine for me


Pages: [1]