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

Author Topic: Fullscrean falling  (Read 1878 times)

0 Members and 1 Guest are viewing this topic.

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
Fullscrean falling
« on: June 11, 2015, 09:33:02 pm »
Hello, this is code cut off my game - strange thing is that fullscrean sometimes (randomly) falls. Sometimes it stays windowed, sometimes it falls to window and then resize back to fullscrean...
while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event)){
                        if (event.type == sf::Event::Closed)window.close();
                        if (event.key.code == sf::Keyboard::F4)window.create(sf::VideoMode(800, 650), "My window", sf::Style::Fullscreen);
                        if (event.key.code == sf::Keyboard::Escape)window.create(sf::VideoMode(800, 650), "My window", sf::Style::Default);
                }
 
is there a mistake in code? , is good idea to use events for this? Any ideas?
Thanks for replies.

AlejandroCoria

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • alejandrocoria.games
    • Email
Re: Fullscrean falling
« Reply #1 on: June 11, 2015, 09:45:07 pm »
You have to check if the event type is KeyPressed or KeyRelease before seeing what the key code.

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Fullscrean falling
« Reply #2 on: June 11, 2015, 10:31:05 pm »
Aside from failing to check the correct type before attempting read the key code as AlejandroCoria already mentioned, your resolution is not a typical monitor resolution so could be failing to create fullscreen as the monitor doesn't have the mode available.
Maybe try this test.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

AlejandroCoria

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • alejandrocoria.games
    • Email
Re: Fullscrean falling
« Reply #3 on: June 12, 2015, 01:45:04 am »
Wow, I completely overlooked that :P

CreaM

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Fullscrean falling
« Reply #4 on: June 12, 2015, 08:18:21 am »
Oh, 800 x 650 isnt a valid mode, stupid mistake...
Thank you for solving it.  :-*

 

anything