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

Author Topic: How to change the display in the window  (Read 1850 times)

0 Members and 1 Guest are viewing this topic.

Dima00782@yandex.ru

  • Newbie
  • *
  • Posts: 2
    • View Profile
How to change the display in the window
« on: December 04, 2013, 02:09:58 pm »
Hello everybody.

I want to implement this behavior:

The user initially sees the main application window - menu, this menu has items - "options", "load", "save", "play."

I want to switch to another view when click on "play". How do I do this?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: How to change the display in the window
« Reply #1 on: December 04, 2013, 02:19:56 pm »
This is done by having multiple surfaces, often called "states", such as main menu, options, game.

One possibility is to have an abstract base class State and derived classes MainMenu, Options, Game for a concrete state. When clicking a button, the state is changed (either by creating a new state object and possibly destroying the old one, or just changing a pointer).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Dima00782@yandex.ru

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How to change the display in the window
« Reply #2 on: December 04, 2013, 02:25:51 pm »
Thanks for the answer.
From the point of view of patterns it is clear but how to make it in sfml? What classes to use, right there is no JPanel or JFrame as in Swing.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: How to change the display in the window
« Reply #3 on: December 04, 2013, 03:27:08 pm »
There are no GUI classes in SFML. You can either build your own around the basic drawables (sf::Text, sf::Sprite, sf::Shape), or use an existing GUI extension such as SFGUI or TGUI.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything